Search in sources :

Example 1 with ICloneable

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;
}
Also used : ICloneable(com.servoy.j2db.persistence.ICloneable) TableNode(com.servoy.j2db.persistence.TableNode)

Example 2 with ICloneable

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());
            }
        }
    }
}
Also used : ICloneable(com.servoy.j2db.persistence.ICloneable) ISupportChilds(com.servoy.j2db.persistence.ISupportChilds) IPersist(com.servoy.j2db.persistence.IPersist) Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) AbstractBase(com.servoy.j2db.persistence.AbstractBase) IPersistVisitor(com.servoy.j2db.persistence.IPersistVisitor) JSONObject(org.json.JSONObject) IRootObject(com.servoy.j2db.persistence.IRootObject) Solution(com.servoy.j2db.persistence.Solution)

Aggregations

ICloneable (com.servoy.j2db.persistence.ICloneable)2 AbstractBase (com.servoy.j2db.persistence.AbstractBase)1 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)1 Form (com.servoy.j2db.persistence.Form)1 IPersist (com.servoy.j2db.persistence.IPersist)1 IPersistVisitor (com.servoy.j2db.persistence.IPersistVisitor)1 IRootObject (com.servoy.j2db.persistence.IRootObject)1 ISupportChilds (com.servoy.j2db.persistence.ISupportChilds)1 Solution (com.servoy.j2db.persistence.Solution)1 TableNode (com.servoy.j2db.persistence.TableNode)1 JSONObject (org.json.JSONObject)1