Search in sources :

Example 26 with Solution

use of com.servoy.j2db.persistence.Solution in project servoy-client by Servoy.

the class RemoteActiveSolutionHandler method loadLoginSolutionAndModules.

@Override
public Solution[] loadLoginSolutionAndModules(final SolutionMetaData mainSolutionDef) throws RepositoryException, RemoteException {
    final SolutionMetaData[] loginSolutionDefinitions = getApplicationServer().getLoginSolutionDefinitions(mainSolutionDef);
    if (loginSolutionDefinitions == null) {
        throw new RepositoryException("Could not load login solution");
    }
    final Solution[] solutions = new Solution[loginSolutionDefinitions.length];
    if (loginSolutionDefinitions.length > 0) {
        ThrowingRunnable<RepositoryException, RemoteException> r = new ThrowingRunnable<RepositoryException, RemoteException>() {

            @Override
            public void run() {
                try {
                    int[] sol_ids = new int[loginSolutionDefinitions.length];
                    for (int i = 0; i < sol_ids.length; i++) {
                        sol_ids[i] = loginSolutionDefinitions[i].getRootObjectId();
                    }
                    long[] asus = getApplicationServer().getActiveRootObjectsLastModified(sol_ids);
                    ConcurrentMap<String, IServer> sps = getRepository().getServerProxies(loginSolutionDefinitions);
                    for (int i = 0; i < loginSolutionDefinitions.length; i++) {
                        Solution s = loadCachedSolution(loginSolutionDefinitions[i], asus[i], sps);
                        if (s == null) {
                            // do full load
                            s = getApplicationServer().getLoginSolution(mainSolutionDef, loginSolutionDefinitions[i]);
                        }
                        if (s != null) {
                            if (s.getRepository() == null) {
                                // transient
                                s.setRepository(getRepository());
                            }
                            loadedActiveSolutionUpdateSequences.put(new Integer(s.getSolutionID()), new Long(asus[i]));
                            s.setServerProxies(sps);
                        }
                        solutions[i] = s;
                    }
                } catch (RepositoryException eo) {
                    e1 = eo;
                } catch (RemoteException et) {
                    e2 = et;
                }
            }
        };
        UIUtils.runWhileDispatchingEvents(r, getServiceProvider());
    }
    return solutions;
}
Also used : IServer(com.servoy.j2db.persistence.IServer) RepositoryException(com.servoy.j2db.persistence.RepositoryException) SolutionMetaData(com.servoy.j2db.persistence.SolutionMetaData) ThrowingRunnable(com.servoy.j2db.util.UIUtils.ThrowingRunnable) RemoteException(java.rmi.RemoteException) Solution(com.servoy.j2db.persistence.Solution)

Example 27 with Solution

use of com.servoy.j2db.persistence.Solution in project servoy-client by Servoy.

the class PersistHelper method buildOrderedModulesList.

private static void buildOrderedModulesList(Solution parent, List<Solution> orderedModules, List<Solution> fsModules) {
    List<Solution> newParents = new ArrayList<Solution>();
    for (String moduleName : Utils.getTokenElements(parent.getModulesNames(), ",", true)) {
        Iterator<Solution> it = fsModules.iterator();
        while (it.hasNext()) {
            Solution module = it.next();
            if (module.getName().equals(moduleName)) {
                if (!orderedModules.contains(module))
                    orderedModules.add(module);
                it.remove();
                newParents.add(module);
                break;
            }
        }
    }
    for (Solution newParent : newParents) {
        buildOrderedModulesList(newParent, orderedModules, fsModules);
    }
}
Also used : ArrayList(java.util.ArrayList) FlattenedSolution(com.servoy.j2db.FlattenedSolution) Solution(com.servoy.j2db.persistence.Solution)

Example 28 with Solution

use of com.servoy.j2db.persistence.Solution in project servoy-client by Servoy.

the class CmdManager method propertyChange.

