class IBlobDataset(IDataset):

    # TODO: a primary field should not be required. possible bug in plone core
    model.primary('file')
    file = NamedBlobFile(title=_(u"File"),
                         description=_(u"Data content"),
                         required=True)
class IMultiSpeciesDataset(IDatasetCollection):
    """A species dataset based on a single file"""

    model.primary('file')
    file = NamedBlobFile(title=_(u"File"),
                         description=_(u"Data content"),
                         required=True)
class IDataset(model.Schema):
    """Interface all datasets inherit from"""

    # TODO: need behavior to add metadata details?

    directives.mode(downloadable=HIDDEN_MODE)
    downloadable = Bool(
        title=_(u"Download allowed"),
        description=_(
            u"If set, then users are allowed to directly download this dataset."
        ),
        required=True,
        default=True)

    directives.mode(part_of=HIDDEN_MODE)
    part_of = TextLine(title=_(u'Part of Dataset Collection'),
                       description=u'',
                       required=False,
                       default=None)

    directives.mode(dataSource=HIDDEN_MODE)
    dataSource = TextLine(
        title=_(u'Data Source'),
        description=u'e.g. ala, gbif, aekos, upload, experiment, ...',
        required=False,
        default=None)
Exemple #4
0
class Add(add.DefaultAddForm):
    """
    Add Experiment
    """

    template = ViewPageTemplateFile("experiment_add.pt")

    extends(view.DefaultView,
            ignoreButtons=True)

    buttons = button.Buttons(add.DefaultAddForm.buttons['cancel'])

    @button.buttonAndHandler(_('Create and start'), name='save')
    def handleAdd(self, action):
        data, errors = self.extractData()
        self.validateAction(data)
        if errors:
            self.status = self.formErrorsMessage
            return
        # TODO: this is prob. a bug in base form, because createAndAdd
        #       does not return the wrapped object.
        obj = self.createAndAdd(data)
        if obj is None:
            # TODO: this is probably an error here?
            #       object creation/add failed for some reason
            return
        # get wrapped instance fo new object (see above)
        obj = self.context[obj.id]
        # mark only as finished if we get the new object
        self._finishedAdd = True
        IStatusMessage(self.request).addStatusMessage(_(u"Item created"),
                                                      "info")
        # auto start job here
        jt = IJobTracker(obj)
        msgtype, msg = jt.start_job(self.request)
        if msgtype is not None:
            IStatusMessage(self.request).add(msg, type=msgtype)

    @button.buttonAndHandler(_('Create'), name='create')
    def handleCreate(self, action):
        data, errors = self.extractData()
        self.validateAction(data)
        if errors:
            self.status = self.formErrorsMessage
            return
        # TODO: this is prob. a bug in base form, because createAndAdd
        #       does not return the wrapped object.
        obj = self.createAndAdd(data)
        if obj is None:
            # TODO: this is probably an error here?
            #       object creation/add failed for some reason
            return
        # get wrapped instance fo new object (see above)
        obj = self.context[obj.id]
        # mark only as finished if we get the new object
        self._finishedAdd = True
        IStatusMessage(self.request).addStatusMessage(_(u"Item created"),
                                                      "info")
Exemple #5
0
class ISpeciesDataset(model.Schema):
    """
    a schema to drive the forms for species data sets
    """
    genre = schema.Choice(
        title=_(u'Data Genre'),
        vocabulary=u'genre_source'
    )

    scientificName = schema.TextLine(
        required=True,
        title=u'Scientific name',
        description=u'The full scientific name, with authorship and date information if known. When forming part of an Identification, this should be the name in lowest level taxonomic rank that can be determined. This term should not contain identification qualifications, which should instead be supplied in the IdentificationQualifier term.'
    )

    taxonID = schema.TextLine(  # lsid
        required=False,
        title=u'Taxon ID',
        description=u'''An identifier for the set of taxon information (data associated with the Taxon class). May be a global unique identifier or an identifier specific to the data set.

                Examples: "8fa58e08-08de-4ac1-b69c-1235340b7001", "32567", "http://species.gbif.org/abies_alba_1753", "urn:lsid:gbif.org:usages:32567"'''
    )

    vernacularName = schema.TextLine(  # common Name,
        required=False,
        title=u'Common Name',
        description=u'A common or vernacular name.',
    )
Exemple #6
0
class ISpeciesCollection(model.Schema):
    """
    a schema to drive the forms for species collections
    """
    genre = schema.Choice(
        title=_(u'Data Genre'),
        vocabulary=u'genre_source'
    )
class IRemoteDataset(IDataset):
    """A dateset hosted externally"""

    remoteUrl = TextLine(
        title=_(u'Content location'),
        description=u'',
        required=True,
        default=u'http://',
    )
Exemple #8
0
class ITraitsDataset(model.Schema):

    directives.mode(genre='hidden')
    genre = schema.Choice(
        title=_(u'Data Genre'),
        default='DataGenreTraits',
        vocabulary='genre_source',
        readonly=True,
        required=True,
    )
