Search in sources :

Example 1 with WSDataModel

use of com.amalto.workbench.webservices.WSDataModel in project tmdm-studio-se by Talend.

the class DOMViewDialog method updateKeyMap.

private void updateKeyMap(String dataModelName) {
    if (dataModelName == null || port == null) {
        return;
    }
    if (keyWordMap.get(dataModelName) == null) {
        WSGetDataModel wsGetModel = new WSGetDataModel(new WSDataModelPK(dataModelName));
        try {
            WSDataModel dataModel = port.getDataModel(wsGetModel);
            String xsdSchemaStr = dataModel.getXsdSchema();
            if (xsdSchemaStr != null) {
                XSDSchema schema = Util.getXSDSchema(xsdSchemaStr);
                Set<String> allKeyWords = getAllKeyWords(schema);
                if (!allKeyWords.isEmpty()) {
                    String[] keys = allKeyWords.toArray(new String[0]);
                    Arrays.sort(keys);
                    keyWordMap.put(dataModelName, keys);
                }
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
    }
}
Also used : WSDataModel(com.amalto.workbench.webservices.WSDataModel) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 2 with WSDataModel

use of com.amalto.workbench.webservices.WSDataModel in project tmdm-studio-se by Talend.

the class XpathSelectDialog method changeDomTree.

protected void changeDomTree(final TreeParent pObject, String filter) {
    String modelDisplay = dataModelCombo.getText();
    if (modelDisplay.length() == 0) {
        return;
    }
    this.dataModelName = modelDisplay;
    // this.selectedDataModelName = modelDisplay;
    // xobject = pObject.findObject(TreeObject.DATA_MODEL, modelDisplay);
    TMDMService service = null;
    try {
        service = Util.getMDMService(pObject);
    } catch (XtentisException e3) {
        log.error(e3.getMessage(), e3);
    } catch (Exception e3) {
        log.error(e3.getMessage(), e3);
    }
    WSDataModel wsDataModel = null;
    String schema = null;
    XSDSchema xsd = null;
    if (service == null) {
        xsd = MDMRepositoryViewExtensionService.getDataModelXsd(pObject, filter, dataModelName);
        provideViwerContent(xsd, filter);
    } else {
        try {
            wsDataModel = service.getDataModel(new WSGetDataModel(new WSDataModelPK(dataModelName)));
            // XSDSchema xsdSchema = Util.getXSDSchema(wsDataModel.getXsdSchema());
            // Util.nodeToString(xsdSchema.getDocument());
            schema = wsDataModel.getXsdSchema();
            xsd = Util.createXsdSchema(schema, pObject);
            provideViwerContent(xsd, filter);
        } catch (Exception e1) {
            log.error(e1.getMessage(), e1);
        }
    }
}
Also used : WSDataModel(com.amalto.workbench.webservices.WSDataModel) TMDMService(com.amalto.workbench.webservices.TMDMService) XtentisException(com.amalto.workbench.utils.XtentisException) XtentisException(com.amalto.workbench.utils.XtentisException) XSDSchema(org.eclipse.xsd.XSDSchema) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK)

Example 3 with WSDataModel

use of com.amalto.workbench.webservices.WSDataModel in project tmdm-studio-se by Talend.

the class Util method getForeingKeyInDataModel.

/**
 * set the list with all the foreign concepty name in the parent
 *
 * @author ymli
 * @param list
 * @param parent
 * @throws Exception
 */
public static void getForeingKeyInDataModel(Set<String> list, TreeParent parent, TMDMService service) throws Exception {
    TreeObject[] children = parent.getChildren();
    for (TreeObject object : children) {
        if (object instanceof TreeParent) {
            getForeingKeyInDataModel(list, (TreeParent) object, service);
            continue;
        }
        WSDataModel wsDataModel = service.getDataModel(new WSGetDataModel(new WSDataModelPK(object.getDisplayName())));
        XSDSchema xsd = Util.createXsdSchema(wsDataModel.getXsdSchema(), object);
        getForeingKeyInSchema(list, xsd);
    }
}
Also used : WSDataModel(com.amalto.workbench.webservices.WSDataModel) TreeParent(com.amalto.workbench.models.TreeParent) TreeObject(com.amalto.workbench.models.TreeObject) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 4 with WSDataModel

use of com.amalto.workbench.webservices.WSDataModel in project tmdm-studio-se by Talend.

the class Util method getDataModel.

// The ending| bug:21784
public static List<String> getDataModel(TreeObject obj, String datamodel, String conceptName) {
    List<String> systemDataModelValues = Util.getChildren(obj.getServerRoot(), TreeObject.DATA_MODEL);
    // filter the datamodel according to conceptName
    List<String> avaiList = new ArrayList<String>();
    avaiList.addAll(systemDataModelValues);
    if (datamodel != null) {
        avaiList.clear();
        avaiList.add(datamodel);
    } else if (conceptName != null && !conceptName.contains("*")) {
        // $NON-NLS-1$
        for (String data : systemDataModelValues) {
            try {
                WSDataModel dm = Util.getMDMService(obj).getDataModel(new WSGetDataModel(new WSDataModelPK(data)));
                if (dm != null) {
                    // XSDSchema xsdSchema = Util.getXSDSchema(dm.getXsdSchema());
                    String schema = dm.getXsdSchema();
                    // $NON-NLS-1$//$NON-NLS-2$
                    Pattern p = Pattern.compile("<xsd:element(.*?)name=\"" + conceptName + "\"");
                    if (!p.matcher(schema).find()) {
                        avaiList.remove(data);
                    }
                }
            } catch (Exception e1) {
                log.error(e1.getMessage(), e1);
            }
        }
    }
    if (avaiList.size() == 0) {
        avaiList.addAll(systemDataModelValues);
    }
    return avaiList;
}
Also used : Pattern(java.util.regex.Pattern) WSDataModel(com.amalto.workbench.webservices.WSDataModel) ArrayList(java.util.ArrayList) ConnectException(java.net.ConnectException) IOException(java.io.IOException) WebServiceException(javax.xml.ws.WebServiceException) MissingJarsException(com.amalto.workbench.service.MissingJarsException) MalformedURLException(java.net.MalformedURLException) SAXParseException(org.xml.sax.SAXParseException) InaccessibleWSDLException(com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK)

Example 5 with WSDataModel

use of com.amalto.workbench.webservices.WSDataModel in project tmdm-studio-se by Talend.

the class Util method getXSDSchema.

public static XSDSchema getXSDSchema(TreeObject treeObj, String dataModelName) {
    TreeObject dataModelFolder = treeObj.findServerFolder(TreeObject.DATA_MODEL);
    TMDMService port = null;
    try {
        port = Util.getMDMService(dataModelFolder);
    } catch (XtentisException e3) {
        log.error(e3.getMessage(), e3);
    } catch (Exception e3) {
        log.error(e3.getMessage(), e3);
    }
    WSDataModel wsDataModel = null;
    try {
        wsDataModel = port.getDataModel(new WSGetDataModel(new WSDataModelPK(dataModelName)));
        String schema = wsDataModel.getXsdSchema();
        return Util.createXsdSchema(schema, dataModelFolder);
    } catch (Exception e1) {
        log.error(e1.getMessage(), e1);
    }
    return null;
}
Also used : WSDataModel(com.amalto.workbench.webservices.WSDataModel) TMDMService(com.amalto.workbench.webservices.TMDMService) TreeObject(com.amalto.workbench.models.TreeObject) ConnectException(java.net.ConnectException) IOException(java.io.IOException) WebServiceException(javax.xml.ws.WebServiceException) MissingJarsException(com.amalto.workbench.service.MissingJarsException) MalformedURLException(java.net.MalformedURLException) SAXParseException(org.xml.sax.SAXParseException) InaccessibleWSDLException(com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK)

Aggregations

WSDataModel (com.amalto.workbench.webservices.WSDataModel)23 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)10 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)10 SAXParseException (org.xml.sax.SAXParseException)8 TMDMService (com.amalto.workbench.webservices.TMDMService)6 PartInitException (org.eclipse.ui.PartInitException)6 TreeObject (com.amalto.workbench.models.TreeObject)5 XSDSchema (org.eclipse.xsd.XSDSchema)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 IFile (org.eclipse.core.resources.IFile)4 CoreException (org.eclipse.core.runtime.CoreException)4 TreeParent (com.amalto.workbench.models.TreeParent)3 WSDataCluster (com.amalto.workbench.webservices.WSDataCluster)3 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)3 WSGetDataCluster (com.amalto.workbench.webservices.WSGetDataCluster)3 WSGetMenu (com.amalto.workbench.webservices.WSGetMenu)3 WSGetRoutingRule (com.amalto.workbench.webservices.WSGetRoutingRule)3 WSGetStoredProcedure (com.amalto.workbench.webservices.WSGetStoredProcedure)3 WSGetTransformerV2 (com.amalto.workbench.webservices.WSGetTransformerV2)3 WSGetView (com.amalto.workbench.webservices.WSGetView)3