Search in sources :

Example 1 with GroupAccess

use of org.vcell.util.document.GroupAccess 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) {
    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));
            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);
                        }
                    }
                }
            }
        }
    };
    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 2 with GroupAccess

use of org.vcell.util.document.GroupAccess 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 3 with GroupAccess

use of org.vcell.util.document.GroupAccess in project vcell by virtualcell.

the class DbDriver method insertVersionableInit.

/**
 * This method was created in VisualAge.
 * @return cbit.sql.KeyValue
 * @param versionable cbit.sql.Versionable
 * @param pRef cbit.sql.KeyValue
 * @param bCommit boolean
 */
protected Version insertVersionableInit(InsertHashtable hash, Connection con, User user, Versionable versionable, String name, String annot, boolean bVersion) throws SQLException, DataAccessException {
    if (hash.getDatabaseKey(versionable) != null) {
        throw new DataAccessException(versionable + " already inserted in this transaction");
    }
    VersionableType vType = VersionTable.versionableTypeFromVersionable(versionable);
    if (vType.getIsTopLevel() && isNameUsed(con, vType, user, name)) {
        throw new DataAccessException("'" + user.getName() + "' already has a " + vType.getTypeName() + " with name '" + name + "'");
    }
    User owner = user;
    // AccessInfo accessInfo = new AccessInfo(AccessInfo.PRIVATE_CODE);
    GroupAccess accessInfo = new GroupAccessNone();
    KeyValue versionKey = keyFactory.getNewKey(con);
    java.util.Date date = getNewDate(con);
    // if(versionable.getVersion().getVersionKey() != null){
    // throw new DataAccessException("GeomDbDriver:insertVersionable, VersionKey must be null to insert");
    // }
    String versionName = name;
    // Check for Archive and Publish not needed in insert because versionflag is always forced to Current
    VersionFlag versionFlag = null;
    // if(bVersion){
    // versionFlag = VersionFlag.Archived;
    // }else{
    versionFlag = VersionFlag.Current;
    // }
    KeyValue PRefKey = null;
    java.math.BigDecimal branchID = getNewBranchID(con);
    // 
    // Insert Software Version
    // 
    insertSoftwareVersion(con, versionKey);
    // 
    return new Version(versionKey, versionName, owner, accessInfo, PRefKey, branchID, date, versionFlag, annot);
}
Also used : User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) VersionableType(org.vcell.util.document.VersionableType) GroupAccessNone(org.vcell.util.document.GroupAccessNone) BigDecimal(java.math.BigDecimal) VersionFlag(org.vcell.util.document.VersionFlag) Version(org.vcell.util.document.Version) VersionableTypeVersion(org.vcell.util.document.VersionableTypeVersion) GroupAccess(org.vcell.util.document.GroupAccess) DataAccessException(org.vcell.util.DataAccessException)

Example 4 with GroupAccess

use of org.vcell.util.document.GroupAccess in project vcell by virtualcell.

the class XmlReader method getVersion.

/**
 * This method returns a Version object from an XML representation.
 * Creation date: (3/16/2001 3:41:24 PM)
 * @return cbit.sql.Version
 * @param param org.jdom.Element
 */
