use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class AbstractNodeCheckTreeViewer method isExist.
private boolean isExist(TreeObject treeObj) {
if (treeObj instanceof TreeParent) {
return false;
}
int type = treeObj.getType();
ERepositoryObjectType rType = RepositoryQueryService.getRepositoryObjectType(type);
if (rType == null) {
return false;
}
List<IRepositoryViewObject> children = RepositoryResourceUtil.findAllViewObjectsWithDeleted(rType);
if (children == null) {
return false;
}
String treeObjName = treeObj.getName();
if (type == TreeObject.PICTURES_RESOURCE) {
// $NON-NLS-1$
int index = treeObjName.indexOf("-");
if (index > 0) {
treeObjName = treeObjName.substring(index + 1);
}
}
for (IRepositoryViewObject viewObject : children) {
Item item = viewObject.getProperty().getItem();
if (item instanceof MDMServerObjectItem) {
MDMServerObject serverObj = ((MDMServerObjectItem) item).getMDMServerObject();
String name = serverObj.getName();
if (type == TreeObject.WORKFLOW_PROCESS) {
// $NON-NLS-1$
name = name + "_" + viewObject.getVersion();
}
if (type == TreeObject.PICTURES_RESOURCE) {
// $NON-NLS-1$ //$NON-NLS-2$
name = name + "_" + viewObject.getVersion() + "." + ((WSResourceE) serverObj).getFileExtension();
}
if (serverObj != null && treeObjName.equals(name)) {
return true;
}
}
}
return false;
}
use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class RepositoryQueryService method findAllCustomFormPks.
public static List<String> findAllCustomFormPks() {
List<IRepositoryViewObject> viewObjects = RepositoryResourceUtil.findAllViewObjects(IServerObjectRepositoryType.TYPE_CUSTOM_FORM);
List<String> names = new LinkedList<String>();
if (viewObjects != null) {
for (IRepositoryViewObject viewObj : viewObjects) {
Item item = viewObj.getProperty().getItem();
if (item instanceof MDMServerObjectItem) {
MDMServerObject sObject = ((MDMServerObjectItem) item).getMDMServerObject();
if (sObject instanceof WSCustomFormE) {
WSCustomFormE sForm = (WSCustomFormE) sObject;
String name = sForm.getDatamodel() + IConstants.ITEM_PK_SPLIT + sForm.getEntity() + IConstants.ITEM_PK_SPLIT + sForm.getName();
if (name != null) {
names.add(name);
} else {
names.add(viewObj.getLabel());
}
}
}
// names[i]=viewObj.getLabel();
}
}
return names;
}
use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class OpenObjectAction method openItem.
private void openItem(IRepositoryViewObject viewObject) {
Item item = viewObject.getProperty().getItem();
item = RepositoryResourceUtil.assertItem(item);
IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(item);
if (configuration != null) {
IRepositoryNodeActionProvider actionProvider = configuration.getActionProvider();
if (actionProvider != null) {
IRepositoryViewEditorInput editorInput = actionProvider.getOpenEditorInput(viewObject);
if (editorInput != null) {
if (page == null) {
this.page = getCommonViewer().getCommonNavigator().getSite().getWorkbenchWindow().getActivePage();
}
// do extra action
MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
if (!checkMissingJar(serverObject)) {
return;
}
boolean selected = doSelectServer(item, editorInput);
if (!selected) {
return;
}
try {
// svn lock
ERepositoryStatus status = factory.getStatus(item);
boolean isEditable = factory.isEditableAndLockIfPossible(item);
if (isEditable) {
getCommonViewer().refresh(viewObject);
}
//
editorInput.setReadOnly(status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.READ_ONLY || !isEditable);
if (!editorInput.isReadOnly()) {
editorInput.setReadOnly(item.getState().isDeleted());
}
updateEditorInputVersionInfo(editorInput, viewObject);
activeEditor = this.page.openEditor(editorInput, editorInput.getEditorId());
if (marker != null) {
IDE.gotoMarker(activeEditor, marker);
}
} catch (PartInitException e) {
log.error(e.getMessage(), e);
}
} else {
AbstractRepositoryAction openAction = actionProvider.getOpenAction(viewObject);
if (openAction != null) {
openAction.selectionChanged(getStructuredSelection());
openAction.run();
}
}
}
}
}
use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class RenameObjectAction method doRun.
@Override
protected void doRun() {
Object obj = getSelectedObject().get(0);
if (obj instanceof IRepositoryViewObject) {
IRepositoryViewObject viewObj = (IRepositoryViewObject) obj;
MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
MDMServerObject serverObject = item.getMDMServerObject();
IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(item);
if (configuration != null) {
ERepositoryObjectType type = configuration.getResourceProvider().getRepositoryObjectType(item);
IRepositoryViewObject parentViewObj = ContainerCacheService.get(type, item.getState().getPath());
try {
if (serverObject != null) {
String oldName = serverObject.getName();
String newName = showRenameDlg(type, (ContainerItem) parentViewObj.getProperty().getItem(), oldName);
if (newName != null && factory.isEditableAndLockIfPossible(item)) {
serverObject.setName(newName);
viewObj.getProperty().setLabel(newName);
viewObj.getProperty().setDisplayName(newName);
factory.save(viewObj.getProperty().getItem(), false);
MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(viewObj);
if (lastServerDef != null) {
CommandManager.getInstance().pushCommand(ICommand.CMD_RENAME, viewObj.getId(), new String[] { oldName, newName });
}
}
}
commonViewer.refresh(obj);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} finally {
try {
factory.unlock(item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} catch (LoginException e) {
log.error(e.getMessage(), e);
}
}
}
}
}
use of org.talend.mdm.repository.model.mdmserverobject.MDMServerObject in project tmdm-studio-se by Talend.
the class MarkNodeAsNewAction method run.
public void run(Project project) {
if (project == null) {
return;
}
List<ERepositoryObjectType> types = new ArrayList<ERepositoryObjectType>();
types.add(IServerObjectRepositoryType.TYPE_DATAMODEL);
types.add(IServerObjectRepositoryType.TYPE_CUSTOM_FORM);
types.add(IServerObjectRepositoryType.TYPE_DATACLUSTER);
types.add(IServerObjectRepositoryType.TYPE_MENU);
types.add(IServerObjectRepositoryType.TYPE_RESOURCE);
types.add(IServerObjectRepositoryType.TYPE_ROLE);
types.add(IServerObjectRepositoryType.TYPE_ROUTINGRULE);
types.add(IServerObjectRepositoryType.TYPE_STOREPROCEDURE);
types.add(IServerObjectRepositoryType.TYPE_TRANSFORMERV2);
types.add(IServerObjectRepositoryType.TYPE_VIEW);
types.add(IServerObjectRepositoryType.TYPE_WORKFLOW);
types.add(ERepositoryObjectType.PROCESS);
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
for (ERepositoryObjectType type : types) {
List<IRepositoryViewObject> objects;
try {
objects = factory.getAll(project, type);
} catch (PersistenceException e1) {
log.error(e1.getLocalizedMessage(), e1);
return;
}
if (objects != null && objects.size() > 0) {
for (IRepositoryViewObject object : objects) {
Property property = object.getProperty();
Item item = property.getItem();
boolean needRemoved = false;
MDMServerObject serverObj = null;
if (item instanceof MDMServerObjectItem) {
serverObj = ((MDMServerObjectItem) item).getMDMServerObject();
if (serverObj.getLastServerName() != null || serverObj.getLastServerDef() != null) {
needRemoved = true;
}
} else {
Object value = property.getAdditionalProperties().get(RepositoryResourceUtil.PROP_LAST_SERVER_DEF);
if (value != null) {
needRemoved = true;
}
}
if (needRemoved) {
RepositoryResourceUtil.setLastServerDef(item, null);
try {
factory.save(project, item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
}
String name = (serverObj == null || serverObj.getName() == null) ? item.getProperty().getLabel() : serverObj.getName();
// flagged as new
CommandManager.getInstance().pushCommand(ICommand.CMD_ADD, item.getProperty().getId(), name);
}
}
}
}
Aggregations