use of com.servoy.j2db.persistence.ICloneable in project servoy-client by Servoy.
the class JSDataSourceNode method getScriptCopy.
@SuppressWarnings("unchecked")
public <T extends IScriptProvider> T getScriptCopy(T script) throws RepositoryException {
TableNode tableNode = application.getFlattenedSolution().getSolutionCopyTableNode(dataSource);
T sc = AbstractBase.selectByName(new TypeIterator<T>(tableNode.getAllObjects(), script.getTypeID()), script.getName());
if (sc == null) {
sc = (T) ((ICloneable) script).clonePersist(tableNode);
}
return sc;
}
use of com.servoy.j2db.persistence.ICloneable in project servoy-client by Servoy.
the class FlattenedSolution method updatePersistInSolutionCopy.
public void updatePersistInSolutionCopy(final IPersist persist) {
if (mainSolution == null && loginFlattenedSolution != null) {
loginFlattenedSolution.updatePersistInSolutionCopy(persist);
return;
}
if (copySolution == null)
return;
IPersist copyPersist = (IPersist) copySolution.acceptVisitor(new IPersistVisitor() {
public Object visit(IPersist o) {
if (o.getUUID().equals(persist.getUUID())) {
return o;
}
return IPersistVisitor.CONTINUE_TRAVERSAL;
}
});
if (copyPersist != null) {
((AbstractBase) copyPersist).copyPropertiesMap(((AbstractBase) persist).getPropertiesMap(), false);
ISupportChilds parent = copyPersist.getParent();
flush(persist);
if (parent instanceof Form) {
((Form) parent).setLastModified(System.currentTimeMillis());
} else if (copyPersist instanceof Form) {
((Form) copyPersist).setLastModified(System.currentTimeMillis());
}
} else if (persist.getParent() != null && !(persist.getParent() instanceof Solution)) {
ISupportChilds copyParent = (ISupportChilds) copySolution.acceptVisitor(new IPersistVisitor() {
public Object visit(IPersist o) {
if (o.getUUID().equals(persist.getParent().getUUID())) {
return o;
}
return IPersistVisitor.CONTINUE_TRAVERSAL;
}
});
if (copyParent != null) {
if (persist instanceof ICloneable) {
((ICloneable) persist).clonePersist((AbstractBase) copyParent);
} else {
copyParent.addChild(persist);
}
flush(persist);
if (copyParent instanceof Form) {
((Form) copyParent).setLastModified(System.currentTimeMillis());
}
}
}
}
Aggregations