Search in sources :

Example 6 with MDMServerObject

use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.

the class ConsistencyService method calculateDigestValueByObjectResource.

private String calculateDigestValueByObjectResource(Item item) {
    EObject copy = null;
    if (item instanceof ProcessItem) {
        copy = EcoreUtil.copy(((ProcessItem) item).getProcess());
    } else if (item instanceof MDMServerObjectItem) {
        MDMServerObject mdmServerObject = ((MDMServerObjectItem) item).getMDMServerObject();
        copy = EcoreUtil.copy(mdmServerObject);
        // remove server def property
        MDMServerObject copiedMdmObj = (MDMServerObject) copy;
        copiedMdmObj.setLastServerDef(null);
        copiedMdmObj.setLastServerName(null);
        copiedMdmObj.setCurrentDigestValue(null);
        copiedMdmObj.setDigestValue(null);
        // restore the timestamp to default
        copiedMdmObj.setTimestamp(0L);
    } else {
        // unsupport to caculate object md5 which not belong to MDM
        throw new UnsupportedOperationException();
    }
    if (copy != null) {
        // 
        Resource resource = new SortResourceImpl();
        resource.getContents().add(copy);
        return calculateDigestValueByEMFResource(resource);
    }
    return null;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) Resource(org.eclipse.emf.ecore.resource.Resource) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 7 with MDMServerObject

use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method getLastServerDef.

/**
 * @param item
 * @return A decrypted serverDef
 */
public static MDMServerDef getLastServerDef(Item item) {
    if (item != null) {
        if (item instanceof MDMServerObjectItem) {
            MDMServerObject mdmServerObject = ((MDMServerObjectItem) item).getMDMServerObject();
            String lastServerName = mdmServerObject.getLastServerName();
            if (lastServerName == null) {
                MDMServerDef lastServerDef = mdmServerObject.getLastServerDef();
                if (lastServerDef != null) {
                    lastServerName = lastServerDef.getName();
                }
            }
            if (lastServerName != null) {
                return ServerDefService.findServerDefByName(lastServerName);
            }
        } else {
            Property property = item.getProperty();
            if (property != null) {
                Object value = property.getAdditionalProperties().get(PROP_LAST_SERVER_DEF);
                if (value != null) {
                    return ServerDefService.findServerDefByName((String) value);
                }
            }
        }
    }
    return null;
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) Property(org.talend.core.model.properties.Property) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 8 with MDMServerObject

use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method setLastServerDef.

/**
 * @param item
 * @param def need A decrypted serverDef
 */
@SuppressWarnings("unchecked")
public static void setLastServerDef(Item item, MDMServerDef def) {
    if (item == null) {
        return;
    }
    if (item instanceof MDMServerObjectItem) {
        MDMServerObject mdmServerObject = ((MDMServerObjectItem) item).getMDMServerObject();
        mdmServerObject.setLastServerName(def != null ? def.getName() : null);
        // Not use lastServerDef property any more
        mdmServerObject.setLastServerDef(null);
        return;
    }
    Property property = item.getProperty();
    if (property != null) {
        if (def != null) {
            property.getAdditionalProperties().put(PROP_LAST_SERVER_DEF, def.getName());
        } else {
            property.getAdditionalProperties().remove(PROP_LAST_SERVER_DEF);
        }
    }
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) Property(org.talend.core.model.properties.Property) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 9 with MDMServerObject

use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject 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 10 with MDMServerObject

use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.

the class CommonMdmImportHandler method update.

protected void update(IRepositoryViewObject object, ImportItem selectedImportItem) throws PersistenceException {
    Property property = object.getProperty();
    Item item = property.getItem();
    boolean needSave = false;
    if (item instanceof MDMServerObjectItem) {
        MDMServerObject serverObj = ((MDMServerObjectItem) item).getMDMServerObject();
        if (serverObj.getLastServerName() != null) {
            serverObj.setLastServerName(null);
            needSave = true;
        }
        if (serverObj.getLastServerDef() != null) {
            serverObj.setLastServerDef(null);
            needSave = true;
        }
    } else {
        EMap<?, ?> additionalProperties = property.getAdditionalProperties();
        if (additionalProperties != null) {
            additionalProperties.remove(RepositoryResourceUtil.PROP_LAST_SERVER_DEF);
            needSave = true;
        }
    }
    if (needSave) {
        factory.save(item, true);
    }
    if (selectedImportItem.isValid()) {
        // $NON-NLS-1$
        String[] split = selectedImportItem.getLabel().split(" ");
        String name = split.length > 0 ? split[0] : null;
        if (name != null) {
            CommandManager.getInstance().pushCommand(ICommand.CMD_ADD, selectedImportItem.getItemId(), name);
        }
    }
    // update cache
    ContainerCacheService.put(object);
}
Also used : ReferenceFileItem(org.talend.core.model.properties.ReferenceFileItem) Item(org.talend.core.model.properties.Item) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) Property(org.talend.core.model.properties.Property) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Aggregations

MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)37 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)33 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)19 Item (org.talend.core.model.properties.Item)13 TreeObject (com.amalto.workbench.models.TreeObject)11 Property (org.talend.core.model.properties.Property)11 PersistenceException (org.talend.commons.exception.PersistenceException)9 Test (org.junit.Test)7 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)7 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)7 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)7 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 LoginException (org.talend.commons.exception.LoginException)6 EObject (org.eclipse.emf.ecore.EObject)5 ArrayList (java.util.ArrayList)4 FolderItem (org.talend.core.model.properties.FolderItem)4 TMDMService (com.amalto.workbench.webservices.TMDMService)3 LinkedList (java.util.LinkedList)3 ItemState (org.talend.core.model.properties.ItemState)3