Search in sources :

Example 1 with RuntimeDataAccess

use of com.centurylink.mdw.dataaccess.RuntimeDataAccess in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method updateVariableInstanceInDb.

public void updateVariableInstanceInDb(VariableInstanceInfo varInstInfo, String newValue, boolean isDocument) throws DataAccessException {
    // needs a separate db connection for some reason?
    DatabaseAccess db = new DatabaseAccess(currentServer.getDatabaseUrl());
    try {
        RuntimeDataAccess runtimeDao = DataAccess.getRuntimeDataAccess(dbSchemaVersion, dbSupportedSchemaVersion, db, getVariableTypes());
        db.openConnection();
        if (isDocument) {
            DocumentReference docRef = (DocumentReference) varInstInfo.getData();
            runtimeDao.updateDocumentContent(docRef.getDocumentId(), newValue);
        } else {
            varInstInfo.setStringValue(newValue);
            runtimeDao.updateVariableInstance(varInstInfo);
        }
    } catch (SQLException ex) {
        throw new DataAccessException(-1, ex.getMessage(), ex);
    } finally {
        db.closeConnection();
    }
    auditLog(Action.Change, Entity.VariableInstance, varInstInfo.getInstanceId(), varInstInfo.getName());
}
Also used : RuntimeDataAccess(com.centurylink.mdw.dataaccess.RuntimeDataAccess) DatabaseAccess(com.centurylink.mdw.dataaccess.DatabaseAccess) SQLException(java.sql.SQLException) DocumentReference(com.centurylink.mdw.model.value.variable.DocumentReference) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 2 with RuntimeDataAccess

use of com.centurylink.mdw.dataaccess.RuntimeDataAccess in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method getProcessInstanceList.

public ProcessList getProcessInstanceList(Map<String, String> pMap, int pageIndex, int pageSize, ProcessVO procdef, String orderBy) throws DataAccessException {
    if (procdef != null && procdef.isRemote()) {
        RuntimeDataAccess runTimeInfo = remoteAccess.get(procdef.getRemoteServer()).getRuntimeDataAccess();
        ProcessList ret = runTimeInfo.getProcessInstanceList(pMap, pageIndex, pageSize, orderBy);
        for (ProcessInstanceVO one : ret.getProcesses()) {
            one.setRemoteServer(procdef.getRemoteServer());
        }
        return ret;
    } else {
        return rtinfo.getProcessInstanceList(pMap, pageIndex, pageSize, orderBy);
    }
}
Also used : RuntimeDataAccess(com.centurylink.mdw.dataaccess.RuntimeDataAccess) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 3 with RuntimeDataAccess

use of com.centurylink.mdw.dataaccess.RuntimeDataAccess in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method getChildProcessInstance.

/**
 * Does not work for embedded subprocs in asset processes.
 */
public List<ProcessInstanceVO> getChildProcessInstance(Long processInstanceId, ProcessVO childProcess, ProcessVO parentProcess) throws DataAccessException {
    Map<String, String> pMap = new HashMap<>();
    if (childProcess.isRemote()) {
        RuntimeDataAccess runTimeInfo = remoteAccess.get(childProcess.getRemoteServer()).getRuntimeDataAccess();
        List<ProcessInstanceVO> ret;
        String ownerType = OwnerType.PROCESS_INSTANCE;
        if (parentProcess.isRemote()) {
            if (!parentProcess.getRemoteServer().equals(childProcess.getRemoteServer()))
                ownerType = parentProcess.getRemoteServer();
        } else {
            ownerType = currentServer.getApplicationName();
        }
        pMap.put("owner", ownerType);
        pMap.put("ownerId", processInstanceId.toString());
        pMap.put(PROCESSID, childProcess.getProcessId().toString());
        ProcessList procList = runTimeInfo.getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, null);
        ret = procList.getProcesses();
        for (ProcessInstanceVO one : ret) {
            one.setRemoteServer(childProcess.getRemoteServer());
        }
        return ret;
    } else {
        pMap.put("owner", OwnerType.PROCESS_INSTANCE);
        pMap.put("ownerId", processInstanceId.toString());
        pMap.put(PROCESSID, childProcess.getProcessId().toString());
        return getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, childProcess, null).getProcesses();
    }
}
Also used : RuntimeDataAccess(com.centurylink.mdw.dataaccess.RuntimeDataAccess) HashMap(java.util.HashMap) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Aggregations

RuntimeDataAccess (com.centurylink.mdw.dataaccess.RuntimeDataAccess)3 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)2 ProcessList (com.centurylink.mdw.model.value.process.ProcessList)2 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 DatabaseAccess (com.centurylink.mdw.dataaccess.DatabaseAccess)1 DocumentReference (com.centurylink.mdw.model.value.variable.DocumentReference)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1