Search in sources :

Example 6 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.

the class DatabaseWindowManager method accessPermissions.

/**
 * Insert the method's description here.
 * Creation date: (5/14/2004 5:35:55 PM)
 */
public void accessPermissions(final Component requester, final VersionInfo selectedVersionInfo, boolean bGrantSupportPermissions) {
    final GroupAccess groupAccess = selectedVersionInfo.getVersion().getGroupAccess();
    final DocumentManager docManager = getRequestManager().getDocumentManager();
    AsynchClientTask task1 = new AsynchClientTask("show dialog", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            getAclEditor().clearACLList();
            getAclEditor().setACLState(new ACLEditor.ACLState(groupAccess));
            if (bGrantSupportPermissions) {
                getAclEditor().grantVCellSupportPermissions();
            }
            Object choice = showAccessPermissionDialog(getAclEditor(), requester);
            if (choice != null) {
                hashTable.put("choice", choice);
            }
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("access permission", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            Object choice = hashTable.get("choice");
            if (choice != null && choice.equals("OK")) {
                ACLEditor.ACLState aclState = getAclEditor().getACLState();
                if (aclState != null) {
                    if (aclState.isAccessPrivate() || (aclState.getAccessList() != null && aclState.getAccessList().length == 0)) {
                        VersionInfo vInfo = null;
                        if (selectedVersionInfo instanceof BioModelInfo) {
                            vInfo = docManager.setGroupPrivate((BioModelInfo) selectedVersionInfo);
                        } else if (selectedVersionInfo instanceof MathModelInfo) {
                            vInfo = docManager.setGroupPrivate((MathModelInfo) selectedVersionInfo);
                        } else if (selectedVersionInfo instanceof GeometryInfo) {
                            vInfo = docManager.setGroupPrivate((GeometryInfo) selectedVersionInfo);
                        } else if (selectedVersionInfo instanceof VCImageInfo) {
                            vInfo = docManager.setGroupPrivate((VCImageInfo) selectedVersionInfo);
                        }
                    } else if (aclState.isAccessPublic()) {
                        VersionInfo vInfo = null;
                        if (selectedVersionInfo instanceof BioModelInfo) {
                            vInfo = docManager.setGroupPublic((BioModelInfo) selectedVersionInfo);
                        } else if (selectedVersionInfo instanceof MathModelInfo) {
                            vInfo = docManager.setGroupPublic((MathModelInfo) selectedVersionInfo);
                        } else if (selectedVersionInfo instanceof GeometryInfo) {
                            vInfo = docManager.setGroupPublic((GeometryInfo) selectedVersionInfo);
                        } else if (selectedVersionInfo instanceof VCImageInfo) {
                            vInfo = docManager.setGroupPublic((VCImageInfo) selectedVersionInfo);
                        }
                    } else {
                        String[] aclUserNames = aclState.getAccessList();
                        String[] originalGroupAccesNames = new String[0];
                        // Turn User[] into String[]
                        if (groupAccess instanceof GroupAccessSome) {
                            GroupAccessSome gas = (GroupAccessSome) groupAccess;
                            User[] originalUsers = gas.getNormalGroupMembers();
                            for (int i = 0; i < originalUsers.length; i += 1) {
                                originalGroupAccesNames = (String[]) BeanUtils.addElement(originalGroupAccesNames, originalUsers[i].getName());
                            }
                        }
                        // Determine users needing adding
                        String[] needToAddUsers = new String[0];
                        for (int i = 0; i < aclUserNames.length; i += 1) {
                            if (!BeanUtils.arrayContains(originalGroupAccesNames, aclUserNames[i])) {
                                System.out.println("Added user=" + aclUserNames[i]);
                                needToAddUsers = (String[]) BeanUtils.addElement(needToAddUsers, aclUserNames[i]);
                            }
                        }
                        // Determine users needing removing
                        String[] needToRemoveUsers = new String[0];
                        for (int i = 0; i < originalGroupAccesNames.length; i += 1) {
                            if (!BeanUtils.arrayContains(aclUserNames, originalGroupAccesNames[i])) {
                                System.out.println("Removed user=" + originalGroupAccesNames[i]);
                                needToRemoveUsers = (String[]) BeanUtils.addElement(needToRemoveUsers, originalGroupAccesNames[i]);
                            }
                        }
                        VersionInfo vInfo = null;
                        String errorNames = "";
                        // Add Users to Group Access List
                        for (int i = 0; i < needToAddUsers.length; i++) {
                            try {
                                if (selectedVersionInfo instanceof BioModelInfo) {
                                    vInfo = docManager.addUserToGroup((BioModelInfo) selectedVersionInfo, needToAddUsers[i]);
                                } else if (selectedVersionInfo instanceof MathModelInfo) {
                                    vInfo = docManager.addUserToGroup((MathModelInfo) selectedVersionInfo, needToAddUsers[i]);
                                } else if (selectedVersionInfo instanceof GeometryInfo) {
                                    vInfo = docManager.addUserToGroup((GeometryInfo) selectedVersionInfo, needToAddUsers[i]);
                                } else if (selectedVersionInfo instanceof VCImageInfo) {
                                    vInfo = docManager.addUserToGroup((VCImageInfo) selectedVersionInfo, needToAddUsers[i]);
                                }
                            } catch (ObjectNotFoundException e) {
                                errorNames += "Error changing permissions.\n" + selectedVersionInfo.getVersionType().getTypeName() + " \"" + selectedVersionInfo.getVersion().getName() + "\" edition (" + selectedVersionInfo.getVersion().getDate() + ")\nnot found, " + "your model list may be out of date, please go to menu Server->Reconnect to refresh the model list" + "\n";
                                break;
                            } catch (DataAccessException e) {
                                errorNames += "Error adding user '" + needToAddUsers[i] + "' : " + e.getMessage() + "\n";
                            }
                        }
                        // Remove users from Group Access List
                        for (int i = 0; i < needToRemoveUsers.length; i++) {
                            try {
                                if (selectedVersionInfo instanceof BioModelInfo) {
                                    vInfo = docManager.removeUserFromGroup((BioModelInfo) selectedVersionInfo, needToRemoveUsers[i]);
                                } else if (selectedVersionInfo instanceof MathModelInfo) {
                                    vInfo = docManager.removeUserFromGroup((MathModelInfo) selectedVersionInfo, needToRemoveUsers[i]);
                                } else if (selectedVersionInfo instanceof GeometryInfo) {
                                    vInfo = docManager.removeUserFromGroup((GeometryInfo) selectedVersionInfo, needToRemoveUsers[i]);
                                } else if (selectedVersionInfo instanceof VCImageInfo) {
                                    vInfo = docManager.removeUserFromGroup((VCImageInfo) selectedVersionInfo, needToRemoveUsers[i]);
                                }
                            } catch (DataAccessException e) {
                                errorNames += "Error Removing user '" + needToRemoveUsers[i] + "'\n  -----" + e.getMessage() + "\n";
                            }
                        }
                        if (errorNames.length() > 0) {
                            if (DatabaseWindowManager.this.getComponent() != null) {
                                PopupGenerator.showErrorDialog(DatabaseWindowManager.this, errorNames);
                            } else {
                                DialogUtils.showErrorDialog(requester, errorNames);
                            }
                            accessPermissions(requester, selectedVersionInfo, false);
                        }
                    }
                }
            }
        }
    };
    ClientTaskDispatcher.dispatch(requester, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) DocumentManager(cbit.vcell.clientdb.DocumentManager) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) ACLEditor(cbit.vcell.client.desktop.ACLEditor) VersionInfo(org.vcell.util.document.VersionInfo) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) GeometryInfo(cbit.vcell.geometry.GeometryInfo) GroupAccessSome(org.vcell.util.document.GroupAccessSome) GroupAccess(org.vcell.util.document.GroupAccess) VCImageInfo(cbit.image.VCImageInfo) DataAccessException(org.vcell.util.DataAccessException)

