Search in sources :

Example 1 with DocumentReferenceTranslator

use of com.centurylink.mdw.common.translator.DocumentReferenceTranslator in project mdw-designer by CenturyLinkCloud.

the class VariableHelper method isDocumentVariable.

/**
 * This is another cheaper way for better guessing whether the variable
 * is a document variable, when variable instance value is available
 * @param vartype
 * @param value variable instance value
 * @return
 */
public static boolean isDocumentVariable(String vartype, String value) {
    VariableTranslator translator;
    VariableTypeVO vo = VariableTypeCache.getVariableTypeVO(vartype);
    if (vo == null)
        return false;
    try {
        Class<?> cl = Class.forName(vo.getTranslatorClass());
        translator = (VariableTranslator) cl.newInstance();
        return (translator instanceof DocumentReferenceTranslator);
    } catch (Exception e) {
        if (value == null)
            return false;
        return value.startsWith("DOCUMENT:");
    }
}
Also used : VariableTypeVO(com.centurylink.mdw.model.value.variable.VariableTypeVO) DocumentReferenceTranslator(com.centurylink.mdw.common.translator.DocumentReferenceTranslator) VariableTranslator(com.centurylink.mdw.common.translator.VariableTranslator)

Example 2 with DocumentReferenceTranslator

use of com.centurylink.mdw.common.translator.DocumentReferenceTranslator in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method isDocumentVariable.

private boolean isDocumentVariable(String type, String value) {
    VariableTranslator translator;
    VariableTypeVO vo = dataAccess.getVariableType(type);
    if (vo == null)
        return false;
    try {
        Class<?> cl = Class.forName(vo.getTranslatorClass());
        translator = (VariableTranslator) cl.newInstance();
        return (translator instanceof DocumentReferenceTranslator);
    } catch (Exception e) {
        if (value == null)
            return false;
        return value.startsWith("DOCUMENT:");
    }
}
Also used : VariableTypeVO(com.centurylink.mdw.model.value.variable.VariableTypeVO) DocumentReferenceTranslator(com.centurylink.mdw.common.translator.DocumentReferenceTranslator) VariableTranslator(com.centurylink.mdw.common.translator.VariableTranslator) JSONException(org.json.JSONException) TranslationException(com.centurylink.mdw.common.exception.TranslationException) AuthenticationException(com.centurylink.mdw.auth.AuthenticationException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ZipException(java.util.zip.ZipException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException)

Example 3 with DocumentReferenceTranslator

use of com.centurylink.mdw.common.translator.DocumentReferenceTranslator in project mdw-designer by CenturyLinkCloud.

the class VariableHelper method isDocumentVariable.

/**
 * Check if the variable type is of a document.
 * Custom variable translators must be loaded from server to make
 * the decision precise.
 *
 * @param vartype
 * @param dao
 * @return
 */
public static boolean isDocumentVariable(String vartype, DesignerDataAccess dao) {
    VariableTranslator translator;
    VariableTypeVO vo = VariableTypeCache.getVariableTypeVO(vartype);
    if (vo == null)
        return false;
    try {
        Class<?> cl = Class.forName(vo.getTranslatorClass());
        translator = (VariableTranslator) cl.newInstance();
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    return (translator instanceof DocumentReferenceTranslator);
}
Also used : VariableTypeVO(com.centurylink.mdw.model.value.variable.VariableTypeVO) DocumentReferenceTranslator(com.centurylink.mdw.common.translator.DocumentReferenceTranslator) VariableTranslator(com.centurylink.mdw.common.translator.VariableTranslator)

Aggregations

DocumentReferenceTranslator (com.centurylink.mdw.common.translator.DocumentReferenceTranslator)3 VariableTranslator (com.centurylink.mdw.common.translator.VariableTranslator)3 VariableTypeVO (com.centurylink.mdw.model.value.variable.VariableTypeVO)3 AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)1 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 TranslationException (com.centurylink.mdw.common.exception.TranslationException)1 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)1 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 RemoteException (java.rmi.RemoteException)1 ZipException (java.util.zip.ZipException)1 XmlException (org.apache.xmlbeans.XmlException)1 JSONException (org.json.JSONException)1