Search in sources :

Example 6 with WSDataModelPK

use of com.amalto.workbench.webservices.WSDataModelPK 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)

Example 7 with WSDataModelPK

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

the class EditXObjectAction method run.

@Override
public void run() {
    try {
        super.run();
        if (xobject == null || !xobject.isXObject()) {
            return;
        }
        // Access to server and get port
        TMDMService service = Util.getMDMService(new URL(xobject.getEndpointAddress()), xobject.getUsername(), xobject.getPassword());
        switch(xobject.getType()) {
            case TreeObject.DATA_MODEL:
                WSDataModel wsDataModel = service.getDataModel(new WSGetDataModel((WSDataModelPK) xobject.getWsKey()));
                xobject.setWsObject(wsDataModel);
                // XSDEditorUtil.openDataModel(xobject, false);
                return;
            case TreeObject.VIEW:
                WSView wsView = service.getView(new WSGetView((WSViewPK) xobject.getWsKey()));
                xobject.setWsObject(wsView);
                break;
            case TreeObject.DATA_CLUSTER:
                WSDataCluster wsDataCluster = service.getDataCluster(new WSGetDataCluster((WSDataClusterPK) xobject.getWsKey()));
                xobject.setWsObject(wsDataCluster);
                break;
            case TreeObject.STORED_PROCEDURE:
                WSStoredProcedure wsStoredProcedure = service.getStoredProcedure(new WSGetStoredProcedure((WSStoredProcedurePK) xobject.getWsKey()));
                xobject.setWsObject(wsStoredProcedure);
                break;
            case TreeObject.ROUTING_RULE:
                WSRoutingRule wsRoutingRule = service.getRoutingRule(new WSGetRoutingRule((WSRoutingRulePK) xobject.getWsKey()));
                xobject.setWsObject(wsRoutingRule);
                break;
            case TreeObject.TRANSFORMER:
                WSTransformerV2 wsTranformer = service.getTransformerV2(new WSGetTransformerV2((WSTransformerV2PK) xobject.getWsKey()));
                xobject.setWsObject(wsTranformer);
                break;
            case TreeObject.MENU:
                WSMenu wsMenu = service.getMenu(new WSGetMenu((WSMenuPK) xobject.getWsKey()));
                xobject.setWsObject(wsMenu);
                break;
            case TreeObject.SERVICE_CONFIGURATION:
                break;
            case TreeObject.JOB_REGISTRY:
                // System.out.println("JOB_REGISTRY "+ xobject.getDisplayName());
                break;
            case TreeObject.JOB:
                // System.out.println("JOB "+ xobject.getDisplayName()+" "+xobject.getWsKey());
                xobject.setWsObject(xobject.getDisplayName());
                break;
            case TreeObject.ROLE:
                if (exAdapter != null) {
                    exAdapter.run(service, xobject);
                }
                break;
            case TreeObject.RESOURCES:
            case TreeObject.CUSTOM_TYPE:
            case TreeObject.DATA_MODEL_RESOURCE:
            case TreeObject.DATA_MODEL_TYPES_RESOURCE:
            case TreeObject.CUSTOM_TYPES_RESOURCE:
            case TreeObject.PICTURES_RESOURCE:
                break;
            default:
                MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages.EditXObjectAction_ErrorMsg1, IConstants.TALEND, xobject.getType()));
                return;
        }
        if (page == null) {
            this.page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        }
        this.page.openEditor(new XObjectEditorInput(xobject, xobject.getDisplayName()), // $NON-NLS-1$
        "com.amalto.workbench.editors.XObjectEditor");
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        if (!Util.handleConnectionException(getShell(), e, Messages.EditXObjectAction_ErrorMsg2)) {
            MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages.EditXObjectAction_ErrorMsg2, e.getLocalizedMessage()));
        }
    }
}
Also used : WSGetStoredProcedure(com.amalto.workbench.webservices.WSGetStoredProcedure) WSMenuPK(com.amalto.workbench.webservices.WSMenuPK) WSGetTransformerV2(com.amalto.workbench.webservices.WSGetTransformerV2) WSStoredProcedurePK(com.amalto.workbench.webservices.WSStoredProcedurePK) XObjectEditorInput(com.amalto.workbench.providers.XObjectEditorInput) URL(java.net.URL) WSView(com.amalto.workbench.webservices.WSView) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataCluster(com.amalto.workbench.webservices.WSDataCluster) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) TMDMService(com.amalto.workbench.webservices.TMDMService) WSRoutingRule(com.amalto.workbench.webservices.WSRoutingRule) WSStoredProcedure(com.amalto.workbench.webservices.WSStoredProcedure) WSGetView(com.amalto.workbench.webservices.WSGetView) WSGetMenu(com.amalto.workbench.webservices.WSGetMenu) WSRoutingRulePK(com.amalto.workbench.webservices.WSRoutingRulePK) WSGetRoutingRule(com.amalto.workbench.webservices.WSGetRoutingRule) WSMenu(com.amalto.workbench.webservices.WSMenu) WSDataModel(com.amalto.workbench.webservices.WSDataModel) WSGetDataCluster(com.amalto.workbench.webservices.WSGetDataCluster) WSTransformerV2(com.amalto.workbench.webservices.WSTransformerV2) WSTransformerV2PK(com.amalto.workbench.webservices.WSTransformerV2PK) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK) WSViewPK(com.amalto.workbench.webservices.WSViewPK)

