Search in sources :

Example 11 with MDMServerObjectItem

use of org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem 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 12 with MDMServerObjectItem

use of org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem 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 13 with MDMServerObjectItem

use of org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem 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)

Example 14 with MDMServerObjectItem

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

the class DataModelActionProvider method getActions.

@Override
public List<AbstractRepositoryAction> getActions(IRepositoryViewObject viewObj) {
    List<AbstractRepositoryAction> actions = super.getActions(viewObj);
    if (RepositoryResourceUtil.hasContainerItem(viewObj, FolderType.SYSTEM_FOLDER_LITERAL, FolderType.FOLDER_LITERAL)) {
        addAction(actions, addAction, viewObj);
    }
    if (viewObj.getProperty().getItem() instanceof MDMServerObjectItem) {
        addAction(actions, renameAction, viewObj);
        // validate
        if (validateAction != null) {
            addAction(actions, validateAction, viewObj);
        }
        // deploy
        addAction(actions, deployToAction, viewObj);
        addAction(actions, deployToLastServerAction, viewObj);
        addAction(actions, deployAnotherToAction, viewObj);
        addAction(actions, undeployAction, viewObj);
        IDataModelActionProviderExAdapter exAdapter = getExAdapter();
        if (exAdapter != null && exAdapter.getActions() != null) {
            for (AbstractRepositoryAction action : exAdapter.getActions()) {
                addAction(actions, action, viewObj);
            }
        }
    }
    addAction(actions, deployAllAction, viewObj);
    return actions;
}
Also used : AbstractRepositoryAction(org.talend.mdm.repository.core.AbstractRepositoryAction) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)

Example 15 with MDMServerObjectItem

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

the class RepositoryProcessesNamesHolder method getExternalInfo.

@Override
public String[] getExternalInfo() {
    List<IRepositoryViewObject> viewObjs = RepositoryResourceUtil.findAllViewObjects(IServerObjectRepositoryType.TYPE_TRANSFORMERV2);
    String[] names = new String[viewObjs.size()];
    int i = 0;
    for (IRepositoryViewObject viewObj : viewObjs) {
        Property prop = viewObj.getProperty();
        if (prop.getItem() instanceof MDMServerObjectItem) {
            MDMServerObject serverObject = ((MDMServerObjectItem) prop.getItem()).getMDMServerObject();
            if (serverObject != null) {
                names[i] = serverObject.getName();
            }
        } else {
            names[i] = prop.getLabel();
        }
        i++;
    }
    return names;
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Aggregations

MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)50 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)33 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)28 Item (org.talend.core.model.properties.Item)22 Property (org.talend.core.model.properties.Property)15 PersistenceException (org.talend.commons.exception.PersistenceException)13 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)12 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)11 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)10 LoginException (org.talend.commons.exception.LoginException)9 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)9 TreeObject (com.amalto.workbench.models.TreeObject)7 Test (org.junit.Test)7 TMDMService (com.amalto.workbench.webservices.TMDMService)6 LinkedList (java.util.LinkedList)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 BusinessException (org.talend.commons.exception.BusinessException)5 FolderItem (org.talend.core.model.properties.FolderItem)5 ProcessItem (org.talend.core.model.properties.ProcessItem)5 ArrayList (java.util.ArrayList)4