use of org.vcell.util.document.Version in project vcell by virtualcell.
the class BioModelTable method getInfo.
/**
* This method was created in VisualAge.
* @return cbit.vcell.geometry.GeometryInfo
* @param rset java.sql.ResultSet
* @param log cbit.vcell.server.SessionLog
*/
public VersionInfo getInfo(ResultSet rset, Connection con, DatabaseSyntax dbSyntax) throws SQLException, org.vcell.util.DataAccessException {
KeyValue modelRef = new KeyValue(rset.getBigDecimal(table.modelRef.toString()));
BigDecimal groupid = rset.getBigDecimal(VersionTable.privacy_ColumnName);
Version version = getVersion(rset, DbDriver.getGroupAccessFromGroupID(con, groupid));
String softwareVersion = rset.getString(SoftwareVersionTable.table.softwareVersion.toString());
VCellSoftwareVersion vcSoftwareVersion = VCellSoftwareVersion.fromString(softwareVersion);
String serialDbChildSummary = DbDriver.varchar2_CLOB_get(rset, BioModelTable.table.childSummarySmall, BioModelTable.table.childSummaryLarge, dbSyntax);
return new org.vcell.util.document.BioModelInfo(version, modelRef, serialDbChildSummary, vcSoftwareVersion);
}
use of org.vcell.util.document.Version in project vcell by virtualcell.
the class BioModelTable method getBioModelMetaData.
/**
* This method was created in VisualAge.
* @return cbit.vcell.math.MathDescription
* @param user cbit.vcell.server.User
* @param rset java.sql.ResultSet
*/
public BioModelMetaData getBioModelMetaData(ResultSet rset, BioModelDbDriver bioModelDbDriver, Connection con, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException {
//
// Get Version
//
BigDecimal groupid = rset.getBigDecimal(VersionTable.privacy_ColumnName);
Version version = getVersion(rset, DbDriver.getGroupAccessFromGroupID(con, groupid));
KeyValue bioModelKey = version.getVersionKey();
KeyValue modelRef = new KeyValue(rset.getBigDecimal(table.modelRef.toString()));
//
// get Simulation Keys for bioModelKey
//
KeyValue[] simKeys = bioModelDbDriver.getSimulationEntriesFromBioModel(con, bioModelKey);
//
// get SimulationContext Keys for bioModelKey
//
KeyValue[] simContextKeys = bioModelDbDriver.getSimContextEntriesFromBioModel(con, bioModelKey);
//
// Get VCMetaData XML
//
String vcMetaDataXML = VCMetaDataTable.getVCMetaDataXML(rset, dbSyntax);
BioModelMetaData bioModelMetaData = new BioModelMetaData(version, modelRef, simContextKeys, simKeys, vcMetaDataXML);
return bioModelMetaData;
}
use of org.vcell.util.document.Version in project vcell by virtualcell.
the class BioModelPropertiesPanel method updateInterface.
/**
* Comment
*/
private void updateInterface() {
if (bioModel == null || bioModelWindowManager == null) {
return;
}
nameLabel.setText(bioModel.getName());
Version version = bioModel.getVersion();
if (version != null) {
ownerLabel.setText(version.getOwner().getName());
lastModifiedLabel.setText(version.getDate().toString());
try {
BioModelInfo bioModelInfo = bioModelWindowManager.getRequestManager().getDocumentManager().getBioModelInfo(version.getVersionKey());
permissionLabel.setText(bioModelInfo.getVersion().getGroupAccess().getDescription());
} catch (DataAccessException e) {
e.printStackTrace();
}
changePermissionButton.setEnabled(true);
}
webLinksPanel.removeAll();
webLinksPanel.setLayout(new GridLayout(0, 1));
Set<MiriamRefGroup> resources = new HashSet<MiriamRefGroup>();
Set<MiriamRefGroup> isDescribedByAnnotation = bioModel.getVCMetaData().getMiriamManager().getMiriamRefGroups(bioModel, MIRIAMQualifier.MODEL_isDescribedBy);
Set<MiriamRefGroup> isAnnotation = bioModel.getVCMetaData().getMiriamManager().getMiriamRefGroups(bioModel, MIRIAMQualifier.MODEL_is);
resources.addAll(isDescribedByAnnotation);
resources.addAll(isAnnotation);
for (MiriamRefGroup refGroup : resources) {
for (MiriamResource miriamResources : refGroup.getMiriamRefs()) {
LinkNode linkNode = new MiriamTreeModel.LinkNode(MIRIAMQualifier.MODEL_isDescribedBy, miriamResources);
final String link = linkNode.getLink();
String labelText = miriamResources.getDataType() == null ? "" : miriamResources.getDataType().getDataTypeName();
String toolTip = null;
if (link != null) {
toolTip = "double-click to open link " + link;
labelText = "<html><b>" + labelText + "</b> " + "<font color=blue><a href=" + link + ">" + link + "</a></font></html>";
}
JLabel label = new JLabel(labelText);
label.addMouseListener(new MouseListener() {
public void mouseReleased(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
DialogUtils.browserLauncher(BioModelPropertiesPanel.this, link, "failed to open " + link);
}
}
});
label.setToolTipText(toolTip);
webLinksPanel.add(label);
}
}
applicationsPanel.removeAll();
int gridy = 0;
SimulationContext[] simulationContexts = bioModel.getSimulationContexts();
if (simulationContexts != null) {
for (int i = 0; i < simulationContexts.length; i++) {
SimulationContext simContext = simulationContexts[i];
JLabel label = new JLabel(simContext.getName());
label.setFont(label.getFont().deriveFont(Font.BOLD));
if (simContext.isRuleBased()) {
if (simContext.getGeometry().getDimension() == 0) {
label.setIcon(VCellIcons.appRbmNonspIcon);
}
} else if (simContext.isStoch()) {
if (simContext.getGeometry().getDimension() == 0) {
label.setIcon(VCellIcons.appStoNonspIcon);
} else {
label.setIcon(VCellIcons.appStoSpatialIcon);
}
} else {
// deterministic
if (simContext.getGeometry().getDimension() == 0) {
label.setIcon(VCellIcons.appDetNonspIcon);
} else {
label.setIcon(VCellIcons.appDetSpatialIcon);
}
}
GridBagConstraints gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy++;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.FIRST_LINE_START;
if (i > 0) {
gbc.insets = new Insets(4, 0, 0, 0);
}
applicationsPanel.add(label, gbc);
Geometry geometry = simContext.getGeometry();
String geometryText = "Compartmental geometry";
if (geometry != null) {
Version geometryVersion = geometry.getVersion();
int dimension = geometry.getDimension();
if (dimension > 0) {
String description = geometry.getDimension() + "D " + (geometry.getGeometrySpec().hasImage() ? "image" : "analytic") + " geometry";
geometryText = description;
if (geometryVersion != null) {
geometryText += " - " + geometryVersion.getName();
}
}
}
JLabel geometryLabel = new JLabel(geometryText);
geometryLabel.setIcon(VCellIcons.geometryIcon);
JLabel detStochLabel = new JLabel(simContext.getMathType().getDescription());
detStochLabel.setIcon(VCellIcons.mathTypeIcon);
gbc.insets = new Insets(2, 20, 2, 2);
gbc.gridy = gridy++;
applicationsPanel.add(detStochLabel, gbc);
gbc.gridy = gridy++;
if (i == simulationContexts.length - 1) {
gbc.weighty = 1.0;
}
applicationsPanel.add(geometryLabel, gbc);
}
}
}
use of org.vcell.util.document.Version in project vcell by virtualcell.
the class XmlReader method getMathDescription.
/**
* This method returns a MathDescription from a XML element.
* Creation date: (4/26/2001 12:11:14 PM)
* @return cbit.vcell.math.MathDescription
* @param param org.jdom.Element
* @exception cbit.vcell.xml.XmlParseException The exception description.
*/
MathDescription getMathDescription(Element param, Geometry geometry) throws XmlParseException {
MathDescription mathdes = null;
Element tempelement;
// Retrieve Metadata(Version)
Version version = getVersion(param.getChild(XMLTags.VersionTag, vcNamespace));
// Retrieve attributes
String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
// Create new MathDescription
if (version != null) {
mathdes = new MathDescription(version);
} else {
mathdes = new MathDescription(name);
}
try {
// this step is needed!
mathdes.setGeometry(geometry);
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace();
throw new XmlParseException("a PropertyVetoException was fired when setting the Geometry to the Mathdescription in the simContext " + name, e);
}
// set attributes
try {
mathdes.setName(name);
// String annotation = param.getAttributeValue(XMLTags.AnnotationAttrTag);
// if (annotation!=null) {
// mathdes.setDescription(unMangle(annotation));
// }
// add Annotation
String annotationText = param.getChildText(XMLTags.AnnotationTag, vcNamespace);
if (annotationText != null && annotationText.length() > 0) {
mathdes.setDescription(unMangle(annotationText));
}
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace();
throw new XmlParseException("A PropertyVetoException was fired when setting the name " + name + ", to a new MathDescription!", e);
}
VariableHash varHash = new VariableHash();
// Retrieve Constant
Iterator<Element> iterator = param.getChildren(XMLTags.ConstantTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getConstant(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
// Retrieve FilamentRegionVariables
iterator = param.getChildren(XMLTags.FilamentRegionVariableTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getFilamentRegionVariable(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
// Retrieve FilamentVariables
iterator = param.getChildren(XMLTags.FilamentVariableTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getFilamentVariable(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
// retrieve InsideVariables
// **** This variables are for internal USE ******
// Retrieve MembraneRegionVariable
iterator = param.getChildren(XMLTags.MembraneRegionVariableTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getMembraneRegionVariable(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
// Retrieve MembraneVariable
iterator = param.getChildren(XMLTags.MembraneVariableTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getMemVariable(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
// Retrieve PointVariable
iterator = param.getChildren(XMLTags.PointVariableTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getPointVariable(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
// retrieve OutsideVariables
// **** This variables are for internal USE ******
// Retrieve Volume Region variable
iterator = param.getChildren(XMLTags.VolumeRegionVariableTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getVolumeRegionVariable(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
// Retrieve VolumeVariable
iterator = param.getChildren(XMLTags.VolumeVariableTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getVolVariable(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
// Retrieve StochVolVariable
iterator = param.getChildren(XMLTags.StochVolVariableTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getStochVolVariable(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
// Retrieve all the Functions //This needs to be processed before all the variables are read!
iterator = param.getChildren(XMLTags.FunctionTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getFunction(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
iterator = param.getChildren(XMLTags.VolumeRandomVariableTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getRandomVariable(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
iterator = param.getChildren(XMLTags.MembraneRandomVariableTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getRandomVariable(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
iterator = param.getChildren(XMLTags.VolumeParticleVariableTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getVolumeParticalVariable(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
iterator = param.getChildren(XMLTags.MembraneParticleVariableTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getMembraneParticalVariable(tempelement));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
// ParticleMolecularTypeTag getParticleMolecularTypes
// has to be done before VolumeParticleSpeciesPattern and VolumeParticleObservable
iterator = param.getChildren(XMLTags.ParticleMolecularTypeTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
mathdes.addParticleMolecularType(getParticleMolecularType(tempelement));
}
// VolumeParticleSpeciesPatternTag
iterator = param.getChildren(XMLTags.VolumeParticleSpeciesPatternTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getVolumeParticleSpeciesPattern(tempelement, mathdes));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
// VolumeParticleObservableTag getParticleObservables
iterator = param.getChildren(XMLTags.VolumeParticleObservableTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
varHash.addVariable(getVolumeParticleObservable(tempelement, varHash));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException(e);
}
}
//
try {
mathdes.setAllVariables(varHash.getAlphabeticallyOrderedVariables());
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException("Error adding the Function variables to the MathDescription " + name, e);
} catch (ExpressionBindingException e) {
e.printStackTrace();
throw new XmlParseException("Error adding the Function variables to the MathDescription " + name, e);
}
// Retrieve CompartmentsSubdomains
iterator = param.getChildren(XMLTags.CompartmentSubDomainTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
mathdes.addSubDomain(getCompartmentSubDomain(tempelement, mathdes));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException("Error adding a new CompartmentSubDomain to the MathDescription " + name, e);
}
}
// Retrieve MembraneSubdomains
iterator = param.getChildren(XMLTags.MembraneSubDomainTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
try {
mathdes.addSubDomain(getMembraneSubDomain(tempelement, mathdes));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException("Error adding a new MembraneSubDomain to the MathDescription " + name, e);
}
}
// Retrieve the FilamentSubdomain (if any)
tempelement = param.getChild(XMLTags.FilamentSubDomainTag, vcNamespace);
if (tempelement != null) {
try {
mathdes.addSubDomain(getFilamentSubDomain(tempelement, mathdes));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException("Error adding a new FilamentSubDomain to the MathDescription " + name, e);
}
}
// Retrieve the PointSubdomain (if any)
tempelement = param.getChild(XMLTags.PointSubDomainTag, vcNamespace);
if (tempelement != null) {
try {
mathdes.addSubDomain(getPointSubDomain(tempelement, mathdes));
} catch (MathException e) {
e.printStackTrace();
throw new XmlParseException("Error adding a new PointSubDomain to the MathDescription " + name, e);
}
}
iterator = param.getChildren(XMLTags.EventTag, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
Event event = getEvent(mathdes, tempelement);
try {
mathdes.addEvent(event);
} catch (MathException e) {
e.printStackTrace(System.out);
throw new XmlParseException(e);
}
}
iterator = param.getChildren(XMLTags.PostProcessingBlock, vcNamespace).iterator();
while (iterator.hasNext()) {
tempelement = (Element) iterator.next();
getPostProcessingBlock(mathdes, tempelement);
}
return mathdes;
}
use of org.vcell.util.document.Version in project vcell by virtualcell.
the class XmlReader method getVCImage.
/**
* This method returns a VCIMage object from a XML representation.
* Creation date: (3/16/2001 3:41:24 PM)
* @return VCImage
* @param param org.jdom.Element
*/
VCImage getVCImage(Element param, Extent extent) throws XmlParseException {
// try to get metadata(version)
Version version = getVersion(param.getChild(XMLTags.VersionTag, vcNamespace));
// get the attributes
Element tempelement = param.getChild(XMLTags.ImageDataTag, vcNamespace);
int aNumX = Integer.parseInt(tempelement.getAttributeValue(XMLTags.XAttrTag));
int aNumY = Integer.parseInt(tempelement.getAttributeValue(XMLTags.YAttrTag));
int aNumZ = Integer.parseInt(tempelement.getAttributeValue(XMLTags.ZAttrTag));
// getpixels
String temp = tempelement.getText();
// decode
byte[] data = Hex.toBytes(temp);
// create the VCImage object
VCImageCompressed newimage = null;
try {
newimage = new VCImageCompressed(version, data, extent, aNumX, aNumY, aNumZ);
} catch (ImageException e) {
e.printStackTrace();
throw new XmlParseException("An imageException occurred while trying to create a VCImage!", e);
}
// set attributes
String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
try {
newimage.setName(name);
// String annotation = param.getAttributeValue(XMLTags.AnnotationAttrTag);
// if (annotation!=null) {
// newimage.setDescription(unMangle(annotation));
// }
// read the annotation
String annotation = param.getChildText(XMLTags.AnnotationTag, vcNamespace);
if (annotation != null && annotation.length() > 0) {
newimage.setDescription(unMangle(annotation));
}
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace(System.out);
throw new XmlParseException(e);
}
// get PixelClasses
List<Element> pixelClassList = param.getChildren(XMLTags.PixelClassTag, vcNamespace);
if (pixelClassList.size() != 0) {
VCPixelClass[] pixelClassArray = new VCPixelClass[pixelClassList.size()];
int pixelClassCounter = 0;
for (Element pcElement : pixelClassList) {
pixelClassArray[pixelClassCounter] = getPixelClass(pcElement);
pixelClassCounter++;
}
try {
newimage.setPixelClasses(pixelClassArray);
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace(System.out);
throw new XmlParseException(e);
}
} else {
// Invalid format
System.out.println("Format Error! No <PixelClass> references found inside <Image name=\"" + name + "\">!");
System.out.println("Valid format for images is:");
System.out.println("<Image Name=\"??\">");
System.out.println(" <ImageData Z=\"?\" Y=\"?\" Z=\"?\" CompressedSize=\"?\">");
System.out.println(" ......Image content...");
System.out.println(" </ImageData>");
System.out.println(" <PixelClass Name=\"?\" ImagePixelValue=\"?\"/>");
System.out.println(" ...");
System.out.println(" <PixelClass Name=\"?\" ImagePixelValue=\"?\"/>");
System.out.println(" <Version Name=\"?\"/>");
System.out.println("</Image>");
throw new XmlParseException("Invalid VCML format error!\nNo <PixelClass> references found inside <Image name=\"" + name + "\">!");
}
return newimage;
}
Aggregations