use of com.centurylink.mdw.model.value.variable.DocumentVO in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method getVariableValue.
/**
* Must be called from the UI thread.
*/
public String getVariableValue(final Shell shell, final VariableInstanceInfo varInstInfo, final boolean tryServer) {
final StringBuilder valueHolder = new StringBuilder();
BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
public void run() {
String value = varInstInfo.getStringValue();
if (value != null) {
boolean isDoc = isDocumentVariable(varInstInfo.getType(), value);
if (isDoc) {
DocumentReference docRef = new DocumentReference(value);
DocumentVO docVo = getDocument(docRef);
if (docVo != null) {
value = docVo.getContent();
boolean isJavaObj = Object.class.getName().equals(varInstInfo.getType());
if (isJavaObj) {
try {
value = new JavaObjectTranslator().realToObject(value).toString();
} catch (TranslationException ex) {
if (MdwPlugin.getSettings().isLogConnectErrors())
PluginMessages.log(ex);
if (tryServer) {
try {
String path = "DocumentValues/" + docRef.getDocumentId();
if (!project.checkRequiredVersion(6, 1, 1))
path = "DocumentValue?id=" + docRef.getDocumentId() + "&type=" + varInstInfo.getType() + "&format=text";
value = getRestfulServer().invokeResourceService(path);
} catch (Exception ex2) {
throw new RuntimeException(ex2.getMessage(), ex2);
}
} else {
value = "<Double-click to retrieve>";
}
}
}
}
}
valueHolder.append(value);
}
}
});
return valueHolder.toString();
}
use of com.centurylink.mdw.model.value.variable.DocumentVO in project mdw-designer by CenturyLinkCloud.
the class RuntimeDataAccessRest method getDocument.
public DocumentVO getDocument(Long documentId) throws DataAccessException {
try {
String pathWithArgs = "DocumentValues/" + documentId;
if (!getServer().isSchemaVersion61())
pathWithArgs = "DocumentValue?format=json&id=" + documentId;
String response = getServer().invokeResourceServiceRaw(pathWithArgs);
DocumentVO docVO = new DocumentVO();
docVO.setContent(response);
docVO.setDocumentId(documentId);
return docVO;
} catch (IOException ex) {
throw new DataAccessOfflineException(ex.getMessage(), ex);
} catch (Exception ex) {
throw new DataAccessException(ex.getMessage(), ex);
}
}
Aggregations