Search in sources :

Example 6 with SimpleJobStatus

use of cbit.vcell.server.SimpleJobStatus in project vcell by virtualcell.

the class RestDatabaseService method query.

public SimulationStatusRepresentation[] query(SimulationStatusServerResource resource, User vcellUser) throws SQLException, DataAccessException {
    if (vcellUser == null) {
        vcellUser = VCellApiApplication.DUMMY_USER;
    }
    String userID = vcellUser.getName();
    SimpleJobStatusQuerySpec simQuerySpec = new SimpleJobStatusQuerySpec();
    simQuerySpec.userid = userID;
    simQuerySpec.simId = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_SIM_ID);
    String hasData = resource.getQueryValue(SimulationStatusServerResource.PARAM_HAS_DATA);
    if (hasData != null && hasData.equals("yes")) {
        simQuerySpec.hasData = true;
    } else if (hasData != null && hasData.equals("no")) {
        simQuerySpec.hasData = false;
    } else {
        simQuerySpec.hasData = null;
    }
    simQuerySpec.waiting = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_ACTIVE, false);
    simQuerySpec.queued = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_ACTIVE, false);
    simQuerySpec.dispatched = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_ACTIVE, false);
    simQuerySpec.running = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_ACTIVE, false);
    simQuerySpec.completed = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_COMPLETED, false);
    simQuerySpec.failed = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_FAILED, false);
    simQuerySpec.stopped = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_STOPPED, false);
    simQuerySpec.submitLowMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_SUBMIT_LOW);
    simQuerySpec.submitHighMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_SUBMIT_HIGH);
    simQuerySpec.startLowMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_START_LOW);
    simQuerySpec.startHighMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_START_HIGH);
    simQuerySpec.endLowMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_END_LOW);
    simQuerySpec.endHighMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_END_HIGH);
    Long startRowParam = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_START_ROW);
    // default
    simQuerySpec.startRow = 1;
    if (startRowParam != null) {
        simQuerySpec.startRow = startRowParam.intValue();
    }
    Long maxRowsParam = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_MAX_ROWS);
    // default
    simQuerySpec.maxRows = 10;
    if (maxRowsParam != null) {
        simQuerySpec.maxRows = maxRowsParam.intValue();
    }
    SimulationStatus[] simStatuses = null;
    HashMap<KeyValue, SimulationDocumentLink> simDocLinks = new HashMap<KeyValue, SimulationDocumentLink>();
    // 
    // ask server for simJobStatuses with above query spec.
    // find set of simulation IDs from the result set of simJobStatus
    // ask server for simulationStatuses from list of sim IDs.
    // 
    VCMessageSession rpcSession = vcMessagingService.createProducerSession();
    try {
        UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(), null);
        try {
            userLoginInfo.setUser(vcellUser);
        } catch (Exception e) {
            e.printStackTrace();
            throw new DataAccessException(e.getMessage());
        }
        RpcSimServerProxy rpcSimServerProxy = new RpcSimServerProxy(userLoginInfo, rpcSession);
        SimpleJobStatus[] simpleJobStatusArray = rpcSimServerProxy.getSimpleJobStatus(vcellUser, simQuerySpec);
        // gather unique simIDs and go back and ask server for SimulationStatuses
        for (SimpleJobStatus simpleJobStatus : simpleJobStatusArray) {
            KeyValue simulationKey = simpleJobStatus.jobStatus.getVCSimulationIdentifier().getSimulationKey();
            SimulationDocumentLink simulationDocumentLink = simpleJobStatus.simulationDocumentLink;
            simDocLinks.put(simulationKey, simulationDocumentLink);
        }
        KeyValue[] simKeys = simDocLinks.keySet().toArray(new KeyValue[0]);
        if (simKeys.length > 0) {
            simStatuses = rpcSimServerProxy.getSimulationStatus(vcellUser, simKeys);
        }
    } finally {
        rpcSession.close();
    }
    ArrayList<SimulationStatusRepresentation> simStatusReps = new ArrayList<SimulationStatusRepresentation>();
    for (int i = 0; simStatuses != null && i < simStatuses.length; i++) {
        KeyValue simulationKey = simStatuses[i].getVCSimulationIdentifier().getSimulationKey();
        SimulationRep simRep = getSimulationRep(simulationKey);
        try {
            SimulationRepresentation simRepresentation = new SimulationRepresentation(simRep, simDocLinks.get(simulationKey));
            simStatusReps.add(new SimulationStatusRepresentation(simRepresentation, simStatuses[i]));
        } catch (ExpressionException e) {
            e.printStackTrace(System.out);
        }
    }
    return simStatusReps.toArray(new SimulationStatusRepresentation[0]);
}
Also used : SimpleJobStatusQuerySpec(cbit.vcell.server.SimpleJobStatusQuerySpec) KeyValue(org.vcell.util.document.KeyValue) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) RpcSimServerProxy(org.vcell.rest.rpc.RpcSimServerProxy) VCMessageSession(cbit.vcell.message.VCMessageSession) ArrayList(java.util.ArrayList) BigString(org.vcell.util.BigString) PropertyVetoException(java.beans.PropertyVetoException) MatrixException(cbit.vcell.matrix.MatrixException) ModelException(cbit.vcell.model.ModelException) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) SQLException(java.sql.SQLException) XmlParseException(cbit.vcell.xml.XmlParseException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) UseridIDExistsException(org.vcell.util.UseridIDExistsException) MappingException(cbit.vcell.mapping.MappingException) MathException(cbit.vcell.math.MathException) ExpressionException(cbit.vcell.parser.ExpressionException) SimpleJobStatus(cbit.vcell.server.SimpleJobStatus) SimulationRepresentation(org.vcell.rest.common.SimulationRepresentation) SimulationDocumentLink(cbit.vcell.server.SimulationDocumentLink) SimulationStatus(cbit.vcell.server.SimulationStatus) UserLoginInfo(org.vcell.util.document.UserLoginInfo) DataAccessException(org.vcell.util.DataAccessException) SimulationRep(cbit.vcell.modeldb.SimulationRep) SimulationStatusRepresentation(org.vcell.rest.common.SimulationStatusRepresentation)

