Search in sources :

Example 1 with DataModelSelectDialog

use of com.amalto.workbench.dialogs.DataModelSelectDialog 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)

Aggregations

DataModelSelectDialog (com.amalto.workbench.dialogs.DataModelSelectDialog)1 TreeObject (com.amalto.workbench.models.TreeObject)1 TreeParent (com.amalto.workbench.models.TreeParent)1 WSDataModel (com.amalto.workbench.webservices.WSDataModel)1 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)1 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)1 ArrayList (java.util.ArrayList)1