Search in sources :

Example 1 with Pathway

use of org.vcell.sybil.util.http.pathwaycommons.search.Pathway in project vcell by virtualcell.

the class BioModelEditorPathwayCommonsPanel method showPathway.

public void showPathway() {
    final Pathway pathway = computeSelectedPathway();
    if (pathway == null) {
        return;
    }
    AsynchClientTask task1 = new AsynchClientTask("Importing pathway '" + pathway.name() + "'", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(final Hashtable<String, Object> hashTable) throws Exception {
            final URL url = new URL(BeanUtils.getDynamicClientProperties().getProperty(PropertyLoader.PATHWAY_WEB_DO_URL) + "?" + PathwayCommonsKeyword.cmd + "=" + PathwayCommonsKeyword.get_record_by_cpath_id + "&" + PathwayCommonsKeyword.version + "=" + PathwayCommonsVersion.v2.name + "&" + PathwayCommonsKeyword.q + "=" + pathway.primaryId() + "&" + PathwayCommonsKeyword.output + "=" + PathwayCommonsKeyword.biopax);
            System.out.println(url.toString());
            String ERROR_CODE_TAG = "error_code";
            // String ERROR_MSG_TAG = "error_msg";
            org.jdom.Document jdomDocument = XmlUtil.getJDOMDocument(url, getClientTaskStatusSupport());
            org.jdom.Element rootElement = jdomDocument.getRootElement();
            String errorCode = rootElement.getChildText(ERROR_CODE_TAG);
            if (errorCode != null) {
                throw new RuntimeException("Failed to access " + url + " \n\nPlease try again.");
            }
            // String xmlText = StringUtil.textFromInputStream(connection.getInputStream());
            // PathwayReader pathwayReader = new PathwayReader();
            // org.jdom.Document jdomDocument = XmlUtil.stringToXML(xmlText, null);
            // String xmlText = StringUtil.textFromInputStream(connection.getInputStream(), "UTF-8");
            // PathwayReader pathwayReader = new PathwayReader();
            // org.jdom.Document jdomDocument = XmlUtil.stringToXML(xmlText, "UTF-8");
            PathwayModel pathwayModel = PathwayIOUtil.extractPathwayFromJDOM(jdomDocument, new RDFXMLContext(), getClientTaskStatusSupport());
            PathwayData pathwayData = new PathwayData(pathway.name(), pathwayModel);
            hashTable.put("pathwayData", pathwayData);
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("showing", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            PathwayData pathwayData = (PathwayData) hashTable.get("pathwayData");
            if (pathwayData != null) {
                // setActiveView(new ActiveView(null, DocumentEditorTreeFolderClass.PATHWAY_NODE, null));
                setSelectedObjects(new Object[] { pathwayData });
            }
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, true, true, null);
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) RDFXMLContext(org.vcell.pathway.persistence.RDFXMLContext) Pathway(org.vcell.sybil.util.http.pathwaycommons.search.Pathway) Hashtable(java.util.Hashtable) PathwayModel(org.vcell.pathway.PathwayModel) URL(java.net.URL)

Aggregations

AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 URL (java.net.URL)1 Hashtable (java.util.Hashtable)1 PathwayModel (org.vcell.pathway.PathwayModel)1 RDFXMLContext (org.vcell.pathway.persistence.RDFXMLContext)1 Pathway (org.vcell.sybil.util.http.pathwaycommons.search.Pathway)1