Example 7 with SimpleJobStatus

use of cbit.vcell.server.SimpleJobStatus in project vcell by virtualcell.

the class SimulationJobsTableModel method getValueAt.

@Override
public Object getValueAt(int iRow, int iCol) {
    SimpleJobStatus sjs = getValueAt(iRow);
    if (sjs == null) {
        return null;
    }
    switch(iCol) {
        case iColModelApp:
            if (sjs.simulationDocumentLink instanceof BioModelLink) {
                BioModelLink bml = (BioModelLink) sjs.simulationDocumentLink;
                return "(BM) " + bml.bioModelName + ", (App) " + bml.simContextName;
            } else if (sjs.simulationDocumentLink instanceof MathModelLink) {
                MathModelLink mml = (MathModelLink) sjs.simulationDocumentLink;
                return "(MM) " + mml.mathModelName;
            } else {
                return null;
            }
        case iColSimulation:
            return sjs.simulationMetadata.simname;
        case iColSimId:
            return sjs.simulationMetadata.vcSimID.getSimulationKey().toString() + " / " + sjs.jobStatus.getJobIndex() + " / " + sjs.jobStatus.getTaskID();
        case iColSolver:
            String str = "";
            if (sjs.simulationMetadata.solverTaskDesc != null) {
                str = sjs.simulationMetadata.solverTaskDesc.getSolverDescription() == null ? "" : sjs.simulationMetadata.solverTaskDesc.getSolverDescription().getDisplayLabel();
            }
            return str;
        case iColSubmitDate:
            DateFormat df = new SimpleDateFormat("MM.dd.yyyy");
            Date date = sjs.jobStatus.getStartDate();
            return df.format(date);
        case iColHasData:
            return sjs.jobStatus.hasData() == true ? "Yes" : "No";
        case iColStatus:
            return sjs.jobStatus.getSchedulerStatus().getDescription();
        case iColMessage:
            return sjs.jobStatus.getSimulationMessage().getDisplayMessage();
        case iColSite:
            return sjs.jobStatus.getServerID().toString();
        // return sjs.jobStatus.getComputeHost();
        default:
            return null;
    }
}
Also used : BioModelLink(cbit.vcell.server.BioModelLink) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) MathModelLink(cbit.vcell.server.MathModelLink) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) SimpleJobStatus(cbit.vcell.server.SimpleJobStatus)

Example 8 with SimpleJobStatus

use of cbit.vcell.server.SimpleJobStatus in project vcell by virtualcell.

the class SimulationDatabaseDirect method translateToSimpleJobStatusTransient.

private SimpleJobStatus translateToSimpleJobStatusTransient(SimpleJobStatusPersistent simpleJobStatusPersistent, SimulationJobStatus cachedSimulationJobStatus, StateInfo cachedStateInfo) {
    SimulationJobStatus simJobStatus = null;
    if (cachedSimulationJobStatus != null) {
        simJobStatus = cachedSimulationJobStatus;
    } else {
        simJobStatus = translateToSimulationJobStatusTransient(simpleJobStatusPersistent.jobStatus);
    }
    SimpleJobStatus simpleJobStatus = new SimpleJobStatus(simpleJobStatusPersistent.simulationMetadata, simpleJobStatusPersistent.simulationDocumentLink, simJobStatus, cachedStateInfo);
    return simpleJobStatus;
}
Also used : SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimpleJobStatus(cbit.vcell.server.SimpleJobStatus)