class IDatasetCollection(IDataset):
    """A collection of datasets"""

    # TODO: do I really want to use plone.app.relationfield here?
    parts = List(
        title=_(u"Parts"),
        description=u"",
        required=False,
        value_type=TextLine(),  # should we rather use ASCIILine for uuids?
        default=[])
Exemple #10
0
 def handleCreate(self, action):
     data, errors = self.extractData()
     self.validateAction(data)
     if errors:
         self.status = self.formErrorsMessage
         return
     # TODO: this is prob. a bug in base form, because createAndAdd
     #       does not return the wrapped object.
     obj = self.createAndAdd(data)
     if obj is None:
         # TODO: this is probably an error here?
         #       object creation/add failed for some reason
         return
     # get wrapped instance fo new object (see above)
     obj = self.context[obj.id]
     # mark only as finished if we get the new object
     self._finishedAdd = True
     IStatusMessage(self.request).addStatusMessage(_(u"Item created"),
                                                   "info")
Exemple #11
0
 def handleCreate(self, action):
     data, errors = self.extractData()
     self.validateAction(data)
     if errors:
         self.status = self.formErrorsMessage
         return
     # TODO: this is prob. a bug in base form, because createAndAdd
     #       does not return the wrapped object.
     obj = self.createAndAdd(data)
     if obj is None:
         # TODO: this is probably an error here?
         #       object creation/add failed for some reason
         return
     # get wrapped instance fo new object (see above)
     obj = self.context[obj.id]
     # mark only as finished if we get the new object
     self._finishedAdd = True
     IStatusMessage(self.request).addStatusMessage(_(u"Item created"),
                                                   "info")
Exemple #12
0
class ILayerDataset(model.Schema):

    # more fields;
    #-> projection, spatial units, spatial coverage,
    #-> pixel units, (value space)
    genre = schema.Choice(
        title=_(u'Data Genre'),
        vocabulary=u'genre_source'
    )

    domain = schema.Choice(
        title=u'Dataset Domain',
        vocabulary=u'domain_dataset_source',
        default=u'Terrestrialdatasets'
    )

    datatype = schema.Choice(
        required=False,
        title=u'Type of Dataset',
        vocabulary=u'datatype_source')

    resolution = schema.Choice(
        title=u'Resolution',
        required=True,
        vocabulary=u'resolution_source')

    resolutiono = schema.TextLine(
        required=False,
        title=u'Resolution (other)')

    emsc = schema.Choice(
        required=False,
        title=u'Emission Scenario',
        vocabulary=u'emsc_source')

    gcm = schema.Choice(
        required=False,
        title=u'Global Climate Model',
        vocabulary=u'gcm_source')
class ILayerDataset(form.Schema):

    # more fields;
    #-> projection, spatial units, spatial coverage,
    #-> pixel units, (value space)
    genre = schema.Choice(
        title=_(u'Data Genre'),
        vocabulary=u'genre_source'
    )

    datatype = schema.Choice(
        required=False,
        title=u'Type of Dataset',
        vocabulary=u'datatype_source')

    resolution = schema.Choice(
        title=u'Resolution',
        required=False,
        vocabulary=u'resolution_source')

    resolutiono = schema.TextLine(
        required=False,
        title=u'Resolution (other)')

    # TODO: ISO Date String, DC:Period?
    temporal = schema.TextLine(
        required=False,
        title=u'Temporal coverage')

    emsc = schema.Choice(
        required=False,
        title=u'Emission Scenario',
        vocabulary=u'emsc_source')

    gcm = schema.Choice(
        required=False,
        title=u'Global Climate Model',
        vocabulary=u'gcm_source')
Exemple #14
0
 def handleAdd(self, action):
     data, errors = self.extractData()
     self.validateAction(data)
     if errors:
         self.status = self.formErrorsMessage
         return
     # TODO: this is prob. a bug in base form, because createAndAdd
     #       does not return the wrapped object.
     obj = self.createAndAdd(data)
     if obj is None:
         # TODO: this is probably an error here?
         #       object creation/add failed for some reason
         return
     # get wrapped instance fo new object (see above)
     obj = self.context[obj.id]
     # mark only as finished if we get the new object
     self._finishedAdd = True
     IStatusMessage(self.request).addStatusMessage(_(u"Item created"),
                                                   "info")
     # auto start job here
     jt = IExperimentJobTracker(obj)
     msgtype, msg = jt.start_job(self.request)
     if msgtype is not None:
         IStatusMessage(self.request).add(msg, type=msgtype)
Exemple #15
0
 def handleAdd(self, action):
     data, errors = self.extractData()
     self.validateAction(data)
     if errors:
         self.status = self.formErrorsMessage
         return
     # TODO: this is prob. a bug in base form, because createAndAdd
     #       does not return the wrapped object.
     obj = self.createAndAdd(data)
     if obj is None:
         # TODO: this is probably an error here?
         #       object creation/add failed for some reason
         return
     # get wrapped instance fo new object (see above)
     obj = self.context[obj.id]
     # mark only as finished if we get the new object
     self._finishedAdd = True
     IStatusMessage(self.request).addStatusMessage(_(u"Item created"),
                                                   "info")
     # auto start job here
     jt = IExperimentJobTracker(obj)
     msgtype, msg = jt.start_job(self.request)
     if msgtype is not None:
         IStatusMessage(self.request).add(msg, type=msgtype)