private Version getVersion(Element xmlVersion) throws XmlParseException {
    if (xmlVersion == null) {
        return null;
    }
    // determine if it should be processed using the 'fromVersionable'
    if (xmlVersion.getAttributeValue(XMLTags.FromVersionableTag) == null || Boolean.valueOf(xmlVersion.getAttributeValue(XMLTags.FromVersionableTag)).booleanValue() || this.readKeysFlag == false) {
        // this came from a versionable object, so skip! Or it should not explicitly import the information inside the Version
        return null;
    }
    // Read all the attributes
    // *name
    String name = unMangle(xmlVersion.getAttributeValue(XMLTags.NameAttrTag));
    // *key
    String temp = xmlVersion.getAttributeValue(XMLTags.KeyValueAttrTag);
    KeyValue key = new KeyValue(temp);
    // *owner
    Element tempElement = xmlVersion.getChild(XMLTags.OwnerTag, vcNamespace);
    User owner = new User(unMangle(tempElement.getAttributeValue(XMLTags.NameAttrTag)), new KeyValue(tempElement.getAttributeValue(XMLTags.IdentifierAttrTag)));
    // *access
    GroupAccess groupAccess = getGroupAccess(xmlVersion.getChild(XMLTags.GroupAccessTag, vcNamespace));
    // *Branchpointref
    temp = xmlVersion.getAttributeValue(XMLTags.BranchPointRefTag);
    KeyValue branchpointref = null;
    if (temp != null) {
        branchpointref = new KeyValue(temp);
    }
    // *BranchID
    java.math.BigDecimal branchId = new java.math.BigDecimal(xmlVersion.getAttributeValue(XMLTags.BranchIdAttrTag));
    // *Flag
    temp = xmlVersion.getAttributeValue(XMLTags.FlagAttrTag);
    VersionFlag flag = VersionFlag.fromInt(Integer.parseInt(temp));
    // *Date
    java.util.Date date = null;
    temp = xmlVersion.getAttributeValue(XMLTags.DateAttrTag);
    if (temp != null) {
        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(BeanUtils.vcDateFormat, Locale.US);
            date = simpleDateFormat.parse(temp);
        } catch (java.text.ParseException e) {
            e.printStackTrace();
            throw new XmlParseException("Invalid date:" + temp, e);
        }
    }
    // *Annotation
    String annotation = null;
    String annotationText = xmlVersion.getChildText(XMLTags.AnnotationTag, vcNamespace);
    if (annotationText != null && annotationText.length() > 0) {
        annotation = unMangle(annotationText);
    }
    // Create and return the version object
    return new Version(key, name, owner, groupAccess, branchpointref, branchId, date, flag, annotation);
}
Also used : KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) Element(org.jdom.Element) VersionFlag(org.vcell.util.document.VersionFlag) Version(org.vcell.util.document.Version) RedistributionVersion(cbit.vcell.solvers.mb.MovingBoundarySolverOptions.RedistributionVersion) SimulationVersion(org.vcell.util.document.SimulationVersion) VCellSoftwareVersion(org.vcell.util.document.VCellSoftwareVersion) SpeciesContext(cbit.vcell.model.SpeciesContext) DataContext(cbit.vcell.data.DataContext) ReactionContext(cbit.vcell.mapping.ReactionContext) RDFXMLContext(org.vcell.pathway.persistence.RDFXMLContext) SimulationContext(cbit.vcell.mapping.SimulationContext) OutputFunctionContext(cbit.vcell.solver.OutputFunctionContext) ParameterContext(cbit.vcell.mapping.ParameterContext) GroupAccess(org.vcell.util.document.GroupAccess) SimpleDateFormat(java.text.SimpleDateFormat)

Example 5 with GroupAccess

use of org.vcell.util.document.GroupAccess in project vcell by virtualcell.

the class XmlReader method getSimulationVersion.

/**
 * This method returns a Version object from an XML representation.
 * Creation date: (3/16/2001 3:41:24 PM)
 * @return cbit.sql.Version
 * @param param org.jdom.Element
 */
