Search in sources :

Example 6 with MiriamRefGroup

use of cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup in project vcell by virtualcell.

the class VCMetaData method cleanupMetadata.

public void cleanupMetadata() {
    Set<Registry.Entry> entries = registry.getAllEntries();
    for (Registry.Entry entry : entries) {
        Identifiable entryIdentifiable = entry.getIdentifiable();
        VCID vcid = identifiableProvider.getVCID(entryIdentifiable);
        Identifiable identifiable = identifiableProvider.getIdentifiableObject(vcid);
        if (identifiable == null) {
            // use miriamManager to remove RDF statements from resource for identifiable
            try {
                Map<MiriamRefGroup, MIRIAMQualifier> miriamRefGps = getMiriamManager().getAllMiriamRefGroups(entryIdentifiable);
                if (miriamRefGps != null) {
                    for (Map.Entry<MiriamRefGroup, MIRIAMQualifier> groupEntry : miriamRefGps.entrySet()) {
                        MiriamRefGroup refGroup = groupEntry.getKey();
                        MIRIAMQualifier qualifier = groupEntry.getValue();
                        getMiriamManager().remove(entryIdentifiable, qualifier, refGroup);
                    }
                }
            } catch (URNParseFailureException e) {
                e.printStackTrace(System.out);
            }
            // set nonRDF annotations to null
            NonRDFAnnotation nonRDFAnnotation = getExistingNonRDFAnnotation(entryIdentifiable);
            if (nonRDFAnnotation != null) {
                nonRDFAnnotation.setFreeTextAnnotation(null);
                nonRDFAnnotation.setXhtmlNotes(null);
                nonRDFAnnotation.setXmlAnnotations(null);
            }
            System.err.println("Deleting resource for identifiable '" + entryIdentifiable.toString() + "' since it is not found in " + identifiableProvider.getClass().getName());
        }
    }
}
Also used : Registry(cbit.vcell.biomodel.meta.registry.Registry) Identifiable(org.vcell.util.document.Identifiable) Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry) Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) Map(java.util.Map) IdentityHashMap(java.util.IdentityHashMap) TreeMap(java.util.TreeMap) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)

Example 7 with MiriamRefGroup

use of cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup in project vcell by virtualcell.

the class SpeciesPropertiesPanel method updatePCLink.

private void updatePCLink() {
    try {
        StringBuffer buffer = new StringBuffer("<html>");
        MiriamManager miriamManager = bioModel.getModel().getVcMetaData().getMiriamManager();
        Map<MiriamRefGroup, MIRIAMQualifier> refGroups = miriamManager.getAllMiriamRefGroups(getSpeciesContext().getSpecies());
        if (refGroups != null && refGroups.size() > 0) {
            for (MiriamRefGroup refGroup : refGroups.keySet()) {
                Set<MiriamResource> miriamResources = refGroup.getMiriamRefs();
                for (MiriamResource resource : miriamResources) {
                    String urn = resource.getMiriamURN();
                    String preferredName = "";
                    if (urn != null && urn.length() > 0) {
                        String prettyName = miriamManager.getPrettyName(resource);
                        if (prettyName != null) {
                            preferredName = "[" + prettyName + "]";
                        }
                        String prettyResourceName = urn.replaceFirst("urn:miriam:", "");
                        buffer.append("&#x95;&nbsp;" + prettyResourceName + "&nbsp;<b>" + preferredName + "</b><br>");
                        List<URL> linkURLs = miriamManager.getStoredCrossReferencedLinks(resource);
                        for (URL url : linkURLs) {
                            buffer.append("&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;<a href=\"" + url.toString() + "\">" + url.toString() + "</a><br>");
                        }
                    }
                }
            }
        }
        buffer.append("</html>");
        getPCLinkValueEditorPane().setText(buffer.toString());
        getPCLinkValueEditorPane().setCaretPosition(0);
    } catch (Exception ex) {
        ex.printStackTrace(System.out);
        DialogUtils.showErrorDialog(this, ex.getMessage());
    }
}
Also used : MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) URL(java.net.URL) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException) PropertyVetoException(java.beans.PropertyVetoException) ExpandVetoException(javax.swing.tree.ExpandVetoException) MalformedURLException(java.net.MalformedURLException)

