2019-03-22 15:51:44 +01:00
package org.gcube.resourcemanagement.model.reference.properties ;
import java.net.URI ;
2020-07-07 17:12:10 +02:00
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize ;
2019-03-22 15:51:44 +01:00
import org.gcube.informationsystem.types.annotations.ISProperty ;
2020-12-15 18:44:48 +01:00
import org.gcube.informationsystem.types.reference.Change ;
import org.gcube.informationsystem.types.reference.TypeMetadata ;
2021-10-21 12:50:29 +02:00
import org.gcube.informationsystem.utils.Version ;
2019-03-22 15:51:44 +01:00
import org.gcube.resourcemanagement.model.impl.properties.ValueSchemaImpl ;
import org.gcube.resourcemanagement.model.reference.properties.utilities.PropertyValidator ;
import org.gcube.resourcemanagement.model.reference.properties.utilities.ValidatedTypedProperty ;
import org.gcube.resourcemanagement.model.reference.properties.utilities.Validation ;
/ * *
2020-12-21 13:59:53 +01:00
* This type aims at exposing a value which can be automatically managed by any client with no knowledge of its format .
*
* The client can retrieve the schema at the provided URI , i . e . , schema property ,
* and use its content to understand / validate / manipulate the information contained in the value property .
* The client must have the capability to understand the semantics of content retrieved at the URI endpoint .
*
* Examples of application of such type are eXtensible Markup Language ( XML ) values which can be
* validated by a Document Type Definition ( DTD ) or XML Schema Definition ( XSD ) .
*
2019-03-22 15:51:44 +01:00
* @author Luca Frosini ( ISTI - CNR )
* /
@JsonDeserialize ( as = ValueSchemaImpl . class )
2020-12-15 18:44:48 +01:00
@TypeMetadata (
name = ValueSchema . NAME ,
2020-12-21 13:59:53 +01:00
description = " This type aims at exposing a value which can be automatically managed by any client with no knowledge of its format. " ,
2021-10-21 12:50:29 +02:00
version = Version . MINIMAL_VERSION_STRING
2020-12-15 18:44:48 +01:00
)
2021-10-21 12:50:29 +02:00
@Change ( version = Version . MINIMAL_VERSION_STRING , description = Version . MINIMAL_VERSION_DESCRIPTION )
2019-03-22 15:51:44 +01:00
public interface ValueSchema extends GCubeProperty , ValidatedTypedProperty < URI , String > {
public static final String NAME = " ValueSchema " ; //ValueSchema.class.getSimpleName();
@Override
default Validation validate ( ) {
return new SchemaValidator ( ) . validate ( this ) ;
}
/ * *
* Validator for { @link ValueSchema } properties .
* @author Manuele Simi ( ISTI CNR )
*
* /
class SchemaValidator implements PropertyValidator < ValueSchema > {
@Override
public Validation validate ( ValueSchema property ) {
//TODO validate the string against the URI!
return Validation . success ( " Accepted! " ) ;
}
}
2020-12-21 13:59:53 +01:00
/ * *
* The value which schema is available at the URI provided in the schema property .
* /
@ISProperty ( description = " The value which schema is available at the URI provided in the schema property. " , mandatory = true , nullable = false )
2019-03-22 15:51:44 +01:00
@Override
public String getValue ( ) ;
@Override
public void setValue ( String value ) ;
2020-12-21 13:59:53 +01:00
/ * *
* An URI containing a schema used to validate / interpret the content of the value .
* It is only an informative field . The validation is charge of the client .
* /
2021-02-23 15:19:23 +01:00
@ISProperty ( description = " An URI containing a schema used to validate/interpret the content of the value. It is only an informative field. The validation is in charge of the client. " ) //, mandatory=true, nullable=false)
2019-03-22 15:51:44 +01:00
@Override
2020-12-21 16:02:46 +01:00
public URI getSchema ( ) ;
2019-03-22 15:51:44 +01:00
@Override
2020-12-21 16:02:46 +01:00
public void setSchema ( URI schema ) ;
2019-03-22 15:51:44 +01:00
}