use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.
the class UpdateLastServerService method updateLastServerDefInfo.
public void updateLastServerDefInfo(Object serverDef, IRepositoryViewObject ViewObject) {
if (serverDef == null || ViewObject == null || !(serverDef instanceof MDMServerDef)) {
return;
}
CommandManager cmdManager = CommandManager.getInstance();
DeployService deployService = DeployService.getInstance();
ICommand deployCmd = cmdManager.getNewCommand(ICommand.CMD_MODIFY);
deployCmd.init(ViewObject);
// $NON-NLS-1$ //$NON-NLS-2$
MultiStatus mStatus = new MultiStatus("PLUGIN_ID", Status.OK, "", null);
// $NON-NLS-1$
DeployStatus deployStatus = DeployStatus.getOKStatus(deployCmd, "");
mStatus.add(deployStatus);
cmdManager.removeCommandStack(deployCmd, ICommand.PHASE_DEPLOY);
deployService.pushRestoreCommand(cmdManager, deployCmd, (MDMServerDef) serverDef);
deployService.updateLastServer(mStatus, new NullProgressMonitor());
}
use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.
the class OpenObjectAction method doOpen.
public boolean doOpen() {
List<Object> sels = getSelectedObject();
if (selObjects != null) {
sels = selObjects;
}
if (sels.isEmpty()) {
return false;
}
Object obj = sels.get(0);
if (obj instanceof IRepositoryViewObject) {
if (obj instanceof WSRootRepositoryObject) {
return false;
}
IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
Item item = viewObject.getProperty().getItem();
if (item instanceof ContainerItem) {
if (viewObject.getRepositoryObjectType().equals(IServerObjectRepositoryType.TYPE_SERVICECONFIGURATION)) {
// service
boolean checkMissingJar = MissingJarService.getInstance().checkMissingJar(true);
if (!checkMissingJar) {
return false;
}
// configuration
MDMServerDef serverDef = openServerDialog(null);
openServiceConfig(serverDef);
} else {
getCommonViewer().expandToLevel(obj, 1);
}
} else {
IEditorReference editorRef = RepositoryResourceUtil.isOpenedInEditor(viewObject);
if (editorRef != null) {
if (page == null) {
page = getCommonViewer().getCommonNavigator().getSite().getWorkbenchWindow().getActivePage();
}
if (page != null) {
page.bringToTop(editorRef.getPart(false));
}
if (marker != null) {
IDE.gotoMarker(editorRef.getEditor(true), marker);
}
return false;
} else {
openItem(viewObject);
return true;
}
}
}
return true;
}
use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.
the class RemoveFromServerAction method doRun.
protected void doRun() {
SelectServerDefDialog dialog = new SelectServerDefDialog(getShell());
if (dialog.open() == IDialogConstants.OK_ID) {
// save editors
LockedDirtyObjectDialog lockDirtyDialog = new LockedDirtyObjectDialog(getShell(), Messages.AbstractDeployAction_promptToSaveEditors, getSelectedRepositoryViewObject());
if (lockDirtyDialog.needShowDialog() && lockDirtyDialog.open() == IDialogConstants.CANCEL_ID) {
return;
}
lockDirtyDialog.saveDirtyObjects();
// remove
MDMServerDef serverDef = dialog.getSelectedServerDef();
List<AbstractDeployCommand> commands = new LinkedList<AbstractDeployCommand>();
CommandManager commandManager = CommandManager.getInstance();
for (Object obj : getSelectedObject()) {
IRepositoryViewObject viewObj = (IRepositoryViewObject) obj;
ICommand deleteCommand = commandManager.getNewCommand(ICommand.CMD_DELETE);
deleteCommand.init(viewObj);
commands.add((AbstractDeployCommand) deleteCommand);
}
//
IStatus status = DeployService.getInstance().runCommands(commands, serverDef);
if (status.isMultiStatus()) {
showDeployStatus(status);
}
}
}
use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef 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.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.
the class DeployAllAction method runWithType.
public void runWithType(ERepositoryObjectType type) {
DeployAllDialog dialog = new DeployAllDialog(getShell(), type);
if (dialog.open() == IDialogConstants.OK_ID) {
List<AbstractDeployCommand> selectededCommands = dialog.getSelectedCommands();
if (selectededCommands.size() >= 0) {
DeployService deployService = DeployService.getInstance();
deployViewObject = deployService.getDeployViewObject(selectededCommands);
// validate object
IModelValidateResult validateResult = deployService.validateModel(deployViewObject);
int selectedButton = validateResult.getSelectedButton();
if (selectedButton == IModelValidationService.BUTTON_CANCEL) {
return;
}
List<IRepositoryViewObject> validObjects = validateResult.getValidObjects(selectedButton);
List<IRepositoryViewObject> invalidObjects = validateResult.getInvalidObjects(selectedButton);
//
MDMServerDef serverDef = dialog.getServerDef();
try {
// consistency check
ConsistencyCheckResult consistencyCheckResult = deployService.checkConsistency(serverDef, validObjects, selectededCommands);
if (consistencyCheckResult.isCanceled()) {
return;
} else {
validObjects = consistencyCheckResult.getToDeployObjects();
}
deployService.removeInvalidCommands(invalidObjects, selectededCommands);
deployService.removeInvalidCommands(consistencyCheckResult.getToSkipObjects(), selectededCommands);
// save editors
LockedDirtyObjectDialog lockDirtyDialog = new LockedDirtyObjectDialog(getShell(), Messages.AbstractDeployAction_promptToSaveEditors, validObjects);
if (lockDirtyDialog.needShowDialog() && lockDirtyDialog.open() == IDialogConstants.CANCEL_ID) {
return;
}
lockDirtyDialog.saveDirtyObjects();
// insert impact dialog
List<AbstractDeployCommand> canceledCommandAfterImpactAnalysis = new LinkedList<AbstractDeployCommand>(selectededCommands);
try {
Map<IRepositoryViewObject, ImpactOperation> analyzeModelImpact = ModelImpactAnalyseService.analyzeCommandImpact(serverDef, selectededCommands);
Map<IRepositoryViewObject, ICommandParameter> paramMap = null;
if (analyzeModelImpact != null) {
ModelImpactAnalyseService.shrinkDeployCommands(analyzeModelImpact, selectededCommands);
paramMap = ModelImpactAnalyseService.convertToParameters(analyzeModelImpact);
CommandManager.getInstance().attachParameterToCommand(selectededCommands, paramMap);
}
canceledCommandAfterImpactAnalysis.removeAll(selectededCommands);
} catch (InterruptedException ex) {
return;
}
IStatus status = deployService.runCommands(selectededCommands, serverDef);
// update consistency value
try {
deployService.updateServerConsistencyStatus(serverDef, status);
} catch (XtentisException e) {
log.error(e.getMessage(), e);
} catch (WebServiceException e) {
log.error(e.getMessage(), e);
}
// add canceled object to status
deployService.generateValidationFailedDeployStatus(status, invalidObjects);
deployService.generateConsistencyCancelDeployStatus(status, consistencyCheckResult.getToSkipObjects().toArray(new IRepositoryViewObject[0]));
for (AbstractDeployCommand cmd : canceledCommandAfterImpactAnalysis) {
deployService.generateConsistencyCancelDeployStatus(status, cmd.getViewObject());
}
//
updateChangedStatus(status);
if (status.isMultiStatus()) {
showDeployStatus(status);
}
updateLastServer(status, new NullProgressMonitor());
} catch (Exception e) {
String url = // $NON-NLS-1$
serverDef.getProtocol() + serverDef.getHost() + ":" + serverDef.getPort() + serverDef.getPath();
String title = Messages.bind(Messages.Server_cannot_connected, url);
MessageDialog.openError(getShell(), title, Messages.AbstractDataClusterAction_ConnectFailed);
}
}
}
}
Aggregations