Example 8 with MiriamRefGroup

use of cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup 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>&nbsp;" + "<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);
        }
    }
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) MouseEvent(java.awt.event.MouseEvent) Insets(java.awt.Insets) BioModelInfo(org.vcell.util.document.BioModelInfo) JLabel(javax.swing.JLabel) SimulationContext(cbit.vcell.mapping.SimulationContext) Geometry(cbit.vcell.geometry.Geometry) GridLayout(java.awt.GridLayout) MouseListener(java.awt.event.MouseListener) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) Version(org.vcell.util.document.Version) LinkNode(cbit.vcell.xml.gui.MiriamTreeModel.LinkNode) DataAccessException(org.vcell.util.DataAccessException) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) HashSet(java.util.HashSet)

Example 9 with MiriamRefGroup

use of cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup in project vcell by virtualcell.

the class BioModelTreeModel method addBioModelContents.

/**
 * Insert the method's description here.
 * Creation date: (11/28/00 2:41:43 PM)
 * @param bioModelNode cbit.vcell.desktop.BioModelNode
 * @param bioModelInfo cbit.vcell.biomodel.BioModelInfo
 */
private void addBioModelContents(BioModelNode bioModelNode, BioModel bioModel) {
    // 
    if (bioModel == null) {
        return;
    }
    // bioModelNode.add(new BioModelNode(bioModel.getModel(),false));
    // if (bioModel.getDescription() != null && !bioModel.getDescription().equals("")){
    bioModelNode.add(new BioModelNode(new Annotation(bioModel.getVCMetaData().getFreeTextAnnotation(bioModel)), false));
    // }
    Set<MiriamRefGroup> isDescribedByAnnotation = bioModel.getVCMetaData().getMiriamManager().getMiriamRefGroups(bioModel, MIRIAMQualifier.MODEL_isDescribedBy);
    for (MiriamRefGroup refGroup : isDescribedByAnnotation) {
        for (MiriamResource miriamResources : refGroup.getMiriamRefs()) {
            bioModelNode.add(new MiriamTreeModel.LinkNode(MIRIAMQualifier.MODEL_isDescribedBy, miriamResources));
        }
    }
    Set<MiriamRefGroup> isAnnotation = bioModel.getVCMetaData().getMiriamManager().getMiriamRefGroups(bioModel, MIRIAMQualifier.MODEL_is);
    for (MiriamRefGroup refGroup : isAnnotation) {
        for (MiriamResource miriamResources : refGroup.getMiriamRefs()) {
            bioModelNode.add(new MiriamTreeModel.LinkNode(MIRIAMQualifier.MODEL_is, miriamResources));
        }
    }
    SimulationContext[] scArray = bioModel.getSimulationContexts();
    if (scArray != null) {
        for (int i = 0; i < scArray.length; i++) {
            BioModelNode scNode = new BioModelNode(scArray[i], true);
            bioModelNode.add(scNode);
            // scNode.add(new BioModelNode(scArray[i].getModel(),false));
            // add application type node
            MathType typeInfo = scArray[i].getMathType();
            BioModelNode appTypeNode = new BioModelNode(typeInfo, false);
            appTypeNode.setRenderHint("type", "AppType");
            scNode.add(appTypeNode);
            // 
            // Display Annotation on tree
            // 
            scNode.add(new BioModelNode(new Annotation(scArray[i].getDescription()), false));
            scNode.add(new BioModelNode(scArray[i].getGeometry(), false));
            if (scArray[i].getMathDescription() != null) {
                scNode.add(new BioModelNode(scArray[i].getMathDescription(), false));
            } else {
                scNode.add(new BioModelNode("math not generated", false));
            }
            // 
            // add simulations to simulationContext
            // 
            Simulation[] simArray = bioModel.getSimulations();
            if (simArray != null) {
                for (int j = 0; j < simArray.length; j++) {
                    if (simArray[j].getMathDescription() == scArray[i].getMathDescription()) {
                        BioModelNode simNode = new BioModelNode(simArray[j], true);
                        scNode.add(simNode);
                        // 
                        // add simulation children (simulation annotations)
                        // 
                        // if (simArray[j].getDescription() != null && simArray[j].getDescription().length() > 0){
                        simNode.add(new BioModelNode(new Annotation(simArray[j].getDescription()), false));
                    // }
                    // simNode.add(new BioModelNode(simArray[i].getMathDescription(),false));
                    // simNode.add(new BioModelNode(simArray[i].getMathOverrides(),false));
                    // simNode.add(new BioModelNode(simArray[i].getMeshSpecification(),false));
                    // simNode.add(new BioModelNode(simArray[i].getSolverTaskDescription(),false));
                    }
                }
            }
        }
    }
}
Also used : MathType(org.vcell.util.document.BioModelChildSummary.MathType) SimulationContext(cbit.vcell.mapping.SimulationContext) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) Simulation(cbit.vcell.solver.Simulation) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) MiriamTreeModel(cbit.vcell.xml.gui.MiriamTreeModel)