Example 7 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.

the class DatabaseWindowManager method compareAnotherModel.

/**
 * Comment
 */
public void compareAnotherModel() {
    // 
    if (getPanelSelection() == null) {
        PopupGenerator.showErrorDialog(this, "Error Comparing documents : First document not selected");
        return;
    }
    VCDocumentInfo thisDocumentInfo = getPanelSelection();
    // Choose the other documentInfo. Bring up the appropriate dbTreePanel depending on the type of thisDocumentInfo
    VCDocumentInfo otherDocumentInfo = null;
    try {
        otherDocumentInfo = selectDocument(thisDocumentInfo.getVCDocumentType(), this);
    } catch (Exception e) {
        if (!(e instanceof UserCancelException)) {
            e.printStackTrace();
            DialogUtils.showErrorDialog(this.getComponent(), "Error Comparing documents: " + e.getMessage());
        }
        return;
    }
    if (otherDocumentInfo == null) {
        // PopupGenerator.showErrorDialog(this, "Error Comparing documents : Second document is null ");
        return;
    }
    // Check if both document types are of the same kind. If not, throw an error.
    if (((thisDocumentInfo instanceof BioModelInfo) && !(otherDocumentInfo instanceof BioModelInfo)) || ((thisDocumentInfo instanceof MathModelInfo) && !(otherDocumentInfo instanceof MathModelInfo)) || ((thisDocumentInfo instanceof GeometryInfo) && !(otherDocumentInfo instanceof GeometryInfo))) {
        PopupGenerator.showErrorDialog(this, "Error Comparing documents : The two documents are not of the same type!");
        return;
    }
    // Now that we have both the document versions to be compared, do the comparison and display the result
    compareWithOther(otherDocumentInfo, thisDocumentInfo);
}
Also used : VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) UserCancelException(org.vcell.util.UserCancelException) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) GeometryException(cbit.vcell.geometry.GeometryException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) GifParsingException(cbit.image.GifParsingException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) UserCancelException(org.vcell.util.UserCancelException)

