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;
}
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);
}
}
}
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);
}
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;
}
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;
}
Aggregations