Example 9 with SimpleJobStatus

use of cbit.vcell.server.SimpleJobStatus in project vcell by virtualcell.

the class SimulationJobsTableModel method getComparator.

public Comparator<SimpleJobStatus> getComparator(final int col, final boolean ascending) {
    final int scale = ascending ? 1 : -1;
    return new Comparator<SimpleJobStatus>() {

        public int compare(SimpleJobStatus o1, SimpleJobStatus o2) {
            String s1 = "";
            String s2 = "";
            switch(col) {
                case iColModelApp:
                    if (o1.simulationDocumentLink instanceof BioModelLink) {
                        BioModelLink bml = (BioModelLink) o1.simulationDocumentLink;
                        s1 = "(BM) " + bml.bioModelName + ",(App) " + bml.simContextName;
                    } else if (o1.simulationDocumentLink instanceof MathModelLink) {
                        MathModelLink mml = (MathModelLink) o1.simulationDocumentLink;
                        s1 = "(MM) " + mml.mathModelName;
                    }
                    if (o2.simulationDocumentLink instanceof BioModelLink) {
                        BioModelLink bml = (BioModelLink) o2.simulationDocumentLink;
                        s2 = "(BM) " + bml.bioModelName + ",(App) " + bml.simContextName;
                    } else if (o2.simulationDocumentLink instanceof MathModelLink) {
                        MathModelLink mml = (MathModelLink) o2.simulationDocumentLink;
                        s2 = "(MM) " + mml.mathModelName;
                    }
                    return scale * s1.compareToIgnoreCase(s2);
                case iColSimulation:
                    s1 = o1.simulationMetadata.simname;
                    s2 = o2.simulationMetadata.simname;
                    if (!s1.equalsIgnoreCase(s2)) {
                        return scale * s1.compareToIgnoreCase(s2);
                    } else {
                        // if same simulation, sort by date
                        Date d1 = o1.jobStatus.getStartDate();
                        Date d2 = o2.jobStatus.getStartDate();
                        return scale * d1.compareTo(d2);
                    }
                case iColSimId:
                    s1 = o1.simulationMetadata.vcSimID.getSimulationKey().toString() + "," + o1.jobStatus.getJobIndex() + "," + o1.jobStatus.getTaskID();
                    s2 = o2.simulationMetadata.vcSimID.getSimulationKey().toString() + "," + o2.jobStatus.getJobIndex() + "," + o2.jobStatus.getTaskID();
                    return scale * s1.compareToIgnoreCase(s2);
                case iColSolver:
                    if (o1.simulationMetadata.solverTaskDesc != null && o1.simulationMetadata.solverTaskDesc.getSolverDescription() != null) {
                        s1 = o1.simulationMetadata.solverTaskDesc.getSolverDescription().getDisplayLabel();
                    }
                    if (o2.simulationMetadata.solverTaskDesc != null && o2.simulationMetadata.solverTaskDesc.getSolverDescription() != null) {
                        s2 = o2.simulationMetadata.solverTaskDesc.getSolverDescription().getDisplayLabel();
                    }
                    return scale * s1.compareToIgnoreCase(s2);
                case iColSubmitDate:
                    Date d1 = o1.jobStatus.getSubmitDate();
                    Date d2 = o2.jobStatus.getSubmitDate();
                    return scale * d1.compareTo(d2);
                case iColHasData:
                    Boolean b1 = o1.jobStatus.hasData();
                    Boolean b2 = o2.jobStatus.hasData();
                    return scale * b1.compareTo(b2);
                case iColStatus:
                    SchedulerStatus ss1 = o1.jobStatus.getSchedulerStatus();
                    SchedulerStatus ss2 = o2.jobStatus.getSchedulerStatus();
                    return scale * ss1.compareTo(ss2);
                case iColMessage:
                    if (o1.jobStatus != null && o1.jobStatus.getSimulationMessage() != null) {
                        s1 = o1.jobStatus.getSimulationMessage().getDisplayMessage();
                    }
                    if (o2.jobStatus != null && o2.jobStatus.getSimulationMessage() != null) {
                        s2 = o2.jobStatus.getSimulationMessage().getDisplayMessage();
                    }
                    return scale * s1.compareToIgnoreCase(s2);
                case iColSite:
                    s1 = o1.jobStatus.getServerID().toString();
                    s2 = o2.jobStatus.getServerID().toString();
                    return scale * s1.compareToIgnoreCase(s2);
                default:
                    return 0;
            }
        }
    };
}
Also used : BioModelLink(cbit.vcell.server.BioModelLink) SchedulerStatus(cbit.vcell.server.SimulationJobStatus.SchedulerStatus) MathModelLink(cbit.vcell.server.MathModelLink) Date(java.util.Date) Comparator(java.util.Comparator) SimpleJobStatus(cbit.vcell.server.SimpleJobStatus)