Example 8 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.

the class ClientRequestManager method accessPermissionsEx.

public void accessPermissionsEx(Component requester, VCDocument vcDoc, boolean bGrantSupportPermissions) {
    VersionInfo selectedVersionInfo = null;
    switch(vcDoc.getDocumentType()) {
        case BIOMODEL_DOC:
            BioModelInfo[] bioModelInfos = getDocumentManager().getBioModelInfos();
            for (BioModelInfo bioModelInfo : bioModelInfos) {
                if (bioModelInfo.getVersion().getVersionKey().equals(vcDoc.getVersion().getVersionKey())) {
                    selectedVersionInfo = bioModelInfo;
                    break;
                }
            }
            break;
        case MATHMODEL_DOC:
            MathModelInfo[] mathModelInfos = getDocumentManager().getMathModelInfos();
            for (MathModelInfo mathModelInfo : mathModelInfos) {
                if (mathModelInfo.getVersion().getVersionKey().equals(vcDoc.getVersion().getVersionKey())) {
                    selectedVersionInfo = mathModelInfo;
                    break;
                }
            }
            break;
        case GEOMETRY_DOC:
            GeometryInfo[] geoInfos = getDocumentManager().getGeometryInfos();
            for (GeometryInfo geoInfo : geoInfos) {
                if (geoInfo.getVersion().getVersionKey().equals(vcDoc.getVersion().getVersionKey())) {
                    selectedVersionInfo = geoInfo;
                    break;
                }
            }
            break;
    }
    getMdiManager().getDatabaseWindowManager().accessPermissions(requester, selectedVersionInfo, true);
}
Also used : VersionInfo(org.vcell.util.document.VersionInfo) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) MathModelInfo(org.vcell.util.document.MathModelInfo)

Example 9 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.

the class DocumentWindowManager method openGeometryDocumentWindow.

/**
 * Insert the method's description here.
 * Creation date: (1/21/2006 10:45:13 AM)
 */
public void openGeometryDocumentWindow(final Geometry geom) {
    AsynchClientTask task1 = new AsynchClientTask("opening geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            try {
                GeometryInfo geomInfo = getRequestManager().getDocumentManager().getGeometryInfo(geom.getVersion().getVersionKey());
                hashTable.put("geomInfo", geomInfo);
            } catch (ObjectNotFoundException e) {
                if (getVCDocument().getVersion() != null && !getVCDocument().getVersion().getOwner().equals(getRequestManager().getDocumentManager().getUser())) {
                    throw new RuntimeException("Opening a geometry document window for '" + geom.getName() + "' from\n" + "Model '" + getVCDocument().getName() + "' owned by user (" + getVCDocument().getVersion().getOwner().getName() + ")\n" + "FAILED because user (" + getRequestManager().getDocumentManager().getUser().getName() + ") does not have permission.\n" + "Save Model '" + getVCDocument().getName() + "' to your account to have full access to the geometry.");
                } else {
                    throw e;
                }
            }
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("opening geometry", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            GeometryInfo geomInfo = (GeometryInfo) hashTable.get("geomInfo");
            getRequestManager().openDocument(geomInfo, DocumentWindowManager.this, true);
        }
    };
    ClientTaskDispatcher.dispatch(this.getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) GeometryInfo(cbit.vcell.geometry.GeometryInfo)

