Search in sources :

Example 71 with User

use of org.vcell.util.document.User in project vcell by virtualcell.

the class BioModelTable method getBioModelRep.

public BioModelRep getBioModelRep(User user, ResultSet rset) throws IllegalArgumentException, SQLException {
    KeyValue bmKey = new KeyValue(rset.getBigDecimal(table.id.toString()));
    String name = rset.getString(table.name.toString());
    int privacy = rset.getInt(table.privacy.toString());
    Date date = getDate(rset, table.versionDate.toString());
    String annot = rset.getString(table.versionAnnot.toString());
    BigDecimal branchID = rset.getBigDecimal(table.versionBranchID.toString());
    KeyValue modelRef = new KeyValue(rset.getBigDecimal(table.modelRef.toString()));
    KeyValue ownerRef = new KeyValue(rset.getBigDecimal(table.ownerRef.toString()));
    String ownerName = rset.getString(UserTable.table.userid.toString());
    User owner = new User(ownerName, ownerRef);
    String simKeysString = rset.getString("simKeys");
    ArrayList<KeyValue> simKeyList = new ArrayList<KeyValue>();
    String[] simKeys = simKeysString.replace("[", "").replace("]", "").split(",");
    for (String simKey : simKeys) {
        if (simKey != null && simKey.length() > 0) {
            simKeyList.add(new KeyValue(simKey));
        }
    }
    KeyValue[] simKeyArray = simKeyList.toArray(new KeyValue[0]);
    String simContextsString = rset.getString("simContextKeys");
    ArrayList<KeyValue> simContextKeyList = new ArrayList<KeyValue>();
    String[] simContextKeys = simContextsString.replace("[", "").replace("]", "").split(",");
    for (String simContextKey : simContextKeys) {
        if (simContextKey != null && simContextKey.length() > 0) {
            simContextKeyList.add(new KeyValue(simContextKey));
        }
    }
    KeyValue[] simContextKeyArray = simContextKeyList.toArray(new KeyValue[0]);
    String groupMembers = rset.getString("groupMembers");
    ArrayList<User> groupUsers = new ArrayList<User>();
    String[] groupUserStrings = groupMembers.replace("[", "").replace("]", "").split(",");
    for (String groupUserString : groupUserStrings) {
        if (groupUserString != null && groupUserString.length() > 0) {
            String[] groupUserTokens = groupUserString.split(":");
            KeyValue groupUserKey = new KeyValue(groupUserTokens[0]);
            String groupUserid = groupUserTokens[1];
            groupUsers.add(new User(groupUserid, groupUserKey));
        }
    }
    User[] groupUserArray = groupUsers.toArray(new User[0]);
    return new BioModelRep(bmKey, name, privacy, groupUserArray, date, annot, branchID, modelRef, owner, simKeyArray, simContextKeyArray);
}
Also used : KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) ArrayList(java.util.ArrayList) Date(java.util.Date) BigDecimal(java.math.BigDecimal)

Example 72 with User

use of org.vcell.util.document.User in project vcell by virtualcell.

the class ApiAccessTokenTable method getApiAccessToken.

/**
 * This method was created in VisualAge.
 * @return Model
 * @param rset ResultSet
 * @param log SessionLog
 */
public ApiAccessToken getApiAccessToken(ResultSet rset) throws SQLException, DataAccessException {
    KeyValue key = new KeyValue(rset.getBigDecimal(id.toString()));
    String token = rset.getString(accesstoken.toString());
    KeyValue clientKey = new KeyValue(rset.getBigDecimal(clientRef.toString()));
    KeyValue userKey = new KeyValue(rset.getBigDecimal(userref.toString()));
    String userid = rset.getString(UserTable.table.userid.toString());
    User user = new User(userid, userKey);
    java.util.Date creation = VersionTable.getDate(rset, creationDate.toString());
    if (creation == null) {
        throw new DataAccessException("could not parse creation date");
    }
    java.util.Date expiration = VersionTable.getDate(rset, expireDate.toString());
    if (expiration == null) {
        throw new DataAccessException("could not parse expiration date");
    }
    String accessTokenDatabaseString = rset.getString(status.toString());
    // default value if null
    AccessTokenStatus accessTokenStatus = AccessTokenStatus.created;
    if (accessTokenDatabaseString != null) {
        accessTokenStatus = AccessTokenStatus.fromDatabaseString(accessTokenDatabaseString);
    }
    ApiAccessToken apiAccessToken = new ApiAccessToken(key, token, clientKey, user, creation, expiration, accessTokenStatus);
    return apiAccessToken;
}
Also used : KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) AccessTokenStatus(cbit.vcell.modeldb.ApiAccessToken.AccessTokenStatus) Date(java.util.Date) DataAccessException(org.vcell.util.DataAccessException)

Example 73 with User

use of org.vcell.util.document.User in project vcell by virtualcell.

the class ExportServiceImpl method fireExportStarted.

/**
 * Insert the method's description here.
 * Creation date: (4/1/2001 11:20:45 AM)
 * @deprecated
 */
protected void fireExportStarted(long jobID, VCDataIdentifier vcdID, String format) {
    User user = null;
    Object object = jobRequestIDs.get(new Long(jobID));
    if (object != null) {
        user = (User) object;
    }
    ExportEvent event = new ExportEvent(this, jobID, user, vcdID, ExportEvent.EXPORT_START, format, null, null, null, null);
    fireExportEvent(event);
}
Also used : User(org.vcell.util.document.User) ExportEvent(cbit.rmi.event.ExportEvent)