Exemple #16
0
class IFunction(form.Schema):

    method = TextLine(
        title=_(u'Method'),
        description=_(
            u"Full dotted name of a python function implementing this algorithm"
        ),
        required=True)

    interpreter = Choice(
        title=_(u"Programming language"),
        description=_(u"The language the code is written in."),
        vocabulary="org.bccvl.site.programming_language_vocab",
        required=True,
    )

    script = Text(
        title=_(u"Script"),
        description=_(u"The code being executed"),
        required=True,
    )

    interface = DottedName(title=_(u'Interface'),
                           description=_(u"full package name to interface"),
                           required=True)

    schema = Text(
        title=_(u"Schema"),
        description=
        _(u"A dexterity schema describing the input parameters for the algorithm"
          ),
        required=True)

    output = Text(title=_(u"Output mapping"),
                  description=_(u"defines how to import experiment outputs"),
                  required=True)
Exemple #17
0
class Add(add.DefaultAddForm):
    """
    Add Experiment
    """

    template = ViewPageTemplateFile("experiment_add.pt")

    extends(view.DefaultView, ignoreButtons=True)

    buttons = button.Buttons(add.DefaultAddForm.buttons['cancel'])

    @button.buttonAndHandler(_('Create and start'), name='save')
    def handleAdd(self, action):
        data, errors = self.extractData()
        self.validateAction(data)
        if errors:
            self.status = self.formErrorsMessage
            return
        # TODO: this is prob. a bug in base form, because createAndAdd
        #       does not return the wrapped object.
        obj = self.createAndAdd(data)
        if obj is None:
            # TODO: this is probably an error here?
            #       object creation/add failed for some reason
            return
        # get wrapped instance fo new object (see above)
        obj = self.context[obj.id]
        # mark only as finished if we get the new object
        self._finishedAdd = True
        IStatusMessage(self.request).addStatusMessage(_(u"Item created"),
                                                      "info")
        # auto start job here
        jt = IExperimentJobTracker(obj)
        msgtype, msg = jt.start_job(self.request)
        if msgtype is not None:
            IStatusMessage(self.request).add(msg, type=msgtype)

    @button.buttonAndHandler(_('Create'), name='create')
    def handleCreate(self, action):
        data, errors = self.extractData()
        self.validateAction(data)
        if errors:
            self.status = self.formErrorsMessage
            return
        # TODO: this is prob. a bug in base form, because createAndAdd
        #       does not return the wrapped object.
        obj = self.createAndAdd(data)
        if obj is None:
            # TODO: this is probably an error here?
            #       object creation/add failed for some reason
            return
        # get wrapped instance fo new object (see above)
        obj = self.context[obj.id]
        # mark only as finished if we get the new object
        self._finishedAdd = True
        IStatusMessage(self.request).addStatusMessage(_(u"Item created"),
                                                      "info")

    def updateWidgets(self):
        super(Add, self).updateWidgets()

        # Pre-fill widget fields with field values from the specified SDM.
        uuid = self.request.get('uuid')
        if uuid:
            expobj = uuidToObject(uuid)
            self.widgets["IDublinCore.title"].value = expobj.title
            self.widgets["IDublinCore.description"].value = expobj.description
            for name in self.widgets.keys():
                if name not in [
                        "IDublinCore.title", "IDublinCore.description"
                ]:
                    conv = getMultiAdapter(
                        (self.fields[name].field, self.widgets[name]),
                        IDataConverter)
                    self.widgets[name].value = conv.toWidgetValue(
                        getattr(expobj, name))
Exemple #18
0
class IFunction(model.Schema):

    experiment_type = Choice(
        title=_(u"Experiment Type"),
        description=_(u"The experiment type this toolkit can be used for."),
        required=False,
        default=None,
        vocabulary='experiment_type_source')

    interpreter = Choice(
        title=_(u"Programming language"),
        description=_(u"The language the code is written in."),
        vocabulary="org.bccvl.site.programming_language_vocab",
        required=True,
    )

    directives.widget('script', rows=40)
    script = Text(
        title=_(u"Script"),
        description=_(u"The code being executed"),
        required=True,
    )

    directives.widget('schema', rows=40)
    schema = Text(
        title=_(u"Schema"),
        description=
        _(u"A dexterity schema describing the input parameters for the algorithm"
          ),
        required=True)

    directives.widget('output', rows=40)
    output = Text(title=_(u"Output mapping"),
                  description=_(u"defines how to import experiment outputs"),
                  required=True)

    algorithm_category = Choice(
        title=_(u"Algorithm Category"),
        description=_(u"The category an algorithm belongs to"),
        vocabulary="org.bccvl.site.algorithm_category_vocab",
        required=False,
    )