Changeset 3586


Ignore:
Timestamp:
Jul 20, 2007, 2:40:10 PM (16 years ago)
Author:
Nicklas Nordborg
Message:

References #326: Mass annotation plug-in

Major features in place. Code needs to be polished up and documented. Need to add permissions.
User documentation (docbook) should be checked if it needs to be updated.

Location:
trunk/src
Files:
5 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/AnnotationType.java

    r3527 r3586  
    10941094      if (pv == null || !pv.getValues().contains(value))
    10951095      {
    1096         throw new InvalidDataException("Value '"+value+"' is not among the list of allowed values: "+(pv == null ? "" : pv.getValues()));
     1096        throw new DisallowedValueException("Value '"+value+"' is not among the list of allowed values " +
     1097          "for annotation type: "+getName());
    10971098      }
    10981099    }
  • trunk/src/core/net/sf/basedb/core/Install.java

    r3572 r3586  
    606606      createPluginDefinition("net.sf.basedb.plugins.CdfFileReporterImporter", null, null, true, null, false);
    607607      createPluginDefinition("net.sf.basedb.plugins.PackedFileExporter", null, keyEveryoneUse, true, null, true);
     608      createPluginDefinition("net.sf.basedb.plugins.AnnotationFlatFileImporter", null, keyEveryoneUse, true, null, false);
    608609     
    609610      // Plugin configurations
  • trunk/src/core/net/sf/basedb/core/PluginRequest.java

    r2981 r3586  
    146146  }
    147147 
     148  /**
     149    Get the values that are currently stored in the job or plugin configuration
     150    related to this request. This method will first check the job and then the
     151    plugin configuration.
     152    @param name The name of the parameter
     153    @return The parameter values, or null if no parameter with the given name
     154      exists
     155  */
    148156  public List<?> getCurrentParameterValues(String name)
    149157  {
     
    153161      values = jobParameters.getValues(name);
    154162    }
    155     else if (configurationParameters != null)
     163    if (values == null && configurationParameters != null)
    156164    {
    157165      values = configurationParameters.getValues(name);
     
    161169 
    162170 
     171  /**
     172    Get the values that are currently stored in the plugin configuration
     173    related to this request.
     174    @param name The name of the parameter
     175    @return The parameter values, or null if no parameter with the given name
     176      exists or if this request isn't associated with a plugin configuration
     177  */
    163178  public List<?> getCurrentConfigurationParameterValues(String name)
    164179  {
     
    171186  }
    172187 
     188  /**
     189    Get the values that are currently stored in the job related to this
     190    request.
     191    @param name The name of the parameter
     192    @return The parameter values, or null if no parameter with the given name
     193      exists or if this request isn't associated with a job
     194  */
    173195  public List<?> getCurrentJobParameterValues(String name)
    174196  {
  • trunk/src/plugins/core/net/sf/basedb/plugins/AbstractFlatFileImporter.java

    r3493 r3586  
    953953    return mapper;
    954954  }
    955    
     955 
     956  /**
     957    Get the value for an error handling parameter. If no value
     958    is found for the specified parameter the value for the 'defaultError' parameter
     959    is returned.
     960    @param parameterName The name of the error parameter
     961    @return The error option or null if no option has been set
     962    @since 2.4
     963  */
     964  protected String getErrorOption(String parameterName)
     965  {
     966    Object option = null;
     967    option = job.getValue(parameterName);
     968    if (option == null) option = job.getValue("defaultError");
     969    return option == null ? null : option.toString();
     970  }
     971 
    956972  protected ErrorHandler getErrorHandler(String method, ErrorHandler defaultErrorHandler)
    957973  {
  • trunk/src/test/TestAll.java

    r3471 r3586  
    7272    results.put("TestProtocol", TestProtocol.test_all());
    7373
    74     // Annotation types and annotations
    75     results.put("TestAnnotationType", TestAnnotationType.test_all());
    76     results.put("TestAnnotationTypeCategory", TestAnnotationTypeCategory.test_all());
    77     results.put("TestAnnotation", TestAnnotation.test_all());
    78 
     74    // File parsing
     75    results.put("TestFlatFileParser", TestFlatFileParser.test_all());
     76   
    7977    // Biomaterials
    8078    results.put("TestBioSource", TestBioSource.test_all());
     
    8482    results.put("TestLabeledExtract", TestLabeledExtract.test_all());
    8583
    86     // File parsing
    87     results.put("TestFlatFileParser", TestFlatFileParser.test_all());
    88 
     84    // Annotation types and annotations
     85    results.put("TestAnnotationType", TestAnnotationType.test_all());
     86    results.put("TestAnnotationTypeCategory", TestAnnotationTypeCategory.test_all());
     87    results.put("TestAnnotation", TestAnnotation.test_all());
     88    results.put("TestAnnotationFlatFileImporter", TestAnnotationFlatFileImporter.test_all());
     89   
    8990    // Reporters
    9091    results.put("TestReporterType", TestReporterType.test_all());
  • trunk/src/test/TestAnnotation.java

    r2314 r3586  
    4848    // Create annotation types and array design
    4949
    50     int intId = TestAnnotationType.test_create(Type.INT, 10, Item.ARRAYDESIGN, null, true);
    51     int longId = TestAnnotationType.test_create(Type.LONG, 1056567756767l, Item.ARRAYDESIGN, null, true);
    52     int floatId = TestAnnotationType.test_create(Type.FLOAT, 10.1f, Item.ARRAYDESIGN, null, true);
    53     int doubleId = TestAnnotationType.test_create(Type.DOUBLE, 8.13454646d, Item.ARRAYDESIGN, null, true);
    54     int dateId = TestAnnotationType.test_create(Type.DATE, new Date(), Item.ARRAYDESIGN, null, true);
    55     int textId = TestAnnotationType.test_create(Type.TEXT, "default value", Item.ARRAYDESIGN, null, true);
    56     int stringId = TestAnnotationType.test_create(Type.STRING, "default value", Item.ARRAYDESIGN, null, true);
    57     int booleanId = TestAnnotationType.test_create(Type.BOOLEAN, true, Item.ARRAYDESIGN, null, true);
    58     int enumId = TestAnnotationType.test_create(Type.INT, 3, Item.ARRAYDESIGN, new Object[] { 1, 2, 3, 4, 5 }, false);
     50    int intId = TestAnnotationType.test_create(null, Type.INT, 10, null, Item.ARRAYDESIGN, 1, null, true);
     51    int longId = TestAnnotationType.test_create(null, Type.LONG, 1056567756767l, null, Item.ARRAYDESIGN, 1, null, true);
     52    int floatId = TestAnnotationType.test_create(null, Type.FLOAT, 10.1f, null, Item.ARRAYDESIGN, 1, null, true);
     53    int doubleId = TestAnnotationType.test_create(null, Type.DOUBLE, 8.13454646d, null, Item.ARRAYDESIGN, 1, null, true);
     54    int dateId = TestAnnotationType.test_create(null, Type.DATE, new Date(), null, Item.ARRAYDESIGN, 1, null, true);
     55    int textId = TestAnnotationType.test_create(null, Type.TEXT, "default value", null, Item.ARRAYDESIGN, 1, null, true);
     56    int stringId = TestAnnotationType.test_create(null, Type.STRING, "default value", null, Item.ARRAYDESIGN, 1, null, true);
     57    int booleanId = TestAnnotationType.test_create(null, Type.BOOLEAN, true, null, Item.ARRAYDESIGN, 1, null, true);
     58    int enumId = TestAnnotationType.test_create(null, Type.INT, 3, null, Item.ARRAYDESIGN, 1, new Object[] { 1, 2, 3, 4, 5 }, false);
    5959    int arrayDesignId = TestArrayDesign.test_create(true, false);
    6060
     
    6969    int booleanAnnotationId = test_annotatate(arrayDesignId, booleanId, false);
    7070    int enumAnnotationId = test_annotatate(arrayDesignId, enumId, 4);
    71     test_list_annotations(arrayDesignId, 9);
     71    test_list_annotations(Item.ARRAYDESIGN, arrayDesignId, 9);
    7272
    7373    // Test: inherit annotations
     
    9595    test_remove_annotation(arrayDesignId, booleanId);
    9696    test_remove_annotation(arrayDesignId, enumId);
    97     test_list_annotations(arrayDesignId, 0);
     97    test_list_annotations(Item.ARRAYDESIGN, arrayDesignId, 0);
    9898
    9999    // Delete annotation types and array design
     
    176176  }
    177177
    178   static void test_list_annotations(int arrayDesignId, int expectedResults)
    179   {
    180     DbControl dc = null;
    181     try
    182     {
    183       dc = TestUtil.getDbControl();
    184       ArrayDesign ad = ArrayDesign.getById(dc, arrayDesignId);
    185       AnnotationSet as = ad.getAnnotationSet();
     178  static void test_list_annotations(Item itemType, int itemId, int expectedResults)
     179  {
     180    DbControl dc = null;
     181    Annotatable at = null;
     182    try
     183    {
     184      dc = TestUtil.getDbControl();
     185      at = (Annotatable)itemType.getById(dc, itemId);
     186      AnnotationSet as = at.getAnnotationSet();
    186187      ItemResultList<Annotation> l = as.getAnnotations().list(dc);
    187188      for (int i = 0; i<l.size(); i++)
     
    193194        throw new BaseException("Expected "+expectedResults+" results, not "+l.size());
    194195      }
    195       write("--List annotations OK ("+l.size()+")");
    196     }
    197     catch (Throwable ex)
    198     {
    199       write("--List annotations FAILED");
     196      write("--List annotations for " + at + " OK ("+l.size()+")");
     197    }
     198    catch (Throwable ex)
     199    {
     200      write("--List annotations for " + at + " FAILED");
    200201      ex.printStackTrace();
    201202      ok = false;
  • trunk/src/test/TestAnnotationType.java

    r3527 r3586  
    4545    write_header();
    4646    // Standard tests: create, load, list
    47     int id_int = test_create(Type.INT, 10, Item.SAMPLE, null, true);
    48     int id_long = test_create(Type.LONG, 123456789123456l, Item.SAMPLE, null, true);
    49     int id_float = test_create(Type.FLOAT, 10.1, Item.SAMPLE, null, false);
    50     int id_double = test_create(Type.DOUBLE, 8.13459187745, Item.SAMPLE, null, false);
    51     int id_date = test_create(Type.DATE, new Date(), Item.SAMPLE, null, false);
    52     int id_text = test_create(Type.TEXT, "default value", Item.SAMPLE, null, false);
    53     int id_string = test_create(Type.STRING, "default value", Item.SAMPLE, null, false);
    54     int id_boolean = test_create(Type.BOOLEAN, true, Item.SAMPLE, null, false);
    55     int id_enum = test_create(Type.INT, 3, Item.SAMPLE, new Object[] { 1, 2, 3, 4, 5 }, false);
    56     int id2_enum = test_create(Type.STRING, "one", Item.SAMPLE, new String[] { "one", "two ", "three" }, false);
     47    int id_int = test_create(null, Type.INT, 10, null, Item.SAMPLE, 1, null, true);
     48    int id_long = test_create(null, Type.LONG, 123456789123456l, null, Item.SAMPLE, 1, null, true);
     49    int id_float = test_create(null, Type.FLOAT, 10.1, null, Item.SAMPLE, 1, null, false);
     50    int id_double = test_create(null, Type.DOUBLE, 8.13459187745, null, Item.SAMPLE, 1, null, false);
     51    int id_date = test_create(null, Type.DATE, new Date(), null, Item.SAMPLE, 1, null, false);
     52    int id_text = test_create(null, Type.TEXT, "default value", null, Item.SAMPLE, 1, null, false);
     53    int id_string = test_create(null, Type.STRING, "default value", null, Item.SAMPLE, 1, null, false);
     54    int id_boolean = test_create(null, Type.BOOLEAN, true, null, Item.SAMPLE, 1, null, false);
     55    int id_enum = test_create(null, Type.INT, 3, null, Item.SAMPLE, 1, new Object[] { 1, 2, 3, 4, 5 }, false);
     56    int id2_enum = test_create(null, Type.STRING, "one", null, Item.SAMPLE, 1, new String[] { "one", "two ", "three" }, false);
    5757    test_load(id_int);
    5858    test_load(id_long);
     
    9999  }
    100100 
    101   static int test_create(Type type, Object defaultValue, Item itemType, Object[] enumValues, boolean setAll)
     101  static int test_create(String name, Type type, Object defaultValue, Number maxValue, Item itemType, int multiplicity, Object[] enumValues, boolean setAll)
    102102  {
    103103    if (!TestUtil.hasPermission(Permission.CREATE, Item.ANNOTATIONTYPE)) return 0;
     
    110110      if(setAll)
    111111      {
    112         at.setName("Test annotation type: "+type);
     112        at.setName( "Test annotation type: "+type);
    113113        at.setDescription("Added at "+new Date());
    114         at.setMultiplicity(1);
    115114        at.setRequiredForMiame(true);
    116115        at.setHeight(10);
     
    118117        at.setExternalId("my.external.annotationtype");
    119118      }
     119      at.setMultiplicity(multiplicity);
     120      if (name != null) at.setName(name);
    120121      if (enumValues != null)
    121122      {
     
    125126      }
    126127      if (defaultValue != null) at.setDefaultValue(defaultValue.toString());
     128      if (maxValue != null)
     129      {
     130        if (type.isNumerical())
     131        {
     132          at.setMinValueLong(0l);
     133          at.setMaxValueLong(maxValue.longValue());
     134        }
     135        else if (type == Type.STRING)
     136        {
     137          at.setMaxLength(maxValue.intValue());
     138        }
     139      }
    127140      at.enableForItem(itemType);
    128141      dc.saveItem(at);
  • trunk/src/test/TestAnnotationTypeCategory.java

    r2517 r3586  
    5959
    6060    // extra test: add categories to annotation type
    61     int id_int = TestAnnotationType.test_create(Type.INT, 10, Item.SAMPLE, null, true);
     61    int id_int = TestAnnotationType.test_create(null, Type.INT, 10, null, Item.SAMPLE, 1, null, true);
    6262    test_add_categories(id_int, id, id2);
    6363    test_list_categories(id_int, 2);
  • trunk/src/test/TestAnyToAny.java

    r3454 r3586  
    4848    write_header();
    4949    // Standard tests: create, load, list
    50     int sampleId = TestSample.test_create(0, true);
     50    int sampleId = TestSample.test_create(0, null, true);
    5151    int fileId1 = TestFile.test_create("Linked file #1", true);
    5252    int fileId2 = TestFile.test_create("Linked file #2", true);
  • trunk/src/test/TestExtract.java

    r2314 r3586  
    4545    int id2 = test_create(0, false);
    4646   
    47     int sampleId = TestSample.test_create(0, true);
     47    int sampleId = TestSample.test_create(0, null, true);
    4848    int id3 = test_create(sampleId, false);
    4949    int id4 = test_create_pooled(id, id2, id3);
  • trunk/src/test/TestSample.java

    r2314 r3586  
    4242    write_header();
    4343    // Standard tests: create, load, list
    44     int id = test_create(0, true);
    45     int id2 = test_create(0, false);
     44    int id = test_create(0, null, true);
     45    int id2 = test_create(0, null, false);
    4646   
    4747    int bioSourceId = TestBioSource.test_create(false);
    48     int id3 = test_create(bioSourceId, false);
     48    int id3 = test_create(bioSourceId, null, false);
    4949    int id4 = test_create_pooled(id, id2, id3);
    5050
     
    7171  }
    7272
    73   static int test_create(int bioSourceId, boolean setAll)
     73  static int test_create(int bioSourceId, String name, boolean setAll)
    7474  {
    7575    if (!TestUtil.hasPermission(Permission.CREATE, Item.SAMPLE)) return 0;
     
    8787        s.setOriginalQuantity(500.0f);
    8888      }
     89      if (name != null) s.setName(name);
    8990      if (bioSourceId != 0)
    9091      {
Note: See TracChangeset for help on using the changeset viewer.