Example 10 with MiriamRefGroup

use of cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup in project vcell by virtualcell.

the class AnnotationMapping method getRefInfo.

private HashMap<String, String> getRefInfo(BioModel bioModel, Identifiable identifiable) {
    HashMap<String, String> info = new HashMap<String, String>();
    VCMetaData vcMetaData = bioModel.getVCMetaData();
    MiriamManager miriamManager = vcMetaData.getMiriamManager();
    TreeMap<Identifiable, Map<MiriamRefGroup, MIRIAMQualifier>> miriamDescrHeir = miriamManager.getMiriamTreeMap();
    Map<MiriamRefGroup, MIRIAMQualifier> refGroupMap = miriamDescrHeir.get(identifiable);
    if (refGroupMap != null) {
        for (MiriamRefGroup refGroup : refGroupMap.keySet()) {
            MIRIAMQualifier qualifier = refGroupMap.get(refGroup);
            String[] quaTemp = qualifier.toString().split("/");
            String bioQualifier = quaTemp[quaTemp.length - 1];
            bioQualifier = bioQualifier.substring(0, bioQualifier.length() - 1);
            for (MiriamResource miriamResource : refGroup.getMiriamRefs()) {
                String refSource = miriamResource.getMiriamURN();
                String[] temp = refSource.split(":");
                String sourceInfo = temp[2] + ":" + bioQualifier;
                String refId = miriamResource.getIdentifier();
                info.put(refId, sourceInfo);
            // System.out.println(refId + "*********" + sourceInfo);
            }
        }
    }
    return info;
}
Also used : MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) HashMap(java.util.HashMap) Identifiable(org.vcell.util.document.Identifiable) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)

Aggregations

MiriamRefGroup (cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)10 MIRIAMQualifier (org.vcell.sybil.models.miriam.MIRIAMQualifier)7 MiriamResource (cbit.vcell.biomodel.meta.MiriamManager.MiriamResource)6 Identifiable (org.vcell.util.document.Identifiable)5 MiriamManager (cbit.vcell.biomodel.meta.MiriamManager)4 Map (java.util.Map)4 TreeMap (java.util.TreeMap)4 URNParseFailureException (org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException)3 BioModelNode (cbit.vcell.desktop.BioModelNode)2 SimulationContext (cbit.vcell.mapping.SimulationContext)2 MiriamTreeModel (cbit.vcell.xml.gui.MiriamTreeModel)2 IdentityHashMap (java.util.IdentityHashMap)2 IdentifiableComparator (cbit.vcell.biomodel.meta.IdentifiableComparator)1 VCID (cbit.vcell.biomodel.meta.VCID)1 VCMetaData (cbit.vcell.biomodel.meta.VCMetaData)1 Registry (cbit.vcell.biomodel.meta.registry.Registry)1 Entry (cbit.vcell.biomodel.meta.registry.Registry.Entry)1 Annotation (cbit.vcell.desktop.Annotation)1 Geometry (cbit.vcell.geometry.Geometry)1 SpeciesContext (cbit.vcell.model.SpeciesContext)1