Search in sources :

Example 1 with WSGetBusinessConceptKey

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

the class ViewMainPage method doSave.

@Override
public void doSave(IProgressMonitor monitor) {
    super.doSave(monitor);
    if (this.viewName != null && this.viewName.length() > 0) {
        if (viewName.matches("Browse_items.*")) {
            // $NON-NLS-1$
            // lastDataModelName=XpathSelectDialog.getDataModelName();
            // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
            String concept = viewName.replaceAll("Browse_items_", "").replaceAll("#.*", "");
            java.util.List<String> avaiList = getAvailableDataModel();
            if (avaiList.size() > 0) {
                lastDataModelName = avaiList.get(0);
            }
            if (concept != null && concept.length() > 0 && lastDataModelName != null && lastDataModelName.length() > 0) {
                // if(concept!=null&&concept.length()>0&&lastDataModelName!=null&&lastDataModelName.length()>0){
                // keys validate
                java.util.List<String> toAddViewableList = new ArrayList<String>();
                WSGetBusinessConceptKey wsGetBusinessConceptKey = new WSGetBusinessConceptKey(concept, new WSDataModelPK(lastDataModelName));
                WSConceptKey wsConceptKey = null;
                try {
                    wsConceptKey = getBusinessConceptKey(wsGetBusinessConceptKey);
                } catch (XtentisException e) {
                    log.error(e.getMessage(), e);
                }
                if (wsConceptKey != null) {
                    java.util.List<String> viewableList = new ArrayList<String>();
                    java.util.List<Line> vlines = (java.util.List<Line>) viewableViewer.getViewer().getInput();
                    for (int j = 0; j < vlines.size(); j++) {
                        Line item = vlines.get(j);
                        viewableList.add(item.keyValues.get(0).value);
                    }
                    java.util.List<String> keys = wsConceptKey.getFields();
                    for (int i = 0; i < keys.size(); i++) {
                        if (".".equals(wsConceptKey.getSelector())) {
                            // $NON-NLS-1$//$NON-NLS-2$
                            keys.set(i, "/" + concept + "/" + keys.get(i));
                        } else {
                            keys.set(i, wsConceptKey.getSelector() + keys.get(i));
                        }
                    }
                    java.util.List<String> ids = wsConceptKey.getFields();
                    for (String id : ids) {
                        // need to care about more case
                        if (id.startsWith("/")) {
                            // $NON-NLS-1$
                            id = id.substring(1);
                        } else if (id.startsWith("//")) {
                            // $NON-NLS-1$
                            id = id.substring(2);
                        }
                        if (!viewableList.contains(id)) {
                            toAddViewableList.add(0, id);
                        }
                    }
                }
                // show verify report
                if (toAddViewableList.size() > 0) {
                    String msg = Messages.ViewMainPage_Msg;
                    for (Object element : toAddViewableList) {
                        String toAddItem = (String) element;
                        // $NON-NLS-1$
                        msg += (toAddItem + "\n");
                    }
                    msg += Messages.ViewMainPage_Addtions;
                    MessageDialog.openInformation(this.getSite().getShell(), Messages.ViewMainPage_VerifyReport, msg);
                }
                // auto fix
                IRunnableWithProgress autoFixProcess = new AutoFixProgress(toAddViewableList, viewableViewer, this.getSite().getShell());
                try {
                    new ProgressMonitorDialog(this.getSite().getShell()).run(false, true, autoFixProcess);
                } catch (InvocationTargetException e) {
                    log.error(e.getMessage(), e);
                } catch (InterruptedException e) {
                    log.error(e.getMessage(), e);
                }
            }
        }
    }
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Line(com.amalto.workbench.models.Line) WSGetBusinessConceptKey(com.amalto.workbench.webservices.WSGetBusinessConceptKey) List(org.eclipse.swt.widgets.List) ArrayList(java.util.ArrayList) TreeObject(com.amalto.workbench.models.TreeObject) WSConceptKey(com.amalto.workbench.webservices.WSConceptKey) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK) XtentisException(com.amalto.workbench.utils.XtentisException)

Example 2 with WSGetBusinessConceptKey

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

the class AddBrowseItemsWizardR method getKeyElements.

private static List<String> getKeyElements(String datamodel, String concept) {
    java.util.List<String> idList = new ArrayList<String>();
    WSGetBusinessConceptKey wsGetBusinessConceptKey = new WSGetBusinessConceptKey(concept, new WSDataModelPK(datamodel));
    WSConceptKey wsConceptKey;
    try {
        wsConceptKey = RepositoryResourceUtil.getBusinessConceptKey(wsGetBusinessConceptKey);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        return idList;
    }
    List<String> ids = wsConceptKey.getFields();
    for (String id : ids) {
        // need to care about more case
        if (id.startsWith("/")) {
            // $NON-NLS-1$
            id = id.substring(1);
        } else if (id.startsWith("//")) {
            // $NON-NLS-1$
            id = id.substring(2);
        }
        idList.add(concept + '/' + id);
    }
    return idList;
}
Also used : WSGetBusinessConceptKey(com.amalto.workbench.webservices.WSGetBusinessConceptKey) ArrayList(java.util.ArrayList) WSConceptKey(com.amalto.workbench.webservices.WSConceptKey) LoginException(org.talend.commons.exception.LoginException) PersistenceException(org.talend.commons.exception.PersistenceException) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK)

Aggregations

WSConceptKey (com.amalto.workbench.webservices.WSConceptKey)2 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)2 WSGetBusinessConceptKey (com.amalto.workbench.webservices.WSGetBusinessConceptKey)2 ArrayList (java.util.ArrayList)2 Line (com.amalto.workbench.models.Line)1 TreeObject (com.amalto.workbench.models.TreeObject)1 XtentisException (com.amalto.workbench.utils.XtentisException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 List (org.eclipse.swt.widgets.List)1 LoginException (org.talend.commons.exception.LoginException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1