Search in sources :

Example 11 with MbengException

use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.

the class SwingFormGenerator method getValue.

private String getValue(MbengNode node) {
    String value = null;
    String dataassoc = node.getAttribute(FormConstants.FORMATTR_DATA);
    MbengNode vnode = dataassoc == null ? null : dataxml.getNode(dataassoc);
    if (vnode != null)
        value = vnode.getValue();
    else
        value = null;
    if (value == null || value.length() == 0) {
        String av = node.getAttribute(FormConstants.FORMATTR_AUTOVALUE);
        if (av != null && av.length() > 0) {
            // String rulename = node.getAttribute(FormConstants.FORMATTR_ID) + "_DEFAULT";
            // try {
            // value = this.evaluateExpression(rulename, av, dataxml);
            // } catch (MbengException e) {
            // // return null if data element is not there
            // // rule syntax error should be detected at design time?
            // value = null;
            // }
            // this makes it the same as JSF version
            value = av;
            try {
                dataxml.setValue(dataassoc, value, FormDataDocument.KIND_FIELD);
            } catch (MbengException e) {
            }
        }
    }
    return value;
}
Also used : MbengException(com.qwest.mbeng.MbengException) MbengNode(com.qwest.mbeng.MbengNode)

Example 12 with MbengException

use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method getTaskInstances.

private List<TaskInstanceVO> getTaskInstances(ProcessVO process, ProcessInstanceVO processInstance, Long activityId, List<TaskInstanceVO> allTaskInstances) throws DataAccessException {
    List<TaskInstanceVO> taskInstances = new ArrayList<>();
    for (TaskInstanceVO taskInstance : allTaskInstances) {
        String secondaryOwner = taskInstance.getSecondaryOwnerType();
        if (OwnerType.DOCUMENT.equals(secondaryOwner) || "EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner)) {
            String formDataString = null;
            if (OwnerType.DOCUMENT.equals(secondaryOwner))
                formDataString = rtinfo.getDocument(taskInstance.getSecondaryOwnerId()).getContent();
            else if ("EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner))
                formDataString = rtinfo.getExternalEventDetails(taskInstance.getSecondaryOwnerId());
            FormDataDocument formDataDoc = new FormDataDocument();
            try {
                formDataDoc.load(formDataString);
                for (ActivityInstanceVO activityInstance : processInstance.getActivityInstances(activityId)) {
                    if (activityInstance.getId().equals(formDataDoc.getActivityInstanceId()))
                        taskInstances.add(taskInstance);
                }
            } catch (MbengException ex) {
                throw new DataAccessException(-1, ex.getMessage(), ex);
            }
        } else {
            // task instance secondary owner is work transition instance
            Long workTransInstId = taskInstance.getSecondaryOwnerId();
            for (WorkTransitionInstanceVO transitionInstance : processInstance.getTransitions()) {
                if (transitionInstance.getTransitionInstanceID().equals(workTransInstId)) {
                    Long transitionId = transitionInstance.getTransitionID();
                    WorkTransitionVO workTrans = process.getWorkTransition(transitionId);
                    if (workTrans == null && process.getSubProcesses() != null) {
                        for (ProcessVO subproc : process.getSubProcesses()) {
                            workTrans = subproc.getWorkTransition(transitionId);
                            if (workTrans != null)
                                break;
                        }
                    }
                    if (workTrans != null && workTrans.getToWorkId().equals(activityId))
                        taskInstances.add(taskInstance);
                }
            }
        }
    }
    return taskInstances;
}
Also used : MbengException(com.qwest.mbeng.MbengException) WorkTransitionInstanceVO(com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO) WorkTransitionVO(com.centurylink.mdw.model.value.work.WorkTransitionVO) ActivityInstanceVO(com.centurylink.mdw.model.value.work.ActivityInstanceVO) TaskInstanceVO(com.centurylink.mdw.model.value.task.TaskInstanceVO) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) FormDataDocument(com.centurylink.mdw.model.FormDataDocument) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 13 with MbengException

use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.

the class JTablePlus method performSorting.

