本文整理汇总了Java中ca.sqlpower.util.SQLPowerUtils类的典型用法代码示例。如果您正苦于以下问题:Java SQLPowerUtils类的具体用法?Java SQLPowerUtils怎么用?Java SQLPowerUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SQLPowerUtils类属于ca.sqlpower.util包,在下文中一共展示了SQLPowerUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setParentHelper
import ca.sqlpower.util.SQLPowerUtils; //导入依赖的package包/类
/**
* See the comment on {@link #setParent(SQLTable)} for why this method
* exists if it seems goofy.
*/
private void setParentHelper(SPObject parent) {
SPObject oldVal = getParent();
super.setParent(parent);
if (parent != null) {
if (isMagicEnabled() && parent != oldVal) {
try {
attachRelationship(true);
} catch (SQLObjectException e) {
throw new RuntimeException(e);
}
} else {
//Column manager is removed first in case it has already been
//added before. One case is when the relationship is being re-added
//to the same table it was removed from by the undo system.
SQLPowerUtils.unlistenToHierarchy(getParent(), fkColumnUpdater);
SQLPowerUtils.listenToHierarchy(getParent(), fkColumnUpdater);
}
}
}
示例2: childAdded
import ca.sqlpower.util.SQLPowerUtils; //导入依赖的package包/类
public void childAdded(SPChildEvent e) {
if (!e.getSource().getRunnableDispatcher().isForegroundThread()) {
throw new RuntimeException("New child event " + e + " not fired on the foreground.");
}
int index = e.getIndex();
// Get all the sibling under the same parent
PersistedSPObject minValue = new PersistedSPObject(
e.getSource().getUUID(), e.getChildType().getName(), e.getChild().getUUID(), index);
Set<PersistedSPObject> toBeUpdated = new HashSet<PersistedSPObject>(parentPeristedObjects.get(getParentPersistedObjectsId(minValue)).tailSet(minValue));
for (PersistedSPObject psp : toBeUpdated) {
// Update the sibling's index
PersistedSPObject newIndexedSibling = new PersistedSPObject(psp.getParentUUID(), psp.getType(), psp.getUUID(), psp.getIndex()+1);
parentPeristedObjects.remove(getParentPersistedObjectsId(psp), psp);
parentPeristedObjects.put(getParentPersistedObjectsId(newIndexedSibling), newIndexedSibling);
psp.setIndex(psp.getIndex() + 1);
}
SQLPowerUtils.listenToHierarchy(e.getChild(), this);
if (wouldEcho()) return;
if (logger.isDebugEnabled()) {
logger.debug("Child added: " + e);
}
persistObject(e.getChild(), index);
removedObjectsUUIDs.removeAll(getDescendantUUIDs(e.getChild()));
}
示例3: exists
import ca.sqlpower.util.SQLPowerUtils; //导入依赖的package包/类
/**
* Checks to see if a {@link SPObject} with a certain UUID exists
*
* @param uuid
* The UUID to search for
* @return Whether or not the {@link SPObject} exists
*/
private boolean exists(String uuid) {
if (persistedObjectsMap.get(uuid) != null) return true;
SPObject spo = findByUuid(root, uuid, SPObject.class);
if (spo != null) {
List<SPObject> ancestors = SQLPowerUtils.getAncestorList(spo);
ancestors.add(spo);
for (SPObject ancestor : ancestors) {
if (objectsToRemove.containsKey(ancestor.getUUID())) {
return false;
}
}
return true;
}
return false;
}
示例4: persistObject
import ca.sqlpower.util.SQLPowerUtils; //导入依赖的package包/类
@Override
public void persistObject(String parentUUID, String type, String uuid,
int index) throws SPPersistenceException {
if (uuid == null) uuid = "";
if (parentUUID == null) parentUUID = "";
while (!currentObject.isEmpty() && !parentUUID.equals(currentObject.peek())) {
currentObject.pop();
out.println(tab() + "</" + currentType.pop().replace("$", "..") + ">");
}
if (currentObject.isEmpty()) {
if (!type.equals(rootObject)) {
throw new SPPersistenceException(null,
"This persister does not support incremental updates."
+ " The first object persisted must be the root.");
}
} else if (!parentUUID.equals(currentObject.peek())) {
throw new SPPersistenceException(null,
"This persister requires persists to be ordered. An object at ["
+ uuid + "] as a child of [" + parentUUID
+ "] was persisted while the current object was ["
+ currentObject.peek() + "]");
}
out.println(tab() + "<" + type.replace("$", "..") + " UUID=\"" + SQLPowerUtils.escapeXML(uuid) + "\" index=\"" + index + "\">");
currentObject.push(uuid);
currentType.push(type);
}
示例5: equals
import ca.sqlpower.util.SQLPowerUtils; //导入依赖的package包/类
@Override
public boolean equals(Object other) {
// identical object reference
if (this == other) {
return true;
}
// correct type
if (!(other instanceof DBConnectionSpec)) {
return false;
}
DBConnectionSpec otherDbcs = (DBConnectionSpec) other;
// protect from null pointer exceptions by wrapping equality calls
if (getSeqNo() == otherDbcs.getSeqNo() &&
SQLPowerUtils.areEqual(getDriverClass(),otherDbcs.getDriverClass()) &&
SQLPowerUtils.areEqual(getUrl(),otherDbcs.getUrl()) &&
SQLPowerUtils.areEqual(getUser(),otherDbcs.getUser()) &&
SQLPowerUtils.areEqual(getPass(),otherDbcs.getPass())) {
return true;
} else {
return false;
}
}
示例6: undo
import ca.sqlpower.util.SQLPowerUtils; //导入依赖的package包/类
@Override
public void undo() throws CannotUndoException {
List<SPObject> ancestorList = SQLPowerUtils.getAncestorList(spObjectRoot);
SPObject absoluteRoot;
if (ancestorList.isEmpty()) {
absoluteRoot = spObjectRoot;
} else {
absoluteRoot = ancestorList.get(0);
}
try {
absoluteRoot.begin("Undoing compound edit " + getUndoPresentationName());
super.undo();
absoluteRoot.commit();
} catch (RuntimeException e) {
absoluteRoot.rollback(e.getMessage());
throw e;
}
}
示例7: redo
import ca.sqlpower.util.SQLPowerUtils; //导入依赖的package包/类
@Override
public void redo() throws CannotRedoException {
List<SPObject> ancestorList = SQLPowerUtils.getAncestorList(spObjectRoot);
SPObject absoluteRoot;
if (ancestorList.isEmpty()) {
absoluteRoot = spObjectRoot;
} else {
absoluteRoot = ancestorList.get(0);
}
try {
absoluteRoot.begin("Redoing compound edit " + getRedoPresentationName());
super.redo();
absoluteRoot.commit();
} catch (RuntimeException e) {
absoluteRoot.rollback(e.getMessage());
throw e;
}
}
示例8: childAdded
import ca.sqlpower.util.SQLPowerUtils; //导入依赖的package包/类
@Override
public void childAdded(SPChildEvent e) {// selects the new child on the tree if one new child is added
if (selectNewChild) {
final MatchMakerObject insertedMMO = (MatchMakerObject)e.getChild();
if (!(insertedMMO instanceof SQLInputStep
|| insertedMMO instanceof MungeResultStep
|| insertedMMO instanceof MungeStepOutput) && insertedMMO.isMagicEnabled()) {
SwingUtilities.invokeLater(new Runnable(){
public void run() {
MatchMakerTreeModel treeModel = (MatchMakerTreeModel)getTree().getModel();
TreePath treePath = treeModel.getPathForNode(insertedMMO);
getTree().setSelectionPath(treePath);
}
});
}
}
SQLPowerUtils.listenToHierarchy(e.getChild(), this);
}
示例9: childRemoved
import ca.sqlpower.util.SQLPowerUtils; //导入依赖的package包/类
@Override
public void childRemoved(SPChildEvent e) {
hasChanged = true;
SQLPowerUtils.unlistenToHierarchy(e.getChild(), this);
logger.debug("Child: " + e.getChild() + " is removed from: " + e.getSource().toString());
if (e.getSource().isMagicEnabled()) {
UndoableEdit ue = new MMOChildrenRemoveUndoableEdit(e);
addEdit(ue);
}
if (!undo.canUndo()) {
hasChanged = false;
}
swingSession.refreshUndoAction();
}
示例10: 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);
}
}
}
示例11: 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);
}
}
}
示例12: 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);
}
}
}
示例13: 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;
}
示例14: testChangePropNullToNonNull
import ca.sqlpower.util.SQLPowerUtils; //导入依赖的package包/类
public void testChangePropNullToNonNull() throws Exception {
WabitWorkspace workspace = session.getWorkspace();
workspace.setUUID(WabitWorkspace.SYSTEM_WORKSPACE_UUID);
User user = new User("name", "pass");
workspace.addUser(user);
user.setEmail(null);
assertNotNull(SQLPowerUtils.findByUuid(workspace, user.getUUID(), SPObject.class));
wsp.begin();
wsp.persistProperty(
user.getUUID(), "email", DataType.STRING, null, "[email protected]");
wsp.commit();
assertEquals("[email protected]", user.getEmail());
}
示例15: testChangePropNonNullToNull
import ca.sqlpower.util.SQLPowerUtils; //导入依赖的package包/类
public void testChangePropNonNullToNull() throws Exception {
WabitWorkspace workspace = session.getWorkspace();
workspace.setUUID(WabitWorkspace.SYSTEM_WORKSPACE_UUID);
User user = new User("name", "pass");
workspace.addUser(user);
user.setEmail("[email protected]");
assertNotNull(SQLPowerUtils.findByUuid(workspace, user.getUUID(), SPObject.class));
wsp.begin();
wsp.persistProperty(
user.getUUID(), "email", DataType.STRING, "[email protected]", null);
wsp.commit();
assertNull(user.getEmail());
}