예제 #1
0
  private ProjectDescriptor getProjectOrDescriptor(Record projRec) {
    if (projRec == null) return null;

    // Create ProjectDescriptor:
    int id = PROJECT_ID_COLUMN.retrieveValue(projRec).intValue();
    boolean v1x = PROJECT_V1X_SCHEMA_VERSION_COLUMN.isValuePresent(projRec);
    ProjectDescriptor projDescr =
        new ProjectDescriptor(
            v1x ? ProjectDescriptor.PROJECT_ID_V1X_TEMP : id,
            PROJECT_NAME_COLUMN.retrieveValue(projRec),
            PROJECT_VARIANT_COLUMN.retrieveValue(projRec), // "" is treated as null,
            PROJECT_VERSION_COLUMN.retrieveValue(projRec),
            PROJECT_FINGERPRINT_COLUMN.retrieveValue(projRec).intValue());
    if (v1x)
      projDescr.setV1XSchemaInfo(
          id, PROJECT_V1X_SCHEMA_VERSION_COLUMN.retrieveValue(projRec).intValue());

    // If the full project is cached return it instead of the descriptor:
    Project project = cache.get(getCacheKey(projDescr));
    if (project != null) return project;

    return projDescr;
  }
예제 #2
0
 /* (non-Javadoc)
  * @see uk.ac.ucl.excites.sapelli.collector.db.ProjectStore#retrieveHeldForeignKey(uk.ac.ucl.excites.sapelli.collector.model.fields.Relationship)
  */
 @Override
 public RecordReference retrieveHeldForeignKey(Relationship relationship) {
   Record hfkRecord = null;
   try {
     hfkRecord = rsWrapper.recordStore.retrieveRecord(getHFKRecordReference(relationship));
     return relationship
         .getRelatedForm()
         .getSchema()
         .createRecordReference(HFK_SERIALISED_RECORD_REFERENCE.retrieveValue(hfkRecord));
   } catch (Exception e) {
     if (hfkRecord != null) deleteHeldForeignKey(relationship);
   }
   // else:
   return null;
 }