Example 8 with WSDataModelPK

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

the class ResourceCompareInput method commitToDB.

private void commitToDB() {
    try {
        String toCommitContent = CompareManager.getInstance().getLeftContent();
        // $NON-NLS-1$
        toCommitContent = XmlUtil.formatCompact(toCommitContent, "UTF-8");
        if (this.compareHeadInfo.isItem()) {
            Util.getMDMService(compareHeadInfo.getXobject()).putItem(new WSPutItem(false, (WSDataClusterPK) compareHeadInfo.getXobject().getWsKey(), // $NON-NLS-1$
            "".equals(compareHeadInfo.getDataModelName()) ? null : new WSDataModelPK(compareHeadInfo.getDataModelName()), toCommitContent));
        } else {
        // TODO add support for Object(s)
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        if (!Util.handleConnectionException((Shell) null, e, null)) {
            MessageDialog.openError(null, Messages._Error, Messages.bind(Messages.ResourceCompareInput_ErrorMsg, e.getLocalizedMessage()));
        }
    }
}
Also used : WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) WSPutItem(com.amalto.workbench.webservices.WSPutItem) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK)

Example 9 with WSDataModelPK

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

the class DataClusterComposite method doSelectDataModelForEntityRecords.

/**
 * @param clusterName
 * @throws XtentisException
 * @throws Exception
 */
private boolean doSelectDataModelForEntityRecords(String clusterName) throws XtentisException, Exception {
    // if (false) {
    // Modified by hbhong,to fix bug 21784|
    TreeParent treeParent = (TreeParent) getAdapter(TreeParent.class);
    DataModelSelectDialog dialog = new DataModelSelectDialog(getSite(), treeParent, clusterName);
    // The ending| bug:21784
    dialog.setBlockOnOpen(true);
    dialog.open();
    if (dialog.getReturnCode() == Window.OK) {
        List<String> allConcept = new ArrayList<String>();
        String[] xpaths = dialog.getXpath();
        for (String xpath : xpaths) {
            WSDataModel dm = Util.getMDMService(this.getXObject()).getDataModel(new WSGetDataModel(new WSDataModelPK(xpath)));
            if (dm == null) {
                return false;
            }
            List<String> concepts = Util.getConcepts(Util.getXSDSchema(dm.getXsdSchema()));
            allConcept.addAll(concepts);
        }
        String[] concepts = allConcept.toArray(new String[0]);
        TreeObject object = null;
        TreeObject[] children = treeParent.getChildren();
        for (TreeObject element : children) {
            object = element;
            if (object.getType() == TreeObject.DATA_MODEL) {
                break;
            }
        }
        // $NON-NLS-1$
        String revision = "";
        if (object != null) {
            // revisions).
            if (object.getDisplayName().contains(Messages.DataClusterBrowserMainPage_16) && object.getDisplayName().contains(Messages.DataClusterBrowserMainPage_17)) {
                revision = // $NON-NLS-1$
                object.getDisplayName().substring(// $NON-NLS-1$
                object.getDisplayName().indexOf("[") + 1, // $NON-NLS-1$
                object.getDisplayName().indexOf("]"));
            }
        }
        for (int i = 0; i < concepts.length; i++) {
            String concept = concepts[i];
            if (revision == null || revision.equals("")) {
                // $NON-NLS-1$
                // $NON-NLS-1$
                revision = "HEAD";
            }
            // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
            concepts[i] = concept + " " + "[" + revision + "]";
        }
        conceptCombo.removeAll();
        // $NON-NLS-1$
        conceptCombo.add("*");
        for (String concept : concepts) {
            conceptCombo.add(concept);
        }
    } else {
        // $NON-NLS-1$
        conceptCombo.add("*");
    }
    return true;
}
Also used : WSDataModel(com.amalto.workbench.webservices.WSDataModel) DataModelSelectDialog(com.amalto.workbench.dialogs.DataModelSelectDialog) TreeParent(com.amalto.workbench.models.TreeParent) ArrayList(java.util.ArrayList) TreeObject(com.amalto.workbench.models.TreeObject) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK)

