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


Java SQLPowerUtils.findByUuid方法代码示例

本文整理汇总了Java中ca.sqlpower.util.SQLPowerUtils.findByUuid方法的典型用法代码示例。如果您正苦于以下问题:Java SQLPowerUtils.findByUuid方法的具体用法?Java SQLPowerUtils.findByUuid怎么用?Java SQLPowerUtils.findByUuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca.sqlpower.util.SQLPowerUtils的用法示例。


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

示例1: rollbackRemovals

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
 * Rolls back the removal of persisted {@link WabitObject}s
 * 
 * @throws SPPersistenceException
 *             Thrown if a WabitObject could not be rolled back from its parent.
 */
private void rollbackRemovals() throws IllegalStateException {
	// We must rollback in the inverse order the operations were performed.
	Collections.reverse(this.objectsToRemoveRollbackList);
	for (RemovedObjectEntry entry : this.objectsToRemoveRollbackList) {
		final String parentUuid = entry.getParentUUID();
		final SPObject objectToRestore = entry.getRemovedChild();
		final int index = entry.getIndex();
		final SPObject parent = SQLPowerUtils.findByUuid(root, parentUuid, SPObject.class);
		try {
			parent.addChild(objectToRestore, index);
		} catch (Throwable t) {
			// Keep going. We need to rollback as much as we can.
			logger.error("Cannot rollback " + entry.getRemovedChild() + " child removal", t);
		}
	}
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:23,代码来源:WabitSessionPersister.java

示例2: rollbackProperties

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
private void rollbackProperties() throws SPPersistenceException {
	Collections.reverse(this.persistedPropertiesRollbackList);
	for (PersistedPropertiesEntry entry : this.persistedPropertiesRollbackList) {
		try {
			final String parentUuid = entry.getUUID();
			final String propertyName = entry.getPropertyName();
			final Object rollbackValue = entry.getRollbackValue();
			final SPObject parent = SQLPowerUtils.findByUuid(root, parentUuid, SPObject.class);
			if (parent != null) {
				this.applyProperty(parent, propertyName, rollbackValue);
			}
		} catch (Throwable t) {
			// Keep going. We need to rollback as much as we can.
			logger.error("Cannot rollback change to " + entry.getPropertyName() + " to value " + entry.getRollbackValue(), t);
		}
	}
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:18,代码来源:WabitSessionPersister.java

示例3: rollbackCreations

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
private void rollbackCreations() throws Exception {
	Collections.reverse(this.persistedObjectsRollbackList);
	for (PersistedObjectEntry entry : this.persistedObjectsRollbackList) {
		try {
			// We need to verify if the entry specifies a parent.
			// WabitWorkspaces don't have parents so we can't remove them really...
			if (entry.getParentId() != null) {
				final SPObject parent = SQLPowerUtils.findByUuid(root, entry.getParentId(), SPObject.class);
				final SPObject child = SQLPowerUtils.findByUuid(root, entry.getChildId(), SPObject.class);
				parent.removeChild(child);
			}
		} catch (Throwable t) {
			// Keep going. We need to rollback as much as we can.
			logger.error("Cannot rollback " + entry.getChildId() + " child creation", t);
		}
	}
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:18,代码来源:WabitSessionPersister.java

示例4: aggregateDependantObjectsUnsafe

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
 * Returns all objects that depend on the object represented by rootUuid. If
 * a user has read access on an object, he must also have read access on all
 * objects it depends upon. This method is not thread safe, and must be
 * externally synchronized. Use {@link #aggregateDependantObjects(String)}
 * instead.
 * 
 * @param rootUuid
 *            The UUID of the object in question.
 * @return A Collection of all objects that depend on the given object.
 */
protected Collection<SPObject> aggregateDependantObjectsUnsafe(@Nonnull String rootUuid) {
	if (getCurrentSession() == null) {
		return Collections.emptyList();
	}
	final SPObject workspace = getCurrentSession().getWorkspace();
	SPObject root = SQLPowerUtils.findByUuid(workspace, rootUuid, SPObject.class);
	// Must find all dependent objects, but not ancestors
	WorkspaceGraphModel graph = new WorkspaceGraphModel(workspace,
			root, true, true);
	List<SPObject> parents = new LinkedList<SPObject>();
	for (SPObject wo : graph.getNodes()) {
		if (wo instanceof WabitWorkspace) {
			parents.add(wo);
			continue;
		}
		while (!(wo.getParent() instanceof WabitWorkspace)) {
			wo = wo.getParent();
		}
		parents.add(wo);
	}
	return parents;
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:34,代码来源:WabitAccessManager.java

示例5: getAncestorListFromPersistedObjects

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
 * Returns an ancestor list of {@link PersistedSPObject}s from a given
 * child PersistedSPObject.
 */
private List<PersistedSPObject> getAncestorListFromPersistedObjects(PersistedSPObject child) {
	List<PersistedSPObject> resultList = new ArrayList<PersistedSPObject>();

	// Iterate through list of persisted WabitObjects to build an ancestor
	// list from objects that do not exist in the workspace yet.
	String uuid = child.getParentUUID();
	PersistedSPObject pwo;
	while ((pwo = findPersistedObjectByUUID(uuid)) != null) {
		resultList.add(0, pwo);
		uuid = pwo.getParentUUID();
	}

	// Iterate through list of existing WabitObjects in the workspace and
	// build the rest of the ancestor list.
	SPObject spo = SQLPowerUtils.findByUuid(root, uuid, SPObject.class);
	if (spo != null) {
		resultList.add(0, createPersistedObjectFromSPObject(spo));
		List<SPObject> ancestorList = SQLPowerUtils.getAncestorList(spo);

		for (SPObject ancestor : ancestorList) {
			resultList.add(0, createPersistedObjectFromSPObject(ancestor));
		}
	}
	
	return resultList;
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:31,代码来源:WabitSessionPersister.java

示例6: commitObjects

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
 * Commits the persisted {@link WabitObject}s
 * 
 * @throws SPPersistenceException
 */
private void commitObjects() throws SPPersistenceException {
	List<PersistedSPObject> orderedPersistedObjects = new ArrayList<PersistedSPObject>(persistedObjects.size());
	orderedPersistedObjects.addAll(persistedObjects.values());
	Collections.sort(orderedPersistedObjects, persistedObjectComparator);
	
	for (PersistedSPObject pwo : orderedPersistedObjects) {
		if (pwo.isLoaded())
			continue;
		SPObject parent = SQLPowerUtils.findByUuid(root, pwo
				.getParentUUID(), SPObject.class);
		SPObject spo = loadWabitObject(pwo);
		if (spo != null) {
			SPListener removeChildOnAddListener = new AbstractSPListener() {
				public void childRemoved(SPChildEvent e) {
					objectsToRemoveRollbackList.add(
							new RemovedObjectEntry(e.getSource().getUUID(), e.getChild(), e.getIndex()));
				}
			};
			parent.addSPListener(removeChildOnAddListener);
			// FIXME Terrible hack, see bug 2326
			parent.addChild(spo, Math.min(pwo.getIndex(), parent.getChildren(spo.getClass()).size()));
			parent.removeSPListener(removeChildOnAddListener);
			this.persistedObjectsRollbackList.add(
				new PersistedObjectEntry(
					parent.getUUID(), 
					spo.getUUID()));
		}
	}
	persistedObjects.clear();
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:36,代码来源:WabitSessionPersister.java

示例7: commitProperties

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
 * Commits the persisted {@link WabitObject} property values
 * 
 * @throws SPPersistenceException
 *             Thrown if an invalid WabitObject type has been persisted into
 *             storage. This theoretically should not occur.
 */
private void commitProperties() throws SPPersistenceException {
	SPObject spo;
	String propertyName;
	Object newValue;

	for (String uuid : persistedProperties.keySet()) {
		spo = SQLPowerUtils.findByUuid(root, uuid, SPObject.class);
		if (spo == null) {
			throw new IllegalStateException("Couldn't locate object "
					+ uuid + " in session");
		}

		for (PersistedSPOProperty wop : persistedProperties.get(uuid)) {
			
			propertyName = wop.getPropertyName();
			newValue = wop.getNewValue();

			applyProperty(spo, propertyName, newValue);
			
			this.persistedPropertiesRollbackList.add(
				new PersistedPropertiesEntry(
					spo.getUUID(), //The uuid can be changed so using the currently set one.
					wop.getPropertyName(), 
					wop.getDataType(), 
					wop.getOldValue()));
		}
	}
	persistedProperties.clear();
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:37,代码来源:WabitSessionPersister.java

示例8: persistObject

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
 * Persists a {@link WabitObject} given by its UUID, class name, and parent
 * UUID
 * <p>
 * A new {@link WabitWorkspace} object signals that there is a new workspace
 * being persisted and the current one attached to this listener must either
 * go away or clean up. See the class level documentation for more on this special
 * case.
 * 
 * @param parentUUID
 *            The parent UUID of the {@link WabitObject} to persist
 * @param type
 *            The class name of the {@link WabitObject} to persist
 * @param uuid
 *            The UUID of the {@link WabitObject} to persist
 * @param index
 *            The index of the {@link WabitObject} within its parents' list
 *            of children
 * 
 * @throws SPPersistenceException
 *             Thrown if the property name is not known in this method.
 */
public void persistObject(String parentUUID, String type, String uuid,
		int index) throws SPPersistenceException {
	synchronized (session) {
		this.enforeThreadSafety();
		if (logger.isDebugEnabled()) {
			logger.debug(String.format(
					"wsp.persistObject(\"%s\", \"%s\", \"%s\", %d);", parentUUID,
					type, uuid, index));
		}
		if (transactionCount == 0) {
			this.rollback();
			throw new SPPersistenceException("Cannot persist objects while outside a transaction.");
		}
		SPObject objectToPersist = SQLPowerUtils.findByUuid(root, uuid, SPObject.class);
		boolean isWorkspace= objectToPersist instanceof WabitWorkspace;
		if (objectToPersist != null && isWorkspace) {
			//reset now or the next object persisted will fail a few lines down.
			((WabitWorkspace) objectToPersist).reset();
		}
		if (exists(uuid) && !isWorkspace) {
			this.rollback();
			throw new SPPersistenceException(uuid,
					"A WabitObject with UUID " + uuid + " and type " + type
					+ " under parent with UUID " + parentUUID
					+ " already exists.");
		}

		PersistedSPObject pwo = new PersistedSPObject(parentUUID,
				type, uuid, index);
		persistedObjects.put(uuid, pwo);
	}
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:55,代码来源:WabitSessionPersister.java

示例9: convertToComplexType

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
public SPObject convertToComplexType(String convertFrom)
		throws ConversionException {
	if (lookupCache != null && lookupCache.get(convertFrom) != null) return lookupCache.get(convertFrom);
	return SQLPowerUtils.findByUuid(root, convertFrom, SPObject.class); 
}
 
开发者ID:SQLPower,项目名称:sqlpower-library,代码行数:6,代码来源:SPObjectConverter.java

示例10: findByUuid

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
 * Locates the WabitObject inside this workspace which has the given UUID,
 * returning null if the item is not found. Throws ClassCastException if in
 * item is found, but it is not of the expected type.
 * 
 * @param <T>
 *            The expected type of the item
 * @param uuid
 *            The UUID of the item
 * @param expectedType
 *            The type of the item with the given UUID. If you are uncertain
 *            what type of object it is, or you do not want a
 *            ClassCastException in case the item is of the wrong type, use
 *            <tt>WabitObject.class</tt> for this parameter.
 * @return The item, or null if no item with the given UUID exists in this
 *         workspace.
 */
public <T extends SPObject> T findByUuid(String uuid, Class<T> expectedType) {
    return SQLPowerUtils.findByUuid(this, uuid, expectedType);
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:21,代码来源:WabitWorkspace.java

示例11: exists

import ca.sqlpower.util.SQLPowerUtils; //导入方法依赖的package包/类
/**
 * Checks to see if a {@link WabitObject} with a certain UUID exists
 * 
 * @param uuid
 *            The UUID to search for
 * @return Whether or not the {@link WabitObject} exists
 */
private boolean exists(String uuid) {
	return (!objectsToRemove.containsKey(uuid) && (persistedObjects
			.containsKey(uuid) || SQLPowerUtils.findByUuid(root, uuid,
			SPObject.class) != null));
}
 
开发者ID:SQLPower,项目名称:wabit,代码行数:13,代码来源:WabitSessionPersister.java


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