Example 10 with SimpleJobStatus

use of cbit.vcell.server.SimpleJobStatus in project vcell by virtualcell.

the class SimulationJobsTableModel method refreshData.

public void refreshData() {
    List<SimpleJobStatus> allJobStatusList = new ArrayList<>();
    for (SimpleJobStatus sjj : jobStatusArray) {
        allJobStatusList.add(sjj);
    }
    // ----- apply filters that are not applied by running the query -----------------
    List<SimpleJobStatus> filteredJobStatusList = new ArrayList<>();
    if (owner.getOrphanedButton().isSelected()) {
        // if checked, hide orphans
        for (SimpleJobStatus sjj : allJobStatusList) {
            if (sjj.simulationDocumentLink != null) {
                filteredJobStatusList.add(sjj);
            }
        }
    } else {
        filteredJobStatusList = allJobStatusList;
    }
    // ------- apply search --------------------------------------------------------------------
    List<SimpleJobStatus> jobStatusList = new ArrayList<>();
    if (searchText == null || searchText.length() == 0) {
        jobStatusList.addAll(filteredJobStatusList);
    } else {
        String lowerCaseSearchText = searchText.toLowerCase();
        for (SimpleJobStatus sjs : filteredJobStatusList) {
            // search in Solver column
            if (sjs.simulationMetadata.solverTaskDesc != null && sjs.simulationMetadata.solverTaskDesc.getSolverDescription() != null) {
                String str = sjs.simulationMetadata.solverTaskDesc.getSolverDescription().getDisplayLabel();
                if (str != null && str.toLowerCase().contains(lowerCaseSearchText)) {
                    jobStatusList.add(sjs);
                    continue;
                }
            }
            // search in Message column
            if (sjs.jobStatus != null && sjs.jobStatus.getSimulationMessage() != null) {
                String str = sjs.jobStatus.getSimulationMessage().getDisplayMessage();
                if (str != null && str.toLowerCase().contains(lowerCaseSearchText)) {
                    jobStatusList.add(sjs);
                    continue;
                }
            }
            // search in Model name, Application name (if available)
            String str = null;
            if (sjs.simulationDocumentLink instanceof BioModelLink) {
                BioModelLink bml = (BioModelLink) sjs.simulationDocumentLink;
                str = "(BM) " + bml.bioModelName + ",(App) " + bml.simContextName;
            } else if (sjs.simulationDocumentLink instanceof MathModelLink) {
                MathModelLink mml = (MathModelLink) sjs.simulationDocumentLink;
                str = "(MM) " + mml.mathModelName;
            }
            if (str != null && !str.isEmpty() && str.toLowerCase().contains(lowerCaseSearchText)) {
                jobStatusList.add(sjs);
                continue;
            }
            // Search in Simulation name
            str = sjs.simulationMetadata.simname;
            if (str != null && !str.isEmpty() && str.toLowerCase().contains(lowerCaseSearchText)) {
                jobStatusList.add(sjs);
                continue;
            }
        }
    }
    setData(jobStatusList);
    GuiUtils.flexResizeTableColumns(ownerTable);
}
Also used : BioModelLink(cbit.vcell.server.BioModelLink) ArrayList(java.util.ArrayList) MathModelLink(cbit.vcell.server.MathModelLink) SimpleJobStatus(cbit.vcell.server.SimpleJobStatus)

Aggregations

SimpleJobStatus (cbit.vcell.server.SimpleJobStatus)13 SimpleJobStatusQuerySpec (cbit.vcell.server.SimpleJobStatusQuerySpec)4 ArrayList (java.util.ArrayList)4 BigString (org.vcell.util.BigString)4 BioModelLink (cbit.vcell.server.BioModelLink)3 MathModelLink (cbit.vcell.server.MathModelLink)3 SQLException (java.sql.SQLException)3 Date (java.util.Date)3 DataAccessException (org.vcell.util.DataAccessException)3 PermissionException (org.vcell.util.PermissionException)3 MappingException (cbit.vcell.mapping.MappingException)2 MathException (cbit.vcell.math.MathException)2 MatrixException (cbit.vcell.matrix.MatrixException)2 VCMessageSession (cbit.vcell.message.VCMessageSession)2 SimulationDatabase (cbit.vcell.message.server.dispatcher.SimulationDatabase)2 SimulationDatabaseDirect (cbit.vcell.message.server.dispatcher.SimulationDatabaseDirect)2 ModelException (cbit.vcell.model.ModelException)2 ExpressionException (cbit.vcell.parser.ExpressionException)2 SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)2 SchedulerStatus (cbit.vcell.server.SimulationJobStatus.SchedulerStatus)2