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;
}
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);
}
}
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());
}
}
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;
}
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");
}
Aggregations