private SimulationVersion getSimulationVersion(Element xmlVersion) throws XmlParseException {
    if (xmlVersion == null) {
        return null;
    }
    // determine if it should be processed using the 'fromVersionable'
    if (xmlVersion.getAttributeValue(XMLTags.FromVersionableTag) == null || Boolean.valueOf(xmlVersion.getAttributeValue(XMLTags.FromVersionableTag)).booleanValue() || this.readKeysFlag == false) {
        // this came from a versionable object, so skip! Or it should not explicitly import the information inside the Version
        return null;
    }
    // Read all the attributes
    // *name
    String name = unMangle(xmlVersion.getAttributeValue(XMLTags.NameAttrTag));
    // *key
    String temp = xmlVersion.getAttributeValue(XMLTags.KeyValueAttrTag);
    KeyValue key = new KeyValue(temp);
    // *owner
    Element tempElement = xmlVersion.getChild(XMLTags.OwnerTag, vcNamespace);
    User owner = new User(unMangle(tempElement.getAttributeValue(XMLTags.NameAttrTag)), new KeyValue(tempElement.getAttributeValue(XMLTags.IdentifierAttrTag)));
    // *access
    GroupAccess groupAccess = getGroupAccess(xmlVersion.getChild(XMLTags.GroupAccessTag, vcNamespace));
    // *Branchpointref
    temp = xmlVersion.getAttributeValue(XMLTags.BranchPointRefTag);
    KeyValue branchpointref = null;
    if (temp != null) {
        branchpointref = new KeyValue(temp);
    }
    // *BranchID
    java.math.BigDecimal branchId = new java.math.BigDecimal(xmlVersion.getAttributeValue(XMLTags.BranchIdAttrTag));
    // *Flag
    temp = xmlVersion.getAttributeValue(XMLTags.FlagAttrTag);
    VersionFlag flag = VersionFlag.fromInt(Integer.parseInt(temp));
    // *Date
    java.util.Date date = null;
    temp = xmlVersion.getAttributeValue(XMLTags.DateAttrTag);
    if (temp != null) {
        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(BeanUtils.vcDateFormat, Locale.US);
            date = simpleDateFormat.parse(temp);
        } catch (java.text.ParseException e) {
            e.printStackTrace();
            throw new XmlParseException("Invalid date:" + temp, e);
        }
    }
    // *DataSimulationRef
    KeyValue parentSimRefKey = null;
    tempElement = xmlVersion.getChild(XMLTags.ParentSimRefTag, vcNamespace);
    if (tempElement != null) {
        parentSimRefKey = new KeyValue(tempElement.getAttributeValue(XMLTags.KeyValueAttrTag));
    }
    // *Annotation
    String annotation = null;
    String annotationText = xmlVersion.getChildText(XMLTags.AnnotationTag, vcNamespace);
    if (annotationText != null && annotationText.length() > 0) {
        annotation = unMangle(annotationText);
    }
    // Create and return the version object
    return new SimulationVersion(key, name, owner, groupAccess, branchpointref, branchId, date, flag, annotation, parentSimRefKey);
}
Also used : KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) Element(org.jdom.Element) VersionFlag(org.vcell.util.document.VersionFlag) SimulationVersion(org.vcell.util.document.SimulationVersion) SpeciesContext(cbit.vcell.model.SpeciesContext) DataContext(cbit.vcell.data.DataContext) ReactionContext(cbit.vcell.mapping.ReactionContext) RDFXMLContext(org.vcell.pathway.persistence.RDFXMLContext) SimulationContext(cbit.vcell.mapping.SimulationContext) OutputFunctionContext(cbit.vcell.solver.OutputFunctionContext) ParameterContext(cbit.vcell.mapping.ParameterContext) GroupAccess(org.vcell.util.document.GroupAccess) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

GroupAccess (org.vcell.util.document.GroupAccess)6 DataAccessException (org.vcell.util.DataAccessException)4 KeyValue (org.vcell.util.document.KeyValue)4 User (org.vcell.util.document.User)4 VersionFlag (org.vcell.util.document.VersionFlag)4 Version (org.vcell.util.document.Version)3 VCImageInfo (cbit.image.VCImageInfo)2 ACLEditor (cbit.vcell.client.desktop.ACLEditor)2 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)2 DocumentManager (cbit.vcell.clientdb.DocumentManager)2 DataContext (cbit.vcell.data.DataContext)2 GeometryInfo (cbit.vcell.geometry.GeometryInfo)2 ParameterContext (cbit.vcell.mapping.ParameterContext)2 ReactionContext (cbit.vcell.mapping.ReactionContext)2 SimulationContext (cbit.vcell.mapping.SimulationContext)2 SpeciesContext (cbit.vcell.model.SpeciesContext)2 OutputFunctionContext (cbit.vcell.solver.OutputFunctionContext)2 BigDecimal (java.math.BigDecimal)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Hashtable (java.util.Hashtable)2