private void performSorting(ActionEvent e) {
    int columnIndex = e.getID();
    boolean descending = columnIndex < 0;
    if (columnIndex < 0)
        columnIndex = -columnIndex - 1;
    else
        columnIndex = columnIndex - 1;
    if (!model.isColumnSortable(columnIndex)) {
        e.setSource(null);
        return;
    }
    String sorton = getColumnName(columnIndex);
    if (sorton == null)
        return;
    if (descending)
        sorton = "-" + sorton;
    MbengNode metanode = datadoc.getNode(datapath + "_META");
    try {
        if (metanode != null)
            datadoc.setValue(metanode, "sort_on", sorton);
    } catch (MbengException e1) {
    }
    String action = paginator + "?action=paging&table=" + datapath + "&meta=" + datapath + "_META&topage=S&sorton=" + sorton;
    call_engine(action);
}
Also used : MbengException(com.qwest.mbeng.MbengException) MbengNode(com.qwest.mbeng.MbengNode)

Example 14 with MbengException

use of com.qwest.mbeng.MbengException in project mdw-designer by CenturyLinkCloud.

the class JTablePlus method setData.

public void setData(FormDataDocument dataxml, String datapath) {
    this.datadoc = dataxml;
    this.datapath = datapath;
    MbengNode datanode = dataxml.getNode(datapath);
    MbengNode metanode = dataxml.getNode(datapath + "_META");
    model.setData(datanode);
    if (metanode != null) {
        String sorton = datadoc.getValue(metanode, "sort_on");
        if (sorton != null) {
            boolean descending = sorton.startsWith("-");
            if (descending)
                sorton = sorton.substring(1);
            setSortingStatus(sorton, descending);
        }
        String selected_str = datadoc.getValue(metanode, "selected");
        if (!StringHelper.isEmpty(selected_str)) {
            String[] rows_str = selected_str.split(",");
            int firstRow = Integer.parseInt(rows_str[0]);
            try {
                if (model.getRowCount() > firstRow) {
                    table.setRowSelectionInterval(firstRow, firstRow);
                    datadoc.setValue(metanode, "selected", rows_str[0]);
                } else
                    datadoc.setValue(metanode, "selected", null);
            } catch (MbengException e) {
            }
        }
        if (rowrange != null) {
            int nrows = model.getRowCount();
            if (nrows == 0) {
                rowrange.setText("No rows");
                button_first.setEnabled(false);
                button_prev.setEnabled(false);
                button_next.setEnabled(false);
                button_last.setEnabled(false);
                button_goto.setEnabled(false);
            } else {
                String v = datadoc.getValue(metanode, "start_row");
                int start_row = v == null ? 1 : Integer.parseInt(v);
                v = datadoc.getValue(metanode, "total_rows");
                int total_rows = v == null ? nrows : Integer.parseInt(v);
                rowrange.setText("" + start_row + " - " + (start_row + nrows - 1) + " of " + total_rows);
                button_first.setEnabled(start_row > 1);
                button_prev.setEnabled(start_row > 1);
                button_next.setEnabled(start_row + nrows - 1 < total_rows);
                button_last.setEnabled(start_row + nrows - 1 < total_rows);
                button_goto.setEnabled(nrows < total_rows);
            }
        }
    }
    // for some reason w/o the following, layout was not done and screen shows blank until resized
    super.doLayout();
    for (int k = this.getComponentCount(); k > 0; k--) {
        Component comp = this.getComponent(k - 1);
        if (comp instanceof Container)
            ((Container) comp).doLayout();
    }
}
Also used : MbengException(com.qwest.mbeng.MbengException) Container(java.awt.Container) MbengNode(com.qwest.mbeng.MbengNode) Component(java.awt.Component)

Aggregations

MbengException (com.qwest.mbeng.MbengException)14 MbengNode (com.qwest.mbeng.MbengNode)6 MbengDocument (com.qwest.mbeng.MbengDocument)3 MbengRuleSet (com.qwest.mbeng.MbengRuleSet)3 MbengRuntime (com.qwest.mbeng.MbengRuntime)3 StreamLogger (com.qwest.mbeng.StreamLogger)3 XmlPath (com.qwest.mbeng.XmlPath)3 HashMap (java.util.HashMap)3 ArrayList (java.util.ArrayList)2 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 FormDataDocument (com.centurylink.mdw.model.FormDataDocument)1 ActivityVO (com.centurylink.mdw.model.value.activity.ActivityVO)1 AttributeVO (com.centurylink.mdw.model.value.attribute.AttributeVO)1 BamMessageDefinition (com.centurylink.mdw.model.value.event.BamMessageDefinition)1 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)1 TaskInstanceVO (com.centurylink.mdw.model.value.task.TaskInstanceVO)1 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)1 WorkTransitionInstanceVO (com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO)1 WorkTransitionVO (com.centurylink.mdw.model.value.work.WorkTransitionVO)1 DomDocument (com.qwest.mbeng.DomDocument)1