当前位置: 首页>>代码示例>>Java>>正文


Java SessionPersisterSuperConverter类代码示例

本文整理汇总了Java中ca.sqlpower.dao.session.SessionPersisterSuperConverter的典型用法代码示例。如果您正苦于以下问题:Java SessionPersisterSuperConverter类的具体用法?Java SessionPersisterSuperConverter怎么用?Java SessionPersisterSuperConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SessionPersisterSuperConverter类属于ca.sqlpower.dao.session包,在下文中一共展示了SessionPersisterSuperConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: undoForSession

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
public static void undoForSession(SPObject root,
		List<PersistedSPObject> creations,
		Multimap<String, PersistedSPOProperty> properties,
		List<RemovedObjectEntry> removals,
		SessionPersisterSuperConverter converter) throws SPPersistenceException {
	
	List<PersistedObjectEntry> c = new LinkedList<PersistedObjectEntry>();
	List<PersistedPropertiesEntry> p = new LinkedList<PersistedPropertiesEntry>();
	LinkedHashMap<String, RemovedObjectEntry> r = new LinkedHashMap<String, RemovedObjectEntry>();
	
	for (PersistedSPObject pso : creations) {
		c.add(new PersistedObjectEntry(pso.getParentUUID(), pso.getUUID()));
	}
	for (PersistedSPOProperty property : properties.values()) {
		p.add(new PersistedPropertiesEntry(property.getUUID(), property.getPropertyName(), property.getDataType(), property.getOldValue()));
	}
	for (RemovedObjectEntry removal : removals) {
		r.put(removal.getRemovedChild().getUUID(), removal);
	}
	
	undoForSession(root, c, p, r, converter);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:23,代码来源:SPSessionPersister.java

示例2: setUp

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
	super.setUp();
	root = new SPObjectRoot();
	StubWorkspaceContainer stub = new StubWorkspaceContainer() {
		private final SPObject workspace = new StubWorkspace(this, this, root);
		@Override
		public SPObject getWorkspace() {
			return workspace;
		}
	};
	root.setParent(stub.getWorkspace());
	SQLObjectRoot sqlRoot = new SQLObjectRoot();
	root.addChild(sqlRoot, 0);
	if (setupDB) {
		sqlRoot.addDatabase(db, 0);
	}
	
	converter = new SessionPersisterSuperConverter(
			getPLIni(), root);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:22,代码来源:PersistedSPObjectTest.java

示例3: getInterestingProperties

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
/**
 * Does what the other getInterestingProperties says it does if passed a non-null object
 * Otherwise, it will return a map with a key set of all the property names, but no values.
 * 
 * @param type
 * @param object
 * @param converter
 * @return
 * @throws SecurityException
 * @throws ClassNotFoundException
 * @throws IllegalArgumentException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 */
   private static Map<String, Object> getInterestingProperties(
           String type, SQLObject object, SessionPersisterSuperConverter converter)
throws SecurityException, ClassNotFoundException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    Map<String, Object> propertyMap = new HashMap<String, Object>();
    
    Class<? extends Object> objectClass = Class.forName(type, true, PersisterUtils.class.getClassLoader());
    for (Method m : objectClass.getMethods()) {
        
        if (m.getAnnotation(Accessor.class) != null
                && m.getAnnotation(Accessor.class).isInteresting()) {
            String propertyName;
            if (m.getName().startsWith("get")) {
                   propertyName = m.getName().substring(3);
               } else if (m.getName().startsWith("is")) {
                   propertyName = m.getName().substring(2);
               } else {
                   throw new RuntimeException("Accessor class with improper prefix");
               }
            String firstCharacter = String.valueOf(propertyName.charAt(0));
            
            propertyName = propertyName.replaceFirst(
                    firstCharacter, firstCharacter.toLowerCase());
            
            if (object != null) {
                propertyMap.put(propertyName, 
                        converter.convertToBasicType(m.invoke(object)));
            } else {
                propertyMap.put(propertyName, "");
            }
        }
        
    }
    return propertyMap;
    
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:50,代码来源:PersisterUtils.java

示例4: redoForSession

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
public static void redoForSession(
		SPObject root,
		List<PersistedSPObject> creations,
		Multimap<String, PersistedSPOProperty> properties,
		List<RemovedObjectEntry> removals,
		SessionPersisterSuperConverter converter) throws SPPersistenceException
{
	SPSessionPersister persister = new SPSessionPersister("redoer", root, converter) {
		@Override
		protected void refreshRootNode(PersistedSPObject pso) {
			//do nothing for refresh.
		}
	};
	
	Map<String, String> objToRmv = new TreeMap<String, String>(persister.removedObjectComparator);
	for (RemovedObjectEntry roe : removals) {
		objToRmv.put(roe.getRemovedChild().getUUID(), roe.getParentUUID());
	}
	
	persister.setWorkspaceContainer(root.getWorkspaceContainer());
	persister.setGodMode(true);
	persister.setPersistedObjects(creations);
	persister.setPersistedProperties(properties);
	persister.setObjectsToRemove(objToRmv);

	persister.begin();
	persister.commit();
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:29,代码来源:SPSessionPersister.java

示例5: testAddRemoveAddObject

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
/**
 * Tests an object can go through an add, remove, and add again set of calls
 * in one transaction in a persister listener. Test regression for bug 2830.
 */
public void testAddRemoveAddObject() throws Exception {
    NewValueMaker valueMaker = new GenericNewValueMaker(root);
    SQLTable table = (SQLTable) valueMaker.makeNewValue(SQLTable.class, null, "");
    SQLColumn col = new SQLColumn();
    
    CountingSPPersister targetPersister = new CountingSPPersister();
    SessionPersisterSuperConverter converter = new SessionPersisterSuperConverter(null, table);
    SPPersisterListener listener = new SPPersisterListener(targetPersister, converter);
    table.addSPListener(listener);
    
    table.begin("Test transaction");
    table.addColumn(col);
    
    //Contains SQLTable, its UserDefinedSQLType and its SQLTypePhysicalProperties
    assertEquals(3, listener.getPersistedObjects().size());
    
    table.removeColumn(col);
    
    assertEquals(0, listener.getPersistedObjects().size());
    assertEquals(0, listener.getPersistedProperties().size());
    
    table.addColumn(col);
    
    assertEquals(3, listener.getPersistedObjects().size());
    assertTrue(!listener.getPersistedProperties().isEmpty());
    table.commit();
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:32,代码来源:SPPersisterListenerTest.java

示例6: setConverter

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
public void setConverter(SessionPersisterSuperConverter converter) {
    this.converter = converter;
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:4,代码来源:AbstractNetworkConflictResolver.java

示例7: generateImports

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
/**
 * Generates and returns source code for importing packages that are
 * required by the persister helper this class is generating.
 * 
 * @param visitedClass
 *            The {@link SPObject} class that is being visited by the
 *            annotation processor.
 * @param constructorImports
 *            The {@link Set} of packages that visitedClass uses in its
 *            {@link Constructor} annotated constructor and need to be
 *            imported.
 * @param mutatorImports
 *            The {@link Multimap} of setter methods to packages that
 *            visitedClass uses in its {@link Mutator} annotated methods and
 *            needs to be imported.
 * @return The source code for the generated imports.
 */
private String generateImports(
		Class<? extends SPObject> visitedClass, 
		Set<String> constructorImports,
		Multimap<String, String> mutatorImports) {
	final String helperPackage = visitedClass.getPackage().getName() + "." + PersisterHelperFinder.GENERATED_PACKAGE_NAME;
	
	// Using a TreeSet here to sort imports alphabetically.
	Set<String> allImports = new TreeSet<String>();
	if (!Modifier.isAbstract(visitedClass.getModifiers())) {
	    allImports.addAll(constructorImports);
	}
	allImports.addAll(mutatorImports.values());
	
	StringBuilder sb = new StringBuilder();
	
	// XXX Need to import any additional classes this generated persister helper
	// class requires, aside from those needed in visitedClass.
	allImports.add(List.class.getName());
	allImports.add(visitedClass.getName());
	allImports.add(SPPersistenceException.class.getName());
	allImports.add(SPPersister.class.getName());
	allImports.add(SessionPersisterSuperConverter.class.getName());
	allImports.add(SPObject.class.getName());
	allImports.add(DataType.class.getName());
	allImports.addAll(importedClassNames);
	
	for (String pkg : allImports) {
		// No need to import java.lang as it is automatically imported.
		// No need to import package if the persister helper is already
		// in the package.
		// Also want to keep array classes out
		if (!pkg.startsWith("java.lang") && !pkg.startsWith("[L")) {
			// Nested classes, enums, etc. will be separated by the "$"
			// character but we need to change them to "." so it can be
			// imported correctly.
			String pkgName = pkg.replaceAll("\\$", ".");
			
			// Only import the package if it is not the same one
			// that the persister helper exists in.
			int index = pkgName.lastIndexOf(".");
			if (index == -1) {
				index = pkgName.length();
			}
			if (!pkgName.substring(0, index).equals(helperPackage)) {
				niprintln(sb, "import " + pkgName + ";");
			}
		}
	}
	
	return sb.toString();
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:69,代码来源:SPAnnotationProcessor.java

示例8: testRemoveOfRemovedObjects

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
/**
 * Tests that calling remove on an object whose parent has already been
 * removed in the same transaction is successfully removed.
 */
public void testRemoveOfRemovedObjects() throws Exception {
    final SQLDatabase testDatabase = new SQLDatabase();
    SQLTable table1 = new SQLTable(testDatabase, true);
    testDatabase.addTable(table1);
    SQLTable table2 = new SQLTable(testDatabase, true);
    testDatabase.addTable(table2);
    SQLRelationship relationship = new SQLRelationship();
    relationship.attachRelationship(table1, table2, true);
    
    assertEquals(1, table1.getExportedKeys().size());
    assertEquals(relationship, table1.getExportedKeys().get(0));
    assertEquals(1, table2.getImportedKeys().size());
    assertEquals(relationship.getForeignKey(), table2.getImportedKeys().get(0));
    
    SPSessionPersister sessionPersister = new SPSessionPersister(
            "Testing persister", testDatabase, new SessionPersisterSuperConverter(
                    new PlDotIni(), testDatabase)) {
    
        @Override
        protected void refreshRootNode(PersistedSPObject pso) {
            //do nothing
        }
    };
    sessionPersister.setWorkspaceContainer(new WorkspaceContainer() {
        public SPObject getWorkspace() {
            return testDatabase;
        }
    });
    
    sessionPersister.begin();
    sessionPersister.removeObject(testDatabase.getUUID(), table1.getUUID());
    sessionPersister.removeObject(table1.getUUID(), relationship.getUUID());
    sessionPersister.commit();
    
    assertEquals(1, testDatabase.getChildCount());
    assertEquals(table2, testDatabase.getTables().get(0));
    
    //Although this leaves the table in an invalid state there was no persist call
    //to actually remove the imported key so it should stay there.
    assertEquals(1, table2.getChildren(SQLImportedKey.class).size());
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:46,代码来源:SPSessionPersisterTest.java

示例9: TestingSessionPersister

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
public TestingSessionPersister(String name, SPObject root,
		SessionPersisterSuperConverter converter) {
	super(name, root, converter);
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:5,代码来源:PersistedSPObjectTest.java

示例10: MatchMakerSessionPersister

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
public MatchMakerSessionPersister(String name, SPObject root,
		SessionPersisterSuperConverter converter) {
	super(name, root, converter);
}
 
开发者ID:SQLPower,项目名称:power-matchmaker,代码行数:5,代码来源:MatchMakerSessionPersister.java

示例11: SPPersisterListener

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
/**
 * For the rest of the parameters see
 * {@link #SPPersisterListener(SPPersister, SPSessionPersister, SessionPersisterSuperConverter)}
 * 
 * @param rollbackUpdatesWorkspace
 *            If true this listener will roll back changes it heard when
 *            rollback is performed. Rollback is normally performed when
 *            either explicitly called or when an exception occurs in a
 *            later persister. If false the listener will reset but it will
 *            not update the workspace it is listening to.
 */
public SPPersisterListener(SPPersister target, SPSessionPersister dontEcho, 
		SessionPersisterSuperConverter converter, SPSessionPersister rollbackPersister) {
	this.target = target;
	this.converter = converter;
	this.eventSource = dontEcho;
	this.rollbackPersister = rollbackPersister;
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:19,代码来源:SPPersisterListener.java

示例12: commitObject

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
/**
 * Creates a new {@link SPObject} of type T given a {@link Multimap} of
 * {@link SPObject} UUIDs to persisted properties. The properties taken from
 * the {@link Multimap} of the given UUID to pass into the {@link SPObject}
 * constructor must be removed.
 * 
 * @param pso
 *            The {@link PersistedSPObject} that the {@link SPObject} is
 *            being created from. The UUID to use for the created
 *            {@link SPObject} is to be taken from this object and the
 *            loaded flag should be set the <code>true</code> before
 *            returning the newly created {@link SPObject}.
 * @param persistedProperties
 *            A mutable {@link Multimap} of {@link SPObject} UUIDs to
 *            persisted properties, each represented by
 *            {@link PersistedSPOProperty}. Some entries within this
 *            {@link Multimap} will be removed if the {@link SPObject}
 *            constructor it calls requires arguments.
 * @param persistedObjects
 *            The {@link List} of {@link PersistedSPObject}s that has been
 *            persisted in an {@link SPPersister}. This is to be used for
 *            {@link SPObject}s that take children in their constructor,
 *            where the {@link SPPersisterHelper} factory finds the
 *            appropriate {@link SPPersisterHelper} for that child type and
 *            calls commitObject on that as well.
 * @param converter
 *            The {@link SPPersisterHelperFactory} to use to convert complex
 *            properties into simple ones.
 * @return The created {@link SPObject} with the given required persisted
 *         properties.
 */
T commitObject(PersistedSPObject pso,
		Multimap<String, PersistedSPOProperty> persistedProperties, 
		List<PersistedSPObject> persistedObjects,
		SessionPersisterSuperConverter converter) throws SPPersistenceException;
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:36,代码来源:SPPersisterHelper.java

示例13: commitProperty

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
/**
 * Applies a property change on the given {@link SPObject} and property
 * name.
 * 
 * @param spo
 *            The {@link SPObject} to apply the property change on.
 * @param propertyName
 *            The JavaBean property name.
 * @param newValue
 *            The new property value. This value must be converted through
 *            the {@link SessionPersisterSuperConverter} from simple type
 *            into a complex type before setting the property value.
 * @param type
 *            The object type that the new value is reported to be from the
 *            persist call.
 * @param converter
 *            The {@link SessionPersisterSuperConverter} class to use to
 *            convert newValue from a simple type to a complex type.
 * @throws SPPersistenceException
 *             Thrown if the property is not a persistable property. The
 *             setter method for this property in the {@link SPObject} class
 *             must be annotated with {@link Mutator}.
 */
void commitProperty(SPObject spo, String propertyName, Object newValue, DataType type, 
		SessionPersisterSuperConverter converter) throws SPPersistenceException;
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:26,代码来源:SPPersisterHelper.java

示例14: findProperty

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
/**
 * Finds and returns a property value from the given {@link SPObject} based
 * on the property name and converts it to something that can be passed to
 * an {@link SPPersister}.
 * 
 * @param spo
 *            The {@link SPObject} to retrieve the property from.
 * @param propertyName
 *            The property name that needs to be retrieved and converted.
 *            This is the name of the property in the class itself based on
 *            the property fired by the setter for the event which is
 *            enforced by tests using JavaBeans methods. If changes are made
 *            to an {@link SPObject} class such that one or more properties
 *            are changed (i.e. changed property name or property type), the
 *            {@link SPAnnotationProcessorFactory} should be executed to
 *            generate an updated {@link SPPersisterHelper} class.
 * @param converter
 *            The {@link SessionPersisterSuperConverter} class to use to
 *            convert the retrieved property value from a complex type to a
 *            simple type.
 * @return The value stored in the variable of the object we are given at
 *         the property name after it has been converted to a type that can
 *         be stored. The conversion is based on the
 *         {@link SessionPersisterSuperConverter}.
 * @throws SPPersistenceException
 *             Thrown if the property is not a persistable property. The
 *             getter method for this property in the {@link SPObject} class
 *             must be annotated with {@link Accessor}.
 */
Object findProperty(SPObject spo, String propertyName, 
		SessionPersisterSuperConverter converter) throws SPPersistenceException;
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:32,代码来源:SPPersisterHelper.java

示例15: persistObject

import ca.sqlpower.dao.session.SessionPersisterSuperConverter; //导入依赖的package包/类
/**
 * Persists an {@link SPObject} and all of its required properties into an
 * {@link SPPersister}. The persisted properties must either have
 * getter/setter methods annotated with {@link Accessor} and {@link Mutator}
 * , or be set in a constructor annotated with {@link Constructor} where its
 * parameters are annotated with {@link ConstructorParameter} with reference
 * to the property it will set.
 * 
 * @param o
 *            The {@link SPObject} to persist along with its required
 *            properties.
 * @param index
 *            The index of the {@link SPObject} to persist relative to its
 *            siblings of the same type.
 * @param persister
 *            The {@link SPPersister} to persist the object onto.
 * @param converter
 *            The {@link SessionPersisterSuperConverter} class to use to
 *            convert the properties of the {@link SPObject} from complex
 *            types to simple types which will be recognized by the
 *            {@link SPPersister}.
 * @throws SPPersistenceException
 *             Thrown if the {@link SPPersister} cannot persist the object
 *             or any one of its properties.
 */
void persistObject(SPObject o, int index, SPPersister persister, 
		SessionPersisterSuperConverter converter) throws SPPersistenceException;
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:28,代码来源:SPPersisterHelper.java


注:本文中的ca.sqlpower.dao.session.SessionPersisterSuperConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。