public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();
    if (// $NON-NLS-1$
    "repository".equals(name)) {
        final IRepository repository = (IRepository) evt.getNewValue();
        // $NON-NLS-1$
        Action cmdnewsolution = actions.get("cmdnewsolution");
        if (cmdnewsolution != null)
            cmdnewsolution.setEnabled(repository != null);
        if (autoOpenSolutionSelectDialog) {
            // $NON-NLS-1$
            final Action cmdopensolution = actions.get("cmdopensolution");
            if (cmdopensolution != null) {
                application.invokeLater(new Runnable() {

                    public void run() {
                        cmdopensolution.setEnabled(repository != null);
                        if (repository != null) {
                            try {
                                if (repository.getRootObjectMetaDatasForType(IRepository.SOLUTIONS).length != 0 && application.getSolution() == null && (application.getFlattenedSolution() == null || !application.getFlattenedSolution().isLoadingSolution())) {
                                    executeCmd((ICmd) cmdopensolution, null);
                                }
                            } catch (Exception ex) {
                                Debug.error(ex);
                            }
                        }
                    }
                });
            }
        }
    } else if (// $NON-NLS-1$
    "solution".equals(name)) {
        Solution solution = (Solution) evt.getNewValue();
        ableFormRelatedBrowseActions(solution != null);
        ableFormRelatedDataEditActions(solution != null);
        undoAction.setEnabled(solution != null);
        redoAction.setEnabled(solution != null);
        // $NON-NLS-1$
        Action cmdclose = actions.get("cmdclose");
        if (cmdclose != null)
            cmdclose.setEnabled(solution != null);
        // $NON-NLS-1$
        Action cmdsolutionsettings = actions.get("cmdsolutionsettings");
        if (cmdsolutionsettings != null)
            cmdsolutionsettings.setEnabled(solution != null);
        // TODO:could be optimized by using fast method getFormCount
        if (solution != null && application.getFlattenedSolution().getForms(false).hasNext()) {
            ableFormRelatedActions(true);
        } else {
            ableFormRelatedActions(false);
        }
    } else if (// $NON-NLS-1$
    "mode".equals(name)) {
        int oldmode = ((Integer) evt.getOldValue()).intValue();
        // $NON-NLS-1$
        Action menuselectaction = actions.get("menuselectaction");
        int mode = ((Integer) evt.getNewValue()).intValue();
        switch(mode) {
            case IModeManager.FIND_MODE:
                break;
            case IModeManager.PREVIEW_MODE:
                break;
            case IModeManager.EDIT_MODE:
            default:
                if (menuselectaction != null)
                    menuselectaction.setEnabled(true);
        }
        ableFormRelatedFindActions(mode == IModeManager.FIND_MODE);
        // $NON-NLS-1$
        Action cmdfindmode = actions.get("cmdfindmode");
        if (cmdfindmode != null)
            cmdfindmode.setEnabled(mode == IModeManager.EDIT_MODE);
        if (mode == IModeManager.FIND_MODE) {
            ableFormRelatedBrowseActions(false);
            ableFormRelatedDataEditActions(true);
        } else {
            ableFormRelatedBrowseActions(mode == IModeManager.EDIT_MODE);
        }
    } else if (// $NON-NLS-1$
    "formCreated".equals(name)) {
        ableFormRelatedActions(evt.getNewValue() != null);
    } else if (// $NON-NLS-1$
    "undomanager".equals(name)) {
        String sUndoRedo = (String) evt.getOldValue();
        Boolean bValue = (Boolean) evt.getNewValue();
        Action menuUndoRedo = actions.get(sUndoRedo);
        if (menuUndoRedo != null)
            menuUndoRedo.setEnabled(bValue.booleanValue());
    }
}
Also used : Action(javax.swing.Action) ICmd(com.servoy.j2db.cmd.ICmd) IRepository(com.servoy.j2db.persistence.IRepository) Solution(com.servoy.j2db.persistence.Solution)

Example 29 with Solution

use of com.servoy.j2db.persistence.Solution in project servoy-client by Servoy.

the class JSApplication method js_getVersionInfo.

/**
 * Get the full version information of this solution and all its modules.
 * This will return an object that is a map of Name(Sting)->Version(String) of the solution and all its modules.
 *
 * @return Name->Version map object.
 */
public JSMap<String, String> js_getVersionInfo() {
    JSMap<String, String> info = new JSMap<>();
    Solution solution = application.getSolution();
    info.put(solution.getName(), solution.getVersion());
    Solution[] modules = application.getFlattenedSolution().getModules();
    if (modules != null) {
        for (Solution m : modules) {
            info.put(m.getName(), m.getVersion());
        }
    }
    return info;
}
Also used : Solution(com.servoy.j2db.persistence.Solution)

Example 30 with Solution

use of com.servoy.j2db.persistence.Solution in project servoy-client by Servoy.

the class JSForm method getMethodId.

public static int getMethodId(IApplication application, AbstractBase base, ScriptMethod method) {
    ISupportChilds parent = method.getParent();
    Form f = getFormParent(base);
    // quick check if it is solution or own form..
    if (parent instanceof Solution || parent.getUUID().equals(f.getUUID())) {
        return method.getID();
    }
    // it could be a extends form
    while (f != null && f.getExtendsID() > 0) {
        f = application.getFlattenedSolution().getForm(f.getExtendsID());
        if (f != null && parent.getUUID().equals(f.getUUID())) {
            return method.getID();
        }
    }
    // or a foundset method
    Iterator<ScriptMethod> foundsetMethods = application.getFlattenedSolution().getFoundsetMethods(f.getDataSource(), false);
    while (foundsetMethods.hasNext()) {
        if (foundsetMethods.next().getID() == method.getID()) {
            return method.getID();
        }
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    throw new RuntimeException("Method " + method.getName() + " must be a solution method, foundset method or a forms own method");
}
Also used : ISupportChilds(com.servoy.j2db.persistence.ISupportChilds) Form(com.servoy.j2db.persistence.Form) ISMForm(com.servoy.j2db.solutionmodel.ISMForm) IMobileSMForm(com.servoy.base.solutionmodel.mobile.IMobileSMForm) ScriptMethod(com.servoy.j2db.persistence.ScriptMethod) FlattenedSolution(com.servoy.j2db.FlattenedSolution) Solution(com.servoy.j2db.persistence.Solution)

Aggregations

Solution (com.servoy.j2db.persistence.Solution)59 FlattenedSolution (com.servoy.j2db.FlattenedSolution)17 Form (com.servoy.j2db.persistence.Form)16 ScriptMethod (com.servoy.j2db.persistence.ScriptMethod)14 RepositoryException (com.servoy.j2db.persistence.RepositoryException)12 ArrayList (java.util.ArrayList)9 RemoteException (java.rmi.RemoteException)8 HashMap (java.util.HashMap)8 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)7 IPersist (com.servoy.j2db.persistence.IPersist)6 TableNode (com.servoy.j2db.persistence.TableNode)6 ServoyException (com.servoy.j2db.util.ServoyException)6 JSONObject (org.json.JSONObject)6 IFormController (com.servoy.j2db.IFormController)5 Map (java.util.Map)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 JavaScriptException (org.mozilla.javascript.JavaScriptException)5 IRepository (com.servoy.j2db.persistence.IRepository)4 List (java.util.List)4 ApplicationException (com.servoy.j2db.ApplicationException)3