Example 10 with WSDataModelPK

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

the class ProjectDecisionDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // Should not really be here but well,....
    parent.getShell().setText(this.title);
    Composite composite = (Composite) super.createDialogArea(parent);
    GridLayout layout = (GridLayout) composite.getLayout();
    layout.numColumns = 2;
    try {
        // process the decision
        // $NON-NLS-1$
        String dataClusterName = "";
        // $NON-NLS-1$
        String dataModelName = "";
        boolean doOverwrite = true;
        Matcher m = dp.matcher(decision);
        if (m.matches()) {
            dataClusterName = m.group(1);
            dataModelName = m.group(2);
            if (m.groupCount() >= 4) {
                // $NON-NLS-1$
                doOverwrite = (!"false".equals(m.group(3)));
            }
        }
        TMDMService port = Util.getMDMService(new URL(transformerObject.getEndpointAddress()), transformerObject.getUsername(), transformerObject.getPassword());
        // Grab the available Clusters
        // $NON-NLS-1$
        List<WSDataClusterPK> dcpks = port.getDataClusterPKs(new WSRegexDataClusterPKs(".*")).getWsDataClusterPKs();
        Label dataClustersLabel = new Label(composite, SWT.NULL);
        dataClustersLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        dataClustersLabel.setText(Messages.ProjectDecisionDialog_DataContainers);
        dataClustersCombo = new Combo(composite, SWT.DROP_DOWN);
        dataClustersCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
        int dataClusterSelect = -1;
        if (dcpks != null) {
            int i = 0;
            for (WSDataClusterPK pk : dcpks) {
                dataClustersCombo.add(pk.getPk());
                if (pk.getPk().equals(dataClusterName)) {
                    dataClusterSelect = i;
                }
                i++;
            }
        }
        dataClustersCombo.select(dataClusterSelect);
        // Grab the available Models
        // $NON-NLS-1$
        List<WSDataModelPK> dmpks = port.getDataModelPKs(new WSRegexDataModelPKs(".*")).getWsDataModelPKs();
        Label dataModelsLabel = new Label(composite, SWT.NULL);
        dataModelsLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        dataModelsLabel.setText(Messages.ProjectDecisionDialog_DataModels);
        dataModelsCombo = new Combo(composite, SWT.DROP_DOWN);
        dataModelsCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
        int dataModelSelect = -1;
        if (dmpks != null) {
            int i = 0;
            for (WSDataModelPK pk : dmpks) {
                dataModelsCombo.add(pk.getPk());
                if (pk.getPk().equals(dataModelName)) {
                    dataModelSelect = i;
                }
                i++;
            }
        }
        dataModelsCombo.select(dataModelSelect);
        // Overwrite
        Label overwriteLabel = new Label(composite, SWT.NULL);
        overwriteLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        overwriteLabel.setText(Messages.ProjectDecisionDialog_Overwrite);
        overwriteButton = new Button(composite, SWT.CHECK);
        overwriteButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
        overwriteButton.setSelection(doOverwrite);
    } catch (Exception e) {
        if (!Util.handleConnectionException(this.getShell(), e, null)) {
            MessageDialog.openError(ProjectDecisionDialog.this.getShell(), Messages.ProjectDecisionDialog_ErrorTitle, Messages.bind(Messages.ProjectDecisionDialog_ErrorMsg, e.getMessage()));
        }
    }
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Matcher(java.util.regex.Matcher) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) URL(java.net.URL) GridLayout(org.eclipse.swt.layout.GridLayout) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) TMDMService(com.amalto.workbench.webservices.TMDMService) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) WSRegexDataModelPKs(com.amalto.workbench.webservices.WSRegexDataModelPKs) WSRegexDataClusterPKs(com.amalto.workbench.webservices.WSRegexDataClusterPKs) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK)

Aggregations

WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)17 WSDataModel (com.amalto.workbench.webservices.WSDataModel)10 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)10 TMDMService (com.amalto.workbench.webservices.TMDMService)8 TreeObject (com.amalto.workbench.models.TreeObject)6 ArrayList (java.util.ArrayList)6 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)5 WSRegexDataModelPKs (com.amalto.workbench.webservices.WSRegexDataModelPKs)4 TreeParent (com.amalto.workbench.models.TreeParent)3 WSDataCluster (com.amalto.workbench.webservices.WSDataCluster)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 WSMenu (com.amalto.workbench.webservices.WSMenu)3 WSMenuPK (com.amalto.workbench.webservices.WSMenuPK)3 WSRoutingRule (com.amalto.workbench.webservices.WSRoutingRule)3 WSRoutingRulePK (com.amalto.workbench.webservices.WSRoutingRulePK)3