Search in sources :

Example 11 with TreeObject

use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.

the class OpenObjectAction method doSelectServer.

public boolean doSelectServer(Item item, IRepositoryViewEditorInput editorInput) {
    MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
    if (serverObject.getType() == TreeObject.DATA_CLUSTER) {
        // Data Cluster
        MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(item);
        MDMServerDef serverDef = openServerDialog(lastServerDef);
        if (serverDef != null) {
            XObjectBrowserInput input = (XObjectBrowserInput) editorInput;
            TreeObject xobject = (TreeObject) input.getModel();
            if (xobject != null && xobject.getWsKey() != null) {
                TreeParent serverRoot = getServerRoot(serverDef);
                xobject.setWsKey(new WSDataClusterPK(xobject.getWsKey().toString()));
                xobject.setServerRoot(serverRoot);
                return true;
            }
        }
        return false;
    }
    return true;
}
Also used : WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) TreeParent(com.amalto.workbench.models.TreeParent) XObjectBrowserInput(com.amalto.workbench.providers.XObjectBrowserInput) TreeObject(com.amalto.workbench.models.TreeObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 12 with TreeObject

use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.

the class ConsistencyService method queryServerDigestValue.

public <T> Map<T, WSDigest> queryServerDigestValue(MDMServerDef serverDef, Collection<T> objs) throws XtentisException {
    Map<T, WSDigest> result = new LinkedHashMap<T, WSDigest>();
    TMDMService service = RepositoryWebServiceAdapter.getMDMService(serverDef);
    if (isSupportConsistency(service)) {
        for (T obj : objs) {
            String type = null;
            String objectName = null;
            if (obj instanceof IRepositoryViewObject) {
                IRepositoryViewObject viewObj = (IRepositoryViewObject) obj;
                type = viewObj.getRepositoryObjectType().getKey();
                objectName = viewObj.getLabel();
            } else if (obj instanceof TreeObject) {
                TreeObject treeObj = (TreeObject) obj;
                ERepositoryObjectType repositoryObjectType = RepositoryQueryService.getRepositoryObjectType(treeObj.getType());
                if (repositoryObjectType != null) {
                    type = repositoryObjectType.getKey();
                    objectName = getObjectName(treeObj);
                }
            }
            if (type != null && objectName != null) {
                WSDigest digest = service.getDigest(new WSDigestKey(objectName, type));
                result.put(obj, digest);
            }
        }
    }
    return result;
}
Also used : TMDMService(com.amalto.workbench.webservices.TMDMService) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSDigestKey(com.amalto.workbench.webservices.WSDigestKey) TreeObject(com.amalto.workbench.models.TreeObject) WSDigest(com.amalto.workbench.webservices.WSDigest) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with TreeObject

use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.

the class Bean2EObjUtil method wrapEObjWithTreeObject.

public TreeObject wrapEObjWithTreeObject(EObject eobj) {
    if (eobj instanceof MDMServerObject) {
        MDMServerObject serverObject = (MDMServerObject) eobj;
        Object wsObj = convertFromEObj2Bean(eobj);
        return wrapEObjWithTreeObject(eobj, wsObj);
    }
    return null;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) TreeObject(com.amalto.workbench.models.TreeObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 14 with TreeObject

use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.

the class TreeObjectCheckTreeViewer method initConsistencyData.

private Map<TreeObject, ConsistencyData> initConsistencyData(MDMServerDef serverDef, List<TreeObject> treeObjs) {
    Map<TreeObject, ConsistencyData> map = new HashMap<TreeObject, ConsistencyData>();
    try {
        ConsistencyService consistencyService = ConsistencyService.getInstance();
        Map<TreeObject, WSDigest> serverDigestValues = consistencyService.queryServerDigestValue(serverDef, treeObjs);
        if (treeObjs.size() > 0 && serverDigestValues.isEmpty()) {
            return map;
        }
        for (TreeObject treeObject : treeObjs) {
            ConsistencyData consistencyData = new ConsistencyData();
            WSDigest serverDigestTime = serverDigestValues.get(treeObject);
            consistencyData.setServerDigestTime(serverDigestTime);
            String objName = getTreeObjectName(treeObject);
            ERepositoryObjectType viewType = RepositoryQueryService.getRepositoryObjectType(treeObject.getType());
            if (viewType == null) {
                continue;
            }
            if (viewType == IServerObjectRepositoryType.TYPE_RESOURCE || viewType == IServerObjectRepositoryType.TYPE_JOB || viewType == IServerObjectRepositoryType.TYPE_WORKFLOW) {
                consistencyData.setCompareResult(CompareResultEnum.NOT_SUPPORT);
            } else {
                IRepositoryViewObject viewObj = RepositoryResourceUtil.findViewObjectByName(viewType, objName);
                if (viewObj == null) {
                    consistencyData.setCompareResult(CompareResultEnum.NOT_EXIST_IN_LOCAL);
                } else {
                    consistencyService.updateCurrentDigestValue(viewObj);
                    Item item = viewObj.getProperty().getItem();
                    String ld = consistencyService.getLocalDigestValue(item);
                    String cd = consistencyService.getCurrentDigestValue(item);
                    long localTimestamp = consistencyService.getLocalTimestamp(item);
                    // key
                    String type = viewObj.getRepositoryObjectType().getKey();
                    String objectName = viewObj.getLabel();
                    WSDigestKey key = new WSDigestKey(objectName, type);
                    consistencyData.setLocalDigestTime(new WSDigest(ld, localTimestamp, key));
                    // init compare result;
                    CompareResultEnum result;
                    if (serverDigestTime == null || serverDigestTime.getDigestValue() == null) {
                        result = CompareResultEnum.NOT_EXIST_IN_SERVER;
                    } else {
                        String rd = serverDigestTime.getDigestValue();
                        result = consistencyService.getCompareResult(cd, ld, rd);
                    }
                    consistencyData.setCompareResult(result);
                }
            }
            map.put(treeObject, consistencyData);
        }
    } catch (WebServiceException e) {
        log.error(e.getMessage(), e);
    } catch (XtentisException e) {
        log.error(e.getMessage(), e);
    }
    return map;
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) HashMap(java.util.HashMap) WSDigestKey(com.amalto.workbench.webservices.WSDigestKey) WSDigest(com.amalto.workbench.webservices.WSDigest) ConsistencyService(org.talend.mdm.repository.core.service.ConsistencyService) Item(org.talend.core.model.properties.Item) TreeItem(org.eclipse.swt.widgets.TreeItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TreeObject(com.amalto.workbench.models.TreeObject) CompareResultEnum(org.talend.mdm.repository.core.service.ConsistencyService.CompareResultEnum) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) ConsistencyData(org.talend.mdm.repository.core.service.ConsistencyService.ConsistencyData) XtentisException(com.amalto.workbench.utils.XtentisException)

Example 15 with TreeObject

use of com.amalto.workbench.models.TreeObject in project tmdm-studio-se by Talend.

the class StoredProcedureMainPage method createCompDropTarget.

private void createCompDropTarget() {
    DropTarget dropTarget = new DropTarget(procedureViewer.getTextWidget(), DND.DROP_MOVE | DND.DROP_LINK);
    dropTarget.setTransfer(new TreeObjectTransfer[] { TreeObjectTransfer.getInstance() });
    dropTarget.addDropListener(new DropTargetAdapter() {

        @Override
        public void dragEnter(DropTargetEvent event) {
        }

        @Override
        public void dragLeave(DropTargetEvent event) {
        }

        @Override
        public void dragOver(DropTargetEvent event) {
            event.feedback |= DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL;
        }

        @Override
        public void drop(DropTargetEvent event) {
            if (event.data instanceof TreeObject[]) {
                procedureViewer.getTextWidget().setText(procedureViewer.getTextWidget().getText() + ((TreeObject[]) event.data)[0].getDisplayName());
            }
        }
    });
}
Also used : DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) TreeObject(com.amalto.workbench.models.TreeObject) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DropTarget(org.eclipse.swt.dnd.DropTarget)

Aggregations

TreeObject (com.amalto.workbench.models.TreeObject)66 TreeParent (com.amalto.workbench.models.TreeParent)21 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 ArrayList (java.util.ArrayList)12 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)12 TMDMService (com.amalto.workbench.webservices.TMDMService)6 WSDataModel (com.amalto.workbench.webservices.WSDataModel)5 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)5 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)5 Document (org.dom4j.Document)5 Element (org.dom4j.Element)5 EObject (org.eclipse.emf.ecore.EObject)5 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)5 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IAvailableModel (com.amalto.workbench.availablemodel.IAvailableModel)3 UserInfo (com.amalto.workbench.utils.UserInfo)3 WSDataCluster (com.amalto.workbench.webservices.WSDataCluster)3 WSDigest (com.amalto.workbench.webservices.WSDigest)3 WSDigestKey (com.amalto.workbench.webservices.WSDigestKey)3