Example 10 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.

the class RuleBasedTest method main.

public static void main(String[] args) {
    try {
        PropertyLoader.loadProperties();
    } catch (Exception e) {
        e.printStackTrace();
    }
    final int numTrials = 40;
    VCDatabaseVisitor vcDatabaseVisitor = new VCDatabaseVisitor() {

        @Override
        public void visitMathModel(MathModel mathModel, PrintStream logFilePrintStream) {
            throw new IllegalArgumentException("Not Implemented");
        }

        @Override
        public void visitGeometry(Geometry geometry, PrintStream logFilePrintStream) {
            throw new IllegalArgumentException("Not Implemented");
        }

        @Override
        public void visitBioModel(BioModel bioModel, PrintStream logFilePrintStream) {
            SimulationContext[] simulationContexts = bioModel.getSimulationContexts();
            for (SimulationContext simContext : simulationContexts) {
                if ((simContext.getApplicationType() == Application.NETWORK_STOCHASTIC) && simContext.getGeometry().getDimension() == 0) {
                    File baseDirectory = createDirFile(simContext);
                    try {
                        checkNonspatialStochasticSimContext(simContext, baseDirectory, numTrials);
                    } catch (Exception e) {
                        e.printStackTrace();
                        if (!e.getMessage().contains("Only Mass Action Kinetics supported ")) {
                            writeMessageTofile(baseDirectory, e.getMessage());
                        }
                    }
                }
            }
        }

        @Override
        public boolean filterMathModel(MathModelInfo mathModelInfo) {
            return false;
        }

        @Override
        public boolean filterGeometry(GeometryInfo geometryInfo) {
            return false;
        }

        @Override
        public boolean filterBioModel(BioModelInfo bioModelInfo) {
            return // bioModelInfo.getVersion().getName().equals("model");
            bioModelInfo.getVersion().getName().equals("simpleModel_Network_orig");
        }
    };
    String currentUserID = "schaff";
    String[] allUsers = new String[] { /*-all*/
    currentUserID, "-" };
    VCDatabaseScanner.scanBioModels(allUsers, vcDatabaseVisitor, false);
}
Also used : PrintStream(java.io.PrintStream) MathModel(cbit.vcell.mathmodel.MathModel) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) SimulationContext(cbit.vcell.mapping.SimulationContext) Geometry(cbit.vcell.geometry.Geometry) BioModel(cbit.vcell.biomodel.BioModel) GeometryInfo(cbit.vcell.geometry.GeometryInfo) VCDatabaseVisitor(cbit.vcell.modeldb.VCDatabaseVisitor) File(java.io.File)

Aggregations

GeometryInfo (cbit.vcell.geometry.GeometryInfo)47 BioModelInfo (org.vcell.util.document.BioModelInfo)27 MathModelInfo (org.vcell.util.document.MathModelInfo)27 DataAccessException (org.vcell.util.DataAccessException)19 VCDocumentInfo (org.vcell.util.document.VCDocumentInfo)11 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)8 Hashtable (java.util.Hashtable)8 Geometry (cbit.vcell.geometry.Geometry)7 VCImageInfo (cbit.image.VCImageInfo)6 BioModel (cbit.vcell.biomodel.BioModel)6 User (org.vcell.util.document.User)6 VersionInfo (org.vcell.util.document.VersionInfo)6 CSGObject (cbit.vcell.geometry.CSGObject)5 SimulationContext (cbit.vcell.mapping.SimulationContext)5 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)5 Vector (java.util.Vector)5 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)5 ImageException (cbit.image.ImageException)4 DocumentManager (cbit.vcell.clientdb.DocumentManager)4 GeometryException (cbit.vcell.geometry.GeometryException)4