Example 74 with User

use of org.vcell.util.document.User in project vcell by virtualcell.

the class ExportServiceImpl method fireExportFailed.

/**
 * Insert the method's description here.
 * Creation date: (4/1/2001 11:20:45 AM)
 * @deprecated
 */
protected void fireExportFailed(long jobID, VCDataIdentifier vcdID, String format, String message) {
    User user = null;
    Object object = jobRequestIDs.get(new Long(jobID));
    if (object != null) {
        user = (User) object;
    }
    ExportEvent event = new ExportEvent(this, jobID, user, vcdID, ExportEvent.EXPORT_FAILURE, format, message, null, null, null);
    fireExportEvent(event);
}
Also used : User(org.vcell.util.document.User) ExportEvent(cbit.rmi.event.ExportEvent)

Example 75 with User

use of org.vcell.util.document.User in project vcell by virtualcell.

the class IMGExporter method main.

public static void main(String[] args) throws Exception {
    if (args.length < 7) {
        System.out.println("Usage: IMGExporter username userkey simulationkey userdatadir beginTimeIndex endTimeIndex {varName1 varName2 ...}");
        System.exit(0);
    }
    String userName = args[0];
    String userKey = args[1];
    String SimulationKey = args[2];
    String primaryDirStr = args[3];
    int beginTimeIndex = Integer.valueOf(args[4]);
    int endTimeIndex = Integer.valueOf(args[5]);
    String[] varNames = new String[args.length - 6];
    if (args.length > 6) {
        for (int i = 6; i < args.length; i++) {
            varNames[i - 6] = args[i];
        }
    }
    PropertyLoader.loadProperties();
    User user = new User(userName, new KeyValue(userKey));
    VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(new KeyValue(SimulationKey), user);
    VCSimulationDataIdentifier vcdID = new VCSimulationDataIdentifier(vcSimID, 0);
    class PrintingExportServiceImpl extends ExportServiceImpl {

        public PrintingExportServiceImpl() {
            super();
        }

        @Override
        protected void fireExportEvent(ExportEvent event) {
            super.fireExportEvent(event);
            System.out.println("Event type=" + event.getEventTypeID() + " JobID=" + event.getJobID() + " progress=" + event.getProgress());
        }
    }
    ExportServiceImpl exportServiceImpl = new PrintingExportServiceImpl();
    Cachetable cachetable = new Cachetable(10 * Cachetable.minute);
    File primaryDir = new File(primaryDirStr);
    DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(cachetable, primaryDir, null);
    DataServerImpl dataServerImpl = new DataServerImpl(dataSetControllerImpl, exportServiceImpl);
    double[] allTimes = dataSetControllerImpl.getDataSetTimes(vcdID);
    TimeSpecs timeSpecs = new TimeSpecs(beginTimeIndex, endTimeIndex, allTimes, ExportConstants.TIME_RANGE);
    VariableSpecs variableSpecs = new VariableSpecs(varNames, ExportConstants.VARIABLE_MULTI);
    GeometrySpecs geometrySpecs = new GeometrySpecs(null, 0, 0, ExportConstants.GEOMETRY_SLICE);
    DisplayPreferences displayPreferences = new DisplayPreferences(DisplayAdapterService.BLUERED, new Range(0, 1), DisplayAdapterService.createBlueRedSpecialColors());
    MovieSpecs movieSpecs = new MovieSpecs(// /
    1000.0, // /
    false, // /
    new DisplayPreferences[] { displayPreferences }, // /
    ExportFormat.FORMAT_JPEG, // /
    0, // /
    1, // /
    1, // /
    1, ImagePaneModel.MESH_MODE, FormatSpecificSpecs.CODEC_JPEG, 1.0f, false, FormatSpecificSpecs.PARTICLE_SELECT);
    ExportSpecs exportSpecs = new ExportSpecs(vcdID, ExportFormat.QUICKTIME, variableSpecs, timeSpecs, geometrySpecs, movieSpecs, "IMGExporterTest", null);
    exportServiceImpl.makeRemoteFile(null, user, dataServerImpl, exportSpecs);
}
Also used : Cachetable(cbit.vcell.simdata.Cachetable) DataServerImpl(cbit.vcell.simdata.DataServerImpl) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) ExportEvent(cbit.rmi.event.ExportEvent) Range(org.vcell.util.Range) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) DisplayPreferences(cbit.image.DisplayPreferences) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) File(java.io.File)

Aggregations

User (org.vcell.util.document.User)159 KeyValue (org.vcell.util.document.KeyValue)68 DataAccessException (org.vcell.util.DataAccessException)46 SQLException (java.sql.SQLException)31 VCellApiApplication (org.vcell.rest.VCellApiApplication)30 File (java.io.File)25 BigString (org.vcell.util.BigString)22 ArrayList (java.util.ArrayList)21 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)21 BioModel (cbit.vcell.biomodel.BioModel)20 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)20 XmlParseException (cbit.vcell.xml.XmlParseException)17 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)16 XMLSource (cbit.vcell.xml.XMLSource)15 Simulation (cbit.vcell.solver.Simulation)14 BioModelInfo (org.vcell.util.document.BioModelInfo)14 SimulationContext (cbit.vcell.mapping.SimulationContext)13 ResultSet (java.sql.ResultSet)13 ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)13 BigDecimal (java.math.BigDecimal)12