use of com.centurylink.mdw.model.value.attribute.RuleSetVO in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method upgradeAssets.
/**
* Replace obsolete implementors, and other assets (see help doc
* upgradeAssetsDuringImport.html).
*/
public void upgradeAssets(WorkflowPackage packageVersion) throws DataAccessException, IOException {
boolean packageUpdated = false;
PackageVO packageVO = packageVersion.getPackageVO();
List<ProcessVO> processVOs = packageVO.getProcesses();
// update activity implementors
List<ProcessVO> newProcs = new ArrayList<>();
for (ProcessVO processVO : processVOs) {
boolean processUpdated = false;
ProcessVO newProc = dataAccess.getDesignerDataAccess().getProcess(processVO.getProcessId(), processVO);
List<ActivityVO> activities = newProc.getActivities();
if (activities != null) {
for (ActivityVO activityVO : activities) {
if (new ActivityUpgrader(activityVO).doUpgrade())
processUpdated = true;
}
if (newProc.getSubProcesses() != null) {
for (ProcessVO subproc : newProc.getSubProcesses()) {
if (subproc.getActivities() != null) {
for (ActivityVO subprocActivity : subproc.getActivities()) {
if (new ActivityUpgrader(subprocActivity).doUpgrade())
processUpdated = true;
}
}
}
}
}
// update variable types
List<VariableVO> variables = newProc.getVariables();
if (variables != null) {
for (VariableVO variableVO : variables) {
String variableType = variableVO.getVariableType();
String updatedVariableType = Compatibility.getVariableType(variableType);
if (!updatedVariableType.equals(variableType)) {
variableVO.setVariableType(updatedVariableType);
processUpdated = true;
}
}
}
if (processUpdated) {
int processVersion = newProc.getVersion();
processVersion++;
newProc.setVersion(processVersion);
packageUpdated = true;
}
newProcs.add(newProc);
}
// Set old activity implementors in the package to hidden
List<ActivityImplementorVO> activityImplementorVOs = packageVO.getImplementors();
for (ActivityImplementorVO activityImplementorVO : activityImplementorVOs) {
String activityImplClassName = activityImplementorVO.getImplementorClassName();
if (Compatibility.isOldImplementor(activityImplClassName)) {
activityImplementorVO.setHidden(true);
packageUpdated = true;
}
}
if (packageUpdated) {
// update with new assets for saving
packageVO.setProcesses(newProcs);
List<RuleSetVO> newRuleSets = new ArrayList<>();
for (RuleSetVO ruleSet : packageVO.getRuleSets()) newRuleSets.add(getDesignerDataAccess().getRuleSet(ruleSet.getId()));
packageVO.setRuleSets(newRuleSets);
int version = packageVersion.getVersion();
version++;
packageVersion.setVersion(version);
// avoid forcing version
packageVersion.setExported(false);
// increment on save
packageVersion.syncProcesses();
getDesignerDataAccess().savePackage(packageVO, ProcessPersister.PersistType.IMPORT);
}
}
use of com.centurylink.mdw.model.value.attribute.RuleSetVO in project mdw-designer by CenturyLinkCloud.
the class WorkflowAsset method resourceChanged.
/**
* Change listener so we'll know when the resource is changed in the
* workspace.
*/
public void resourceChanged(IResourceChangeEvent event) {
if (isForceExternalEditor())
return;
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
final IFile file = getAssetFile();
IResourceDelta rootDelta = event.getDelta();
IResourceDelta assetDelta = rootDelta.findMember(file.getFullPath());
if (assetDelta != null && assetDelta.getKind() == IResourceDelta.CHANGED && (assetDelta.getFlags() & IResourceDelta.CONTENT) != 0) {
// the file has been changed
final Display display = Display.getCurrent();
if (display != null) {
display.syncExec(new Runnable() {
public void run() {
if (isRawEdit()) {
if (getProject().isReadOnly())
MessageDialog.openWarning(display.getActiveShell(), "Not Editable", "Your changes to " + getFile().getName() + " will be overwritten the next time project '" + getProject().getLabel() + "' is refreshed.");
} else {
if (!isUserAuthorized(UserRoleVO.ASSET_DESIGN)) {
MessageDialog.openWarning(display.getActiveShell(), "Can't Update " + getTitle(), "You're not authorized to update '" + getLabel() + "'\nin workflow project '" + getProject().getName() + "'.");
return;
} else if (!isLockedToUser()) {
MessageDialog.openWarning(display.getActiveShell(), "Can't Update " + getTitle(), "Resource '" + getLabel() + "' is not locked by you, so updates are not allowed.");
return;
}
}
if (isBinary())
encodeAndSetContent(PluginUtil.readFile(file));
else
setContent(new String(PluginUtil.readFile(file)));
Increment versionIncrement = Increment.Overwrite;
int previousVersion = getVersion();
String versionComment = null;
if (getProject().checkRequiredVersion(5, 0)) {
VersionableSaveDialog saveDialog = new VersionableSaveDialog(display.getActiveShell(), WorkflowAsset.this);
int res = saveDialog.open();
if (res == VersionableSaveDialog.CANCEL) {
if (isRawEdit()) {
String message = "Version for '" + WorkflowAsset.this.getName() + "' remains " + WorkflowAsset.this.getVersionLabel();
MessageDialog.openInformation(display.getActiveShell(), WorkflowAsset.this.getTitle() + " Overwrite", message);
return;
} else {
String message = "Database save for '" + WorkflowAsset.this.getName() + "' was canceled.\nTemp file changes were not persisted.";
MessageDialog.openWarning(display.getActiveShell(), WorkflowAsset.this.getTitle() + " Not Saved", message);
return;
}
}
versionIncrement = saveDialog.getVersionIncrement();
if (versionIncrement != Increment.Overwrite) {
setVersion(versionIncrement == Increment.Major ? getNextMajorVersion() : getNextMinorVersion());
versionComment = saveDialog.getVersionComment();
}
}
if (isRawEdit()) {
if (versionIncrement == Increment.Overwrite) {
// just fire cache refresh
if (!getProject().isRemote())
getProject().getDesignerProxy().getCacheRefresh().fireRefresh(RuleSetVO.JAVA.equals(getLanguage()));
} else {
setRevisionComment(versionComment);
getProject().getDesignerProxy().saveWorkflowAssetWithProgress(WorkflowAsset.this, false);
fireElementChangeEvent(ChangeType.VERSION_CHANGE, getVersion());
}
} else {
try {
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
boolean keepLocked = prefsStore.getBoolean(PreferenceConstants.PREFS_KEEP_RESOURCES_LOCKED_WHEN_SAVING);
if (versionIncrement != Increment.Overwrite) {
RuleSetVO prevVO = new RuleSetVO(WorkflowAsset.this.getRuleSetVO());
prevVO.setId(getId());
prevVO.setVersion(previousVersion);
setComment(versionComment);
if (!isInDefaultPackage()) {
getPackage().removeAsset(WorkflowAsset.this);
getProject().getUnpackagedWorkflowAssets().add(new WorkflowAsset(prevVO, getProject().getDefaultPackage()));
}
RunnerResult result = getProject().getDesignerProxy().createNewWorkflowAsset(WorkflowAsset.this, keepLocked);
if (result.getStatus() == RunnerStatus.SUCCESS) {
getRuleSetVO().setPrevVersion(prevVO);
fireElementChangeEvent(ChangeType.VERSION_CHANGE, getVersion());
} else if (result.getStatus() == RunnerStatus.DISALLOW) {
// deregister since save never
// happened
WorkflowAssetFactory.deRegisterAsset(WorkflowAsset.this);
}
} else {
getProject().getDesignerProxy().saveWorkflowAssetWithProgress(WorkflowAsset.this, keepLocked);
fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, null);
}
if (!keepLocked)
fireElementChangeEvent(ChangeType.PROPERTIES_CHANGE, null);
} catch (Exception ex) {
PluginMessages.uiError(ex, "Save Definition Doc", getProject());
}
}
}
});
}
}
}
}
use of com.centurylink.mdw.model.value.attribute.RuleSetVO in project mdw-designer by CenturyLinkCloud.
the class DesignerPage method saveResourceSub.
public Long saveResourceSub(RuleSetVO ruleset, boolean asNewVersion, boolean keeplock) {
try {
if (asNewVersion) {
RuleSetVO newRuleSet = new RuleSetVO();
newRuleSet.setId(-1L);
newRuleSet.setLanguage(ruleset.getLanguage());
newRuleSet.setVersion(ruleset.getVersion() + 1);
newRuleSet.setName(ruleset.getName());
newRuleSet.setRuleSet(ruleset.getRuleSet());
// set old ruleset as if it is not loaded
ruleset.setRuleSet(null);
// not saved to database, but
ruleset.setModifyingUser(null);
// should be ok
ruleset = newRuleSet;
}
ruleset.setModifyingUser(keeplock ? frame.getCuid() : null);
Long id = frame.dao.saveRuleSet(ruleset);
if (ruleset.getId() <= 0L)
ruleset.setId(id);
if (serverIsRunning(true))
frame.dao.refreshServerCaches("RuleSetCache");
return id;
} catch (Exception ex) {
ex.printStackTrace();
showError(this, "Save resource failed", ex);
return null;
}
}
use of com.centurylink.mdw.model.value.attribute.RuleSetVO in project mdw-designer by CenturyLinkCloud.
the class DesignerDataModel method getRuleSets.
public List<RuleSetVO> getRuleSets() {
List<RuleSetVO> ret = new ArrayList<RuleSetVO>();
for (String key : rulesets.keySet()) {
RuleSetVO ruleset = rulesets.get(key);
ret.add(ruleset);
}
return ret;
}
use of com.centurylink.mdw.model.value.attribute.RuleSetVO in project mdw-designer by CenturyLinkCloud.
the class DesignerDataModel method removeRuleSet.
public void removeRuleSet(RuleSetVO ruleSetVO, boolean allVersions) {
String key = getResourceKey(ruleSetVO);
RuleSetVO lead = rulesets.get(key);
if (lead != null) {
// null for task templates
if (allVersions) {
rulesets.remove(key);
while (lead != null) {
rulesetsById.remove(lead.getId());
lead = lead.getPrevVersion();
}
} else {
// remove latest version
rulesetsById.remove(lead.getId());
if (lead.getPrevVersion() == null)
rulesets.remove(key);
else {
lead = lead.getPrevVersion();
lead.setNextVersion(null);
rulesets.put(key, lead);
}
}
}
}
Aggregations