Compare commits
68 Commits
Author | SHA1 | Date |
---|---|---|
Luca Frosini | dc8595d13e | |
Luca Frosini | 8ac4511bde | |
Luca Frosini | 0559bc031f | |
Luca Frosini | 6eecea2ab1 | |
Luca Frosini | c68826637c | |
luca.frosini | acf51f9dfb | |
luca.frosini | ef74dd31ea | |
luca.frosini | 118e058c90 | |
luca.frosini | 6dc26a43b8 | |
luca.frosini | 8b7aa5660a | |
luca.frosini | 27854806df | |
luca.frosini | b05f0c51f3 | |
luca.frosini | 6db5256e70 | |
luca.frosini | b3cb92f55a | |
luca.frosini | 58b688a9ad | |
luca.frosini | 590be162b8 | |
luca.frosini | 185030acc2 | |
luca.frosini | 58e5e70db6 | |
luca.frosini | 9a32f3c534 | |
luca.frosini | d2b715a318 | |
luca.frosini | ff0c6aec9d | |
luca.frosini | d1d9ae4a4a | |
luca.frosini | e403b2459c | |
luca.frosini | 3895abdac3 | |
luca.frosini | f4761c0a6f | |
luca.frosini | 8594d113e0 | |
luca.frosini | 01a185894c | |
Luca Frosini | 1368f707c8 | |
Luca Frosini | f9137ffff9 | |
Luca Frosini | c36d76c19c | |
Luca Frosini | c48eae1355 | |
Luca Frosini | 05787952be | |
Luca Frosini | e6311a4f30 | |
Luca Frosini | 644dc86b66 | |
Luca Frosini | c222b74d44 | |
Luca Frosini | 2b1f3fa9a3 | |
Luca Frosini | ccb259432f | |
Luca Frosini | 5180428d24 | |
Luca Frosini | a511ae8209 | |
Luca Frosini | eb35bf947f | |
Luca Frosini | 409bf29cd4 | |
Luca Frosini | 4b06b1b6bc | |
Luca Frosini | 21407336bb | |
Luca Frosini | 12280dc9fd | |
Luca Frosini | b403ce9f85 | |
Luca Frosini | 4333855ebc | |
Luca Frosini | 86f015cb21 | |
Luca Frosini | a79ed8fd56 | |
Luca Frosini | ad6018d5fb | |
Luca Frosini | 10563e6b02 | |
Luca Frosini | 817c875b86 | |
Luca Frosini | 3511b7d248 | |
Luca Frosini | b26681665e | |
Luca Frosini | a5f2953fe7 | |
Luca Frosini | 49c04191db | |
Luca Frosini | 4562d463e8 | |
Luca Frosini | 941b47eb14 | |
Luca Frosini | 010e62f4fa | |
Luca Frosini | 4b18898fd0 | |
Luca Frosini | c7f6431d4c | |
Luca Frosini | d170e1707d | |
Luca Frosini | 60ef7ae655 | |
Luca Frosini | a977dc0faf | |
Luca Frosini | cba11607d0 | |
Luca Frosini | 3c3788f930 | |
Luca Frosini | 746748494a | |
Luca Frosini | 66af46bc5d | |
Luca Frosini | ec9e319792 |
|
@ -1,3 +1,4 @@
|
|||
target
|
||||
.classpath
|
||||
.project
|
||||
/.DS_Store
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/org.eclipse.jdt.core.prefs
|
||||
/org.eclipse.core.resources.prefs
|
||||
/org.eclipse.m2e.core.prefs
|
||||
/org.eclipse.jdt.ui.prefs
|
||||
|
|
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -2,6 +2,17 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for Information System Model
|
||||
|
||||
## [v7.1.0-SNAPSHOT]
|
||||
|
||||
- Improved support for model knowledge [#25922]
|
||||
|
||||
|
||||
## [v7.0.0]
|
||||
|
||||
- Reorganized E/R format [#24992]
|
||||
- Added missing expected type field when the provided type does not have the exact class in the classpath
|
||||
|
||||
|
||||
## [v6.0.0]
|
||||
|
||||
- Modified models discovery to make it easier and more powerful [#24548]
|
||||
|
|
413
docs/index.rst
413
docs/index.rst
|
@ -1,199 +1,5 @@
|
|||
#############################
|
||||
Information System (IS) Model
|
||||
#############################
|
||||
|
||||
This Model is part of research conducted in the context of a PhD. This wiki page represents just a partial view of the full rationale of the research. To have a complete overview of the rationale of the model, please refer to the PhD thesis which is publicly available at:
|
||||
|
||||
https://etd.adm.unipi.it/t/etd-05102019-114151/
|
||||
|
||||
https://openportal.isti.cnr.it/doc?id=people______::470484e51fcb9e307a418c800efc44c8
|
||||
|
||||
If you need to refer to such work you can cite the PhD Thesis.
|
||||
|
||||
.. code::
|
||||
|
||||
@phdthesis{frosini2019transactional,
|
||||
title={Transactional REST Information System for Federated Research Infrastructures enabling Virtual Research Environments},
|
||||
author={Frosini, Luca},
|
||||
year={2019},
|
||||
school={UNIVERSITÀ DI PISA}
|
||||
}
|
||||
|
||||
An previous paper about this work is:
|
||||
|
||||
|
||||
|
||||
.. code::
|
||||
|
||||
@article{frosini2018facet,
|
||||
title={A Facet-based Open and Extensible Resource Model for Research Data Infrastructures.},
|
||||
author={Frosini, Luca and Pagano, Pasquale},
|
||||
journal={Grey Journal (TGJ)},
|
||||
volume={14},
|
||||
number={2},
|
||||
year={2018}
|
||||
}
|
||||
|
||||
|
||||
|
||||
************
|
||||
The IS Model
|
||||
************
|
||||
|
||||
.. image:: ./is-model.png
|
||||
|
||||
.. image:: ./is-model-er.png
|
||||
|
||||
The Information System Model (henceforth IS Model) is a graph model with Entities as nodes and Relations as edges.
|
||||
|
||||
* Two typologies of entities are envisaged:
|
||||
|
||||
* Resources, i.e. entities representing a description of "thing" to be managed:
|
||||
|
||||
* Every Resource is described by a number of Facets.
|
||||
|
||||
* Facets, i.e. entities contributing to "build" a description of a Resource. Every facet, once attached to a Resource profile captures a certain aspect / characterization of the resource:
|
||||
|
||||
* Every facet is characterised by a number of properties.
|
||||
|
||||
* Two typologies of relations are envisaged:
|
||||
|
||||
* IsRelatedTo, i.e. a relation linking any two Resources.
|
||||
* ConsistsOf, i.e. a relation connecting each Resource with one of the Facets characterizing it;
|
||||
|
||||
* Each entity and relation:
|
||||
|
||||
* has an header automatically generated for the sake of identification and provenance of the specific information;
|
||||
* can be specialized
|
||||
|
||||
* A number of specializations are identified below. Such specializations are managed by the gCube Core services, i.e. Core services builds upon these specializations to realize its management tasks;
|
||||
* Other specializations can be defined by clients, the system make it possible to store these additional typologies of relations and facets and to discover them.
|
||||
|
||||
* Facet and Relation instances can have additional properties which are not defined in the schema (henceforth schema-mixed mode).
|
||||
* On relations:
|
||||
|
||||
* Any relation has a direction, i.e. a "source" (out bound of the relation) and a "target" (in bound of the relation). Anyway, the relation can be also navigated in the opposite direction;
|
||||
* It is not permitted to define a Relation having a Facet as "source". In other words:
|
||||
|
||||
* It is not permitted to define a Relation connecting a Facet with another one;
|
||||
* It is not permitted to define a Relation connecting a Facet with a Resource (as target);
|
||||
|
||||
* A Facet instance can be linked (by ConsistsOf or any specialization of it) from different Resources.
|
||||
|
||||
We derived the term Facet directly from the dictionary definition.
|
||||
Merriam Webster Dictionary defines facet as “any of the definable aspects that make up a subject
|
||||
(as of contemplation) or an object (as of consideration)” [#FacetMerriamWebsterDef]_ .
|
||||
|
||||
The Free Dictionary defines a facet as “One of numerous aspects, as of a subject” [#FacetFreeDictionaryDef]_ .
|
||||
|
||||
|
||||
|
||||
Type Attributes
|
||||
===============
|
||||
|
||||
Any Property defined in the schema is characterised by:
|
||||
|
||||
Name:
|
||||
Property Name
|
||||
|
||||
Type:
|
||||
The Type of the Property (e.g. String, Integer, ...). It can be a Basic Type or a Derived Type or a Complex Type
|
||||
|
||||
Description:
|
||||
The description of the Property. default=null.
|
||||
|
||||
Mandatory (M):
|
||||
Indicate if the Property is mandatory. default=false.
|
||||
|
||||
ReadOnly (RO):
|
||||
The Property cannot change its value. default=false.
|
||||
|
||||
NotNull (NN):
|
||||
Whether the property must assume a value diverse from 'null' or not. default=false
|
||||
|
||||
Max (Max):
|
||||
default=null
|
||||
|
||||
Min (Min):
|
||||
default=null
|
||||
|
||||
Regex (Reg)):
|
||||
A Regular Expression to validate the property value, default=null. A good online tool for regex is avalable at https://regex101.com/
|
||||
|
||||
|
||||
Basic Types
|
||||
-----------
|
||||
|
||||
.. table:: Basic Types
|
||||
|
||||
+----------+-------------------------------------------------------------------------------------------+-----------------------------------------------------------+
|
||||
| Type | Java type | Description |
|
||||
+==========+===========================================================================================+===========================================================+
|
||||
| Boolean | <code>java.lang.Boolean</code> or <code>boolean</code> | Handles only the values <em>True</em> or <em>False</em>. |
|
||||
+----------+-------------------------------------------------------------------------------------------+-----------------------------------------------------------+
|
||||
| Integer | <code>java.lang.Integer</code> or <code>int</code> or <code>java.math.BigInteger</code> | 32-bit signed Integers. |
|
||||
+----------+-------------------------------------------------------------------------------------------+-----------------------------------------------------------+
|
||||
| Short | <code>java.lang.Short</code> or <code>short</code> | Small 16-bit signed integers. |
|
||||
+----------+-------------------------------------------------------------------------------------------+-----------------------------------------------------------+
|
||||
| Long | <code>java.lang.Long</code> or <code>long</code> | Big 64-bit signed integers. |
|
||||
+----------+-------------------------------------------------------------------------------------------+-----------------------------------------------------------+
|
||||
| Float | <code>java.lang.Float</code> or <code>float</code> | Decimal numbers. |
|
||||
+----------+-------------------------------------------------------------------------------------------+-----------------------------------------------------------+
|
||||
| Double | <code>java.lang.Double</code> or <code>double</code> | Decimal numbers with high precision. |
|
||||
+----------+-------------------------------------------------------------------------------------------+-----------------------------------------------------------+
|
||||
| Date | <code>java.util.Date</code> | Any date with the precision up to milliseconds. |
|
||||
+----------+-------------------------------------------------------------------------------------------+-----------------------------------------------------------+
|
||||
| String | <code>java.lang.String</code> | Any string as alphanumeric sequence of chars. |
|
||||
+----------+-------------------------------------------------------------------------------------------+-----------------------------------------------------------+
|
||||
| Byte | <code>java.lang.Byte</code> or <code>byte</code> | Single byte. useful to store small 8-bit signed integers. |
|
||||
+----------+-------------------------------------------------------------------------------------------+-----------------------------------------------------------+
|
||||
| Binary | <code>java.lang.Byte[]</code> or <code>byte[]</code> | Can contain any value as byte array. |
|
||||
+----------+-------------------------------------------------------------------------------------------+-----------------------------------------------------------+
|
||||
|
||||
|
||||
|
||||
Derived Types
|
||||
-------------
|
||||
|
||||
The following are obtained using a String as real type and adding a validation regex.
|
||||
|
||||
.. table:: Derived Types
|
||||
|
||||
+--------------+-------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Type | Java type | Description |
|
||||
+==============+=============================================================+=============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================+
|
||||
| Enum | <code>java.lang.Enum</code> or <code>enum</code> | By default it is represented using the String representation of the Enum. So that the primitive type used will be String. The enumeration is checked by setting <code>Regexpr</code> property. The Regular Expression is auto-generated and it will be something like <code>^(FIRST-ENUM-STRING_REPRESENTATION SECOND-ENUM-STRING_REPRESENTATION... LAST_ENUM_STRING_REPRESENTATION)$</code>. Otherwise (if indicated using an annotation), it can be represented using the Integer value of the Enum. So that the primitive type used will be Integer. The enumeration is checked using <code>Max</code> and <code>Min</code> properties. |
|
||||
+--------------+-------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| UUID | <code>java.util.UUID</code> | String representation of the UUID. The check is obtained using the regular expression ^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}$ |
|
||||
+--------------+-------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| URL | <code>java.net.URL</code> | String representation of the URL. No check actually. |
|
||||
+--------------+-------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| URI | <code>java.net.URI</code> | String representation of the URI. No check actually. |
|
||||
+--------------+-------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| TypeVersion | <code>org.gcube.informationsystem.utils.TypeVersion</code> | A type representing and validating a version in the following format X.X.X Major(Integer).Minor(Integer).Revision(Integer) (e.g 1.0.0, 2.3.0, 2.0.1). The check is obtained using the regular expression '''<code>^[1-9][0-9]{0,}\.(0 |
|
||||
+--------------+-------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
|
||||
|
||||
Complex Types
|
||||
-------------
|
||||
|
||||
Any property defined by composing basic types, complex types and other complex types. Any complex type can be defined by extending Property type.
|
||||
|
||||
.. table:: Complex Types
|
||||
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Type | Java type | Description |
|
||||
+===========================+=================================================================================================================+===================================================================================================================================================================+
|
||||
| Property | <code>? extends org.gcube.informationsystem.model.reference.properties.Property</code> | This is an Object contained inside the owner Entity and has no Header. It is reachable only by navigating the owner Entity/Relation. |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| <del>Property list</del> | <del><code>List<? extends org.gcube.informationsystem.model.reference.properties.Property></code></del> | <del>List of Objects contained inside the owner Entity and have no Header. They are reachable only by navigating the owner Entity/Relation.</del> |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| <del>Property set</del> | <del><code>Set<? org.gcube.informationsystem.model.reference.properties.Property></code></del> | <del>Set (no duplicates) of Objects contained inside the owner Entity and have no Header. They are reachable only by navigating the owner Entity/Relation.</del> |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Property map | <code>Map<String, ? extends org.gcube.informationsystem.model.reference.properties.Propertyd></code> | Map of Objects contained inside the owner Entity and have no Header. They are reachable only by navigating the owner Entity/Relation. |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
.. _Property:
|
||||
|
||||
Property
|
||||
========
|
||||
|
@ -217,36 +23,62 @@ Changelog:
|
|||
* **1.0.0**: First Version.
|
||||
|
||||
|
||||
Header
|
||||
------
|
||||
.. _Encrypted:
|
||||
|
||||
This type provides metadata per every IdentifiableElement
|
||||
Encrypted
|
||||
---------
|
||||
|
||||
This type is used to properly manage values must be stored safely (e.g. encrypted) in the IS.
|
||||
|
||||
|
||||
.. table:: **Header** ``extends`` **Property**
|
||||
.. table:: **Encrypted** ``extends`` **Property**
|
||||
|
||||
+----------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Name | Type | Attributes | Description |
|
||||
+================+========+====================================================================================================================================================+=========================================================================================================================================+
|
||||
| createdBy | String | ``Mandatory:true`` ``ReadOnly:true`` ``NotNull:true`` | The user that created the Entity or the Relation. It is initialized at Creation Time. |
|
||||
+----------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| creationTime | Date | ``Mandatory:true`` ``ReadOnly:true`` ``NotNull:true`` | Creation time. It is represented in the format yyyy-MM-dd HH:mm:ss.SSS Z. |
|
||||
+----------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| lastUpdateBy | String | ``Mandatory:true`` ``ReadOnly:false`` ``NotNull:true`` | The user that made the last update to the Entity or the Relation. At Creation Time, it assumes the same value of createdBy. |
|
||||
+----------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| lastUpdateTime | Date | ``Mandatory:true`` ``ReadOnly:false`` ``NotNull:true`` | Last Update time. At creation time it assumes the same value of creationTime. It is represented in the format yyyy-MM-dd HH:mm:ss.SSS Z |
|
||||
+----------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| uuid | String | ``Mandatory:true`` ``ReadOnly:true`` ``NotNull:true`` ``Regex:^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}$`` | This UUID is be used to identify the Entity or the Relation univocally. |
|
||||
+----------------+--------+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
+-------+--------+--------------------------------------------------------+-------------------------------------+
|
||||
| Name | Type | Attributes | Description |
|
||||
+=======+========+========================================================+=====================================+
|
||||
| value | String | ``Mandatory:true`` ``ReadOnly:false`` ``NotNull:true`` | The value to store safely in the IS |
|
||||
+-------+--------+--------------------------------------------------------+-------------------------------------+
|
||||
|
||||
|
||||
The **Header** current version is 1.0.0.
|
||||
The **Encrypted** current version is 1.0.0.
|
||||
|
||||
Changelog:
|
||||
|
||||
* **1.0.0**: First Version.
|
||||
|
||||
|
||||
.. _Metadata:
|
||||
|
||||
Metadata
|
||||
--------
|
||||
|
||||
This type provides metadata per every IdentifiableElement
|
||||
|
||||
|
||||
.. table:: **Metadata** ``extends`` **Property**
|
||||
|
||||
+----------------+--------+--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Name | Type | Attributes | Description |
|
||||
+================+========+========================================================+=========================================================================================================================================+
|
||||
| createdBy | String | ``Mandatory:true`` ``ReadOnly:true`` ``NotNull:true`` | The user that created the Entity or the Relation. It is initialized at Creation Time. |
|
||||
+----------------+--------+--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| creationTime | Date | ``Mandatory:true`` ``ReadOnly:true`` ``NotNull:true`` | Creation time. It is represented in the format yyyy-MM-dd HH:mm:ss.SSS Z. |
|
||||
+----------------+--------+--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| lastUpdateBy | String | ``Mandatory:true`` ``ReadOnly:false`` ``NotNull:true`` | The user that made the last update to the Entity or the Relation. At Creation Time, it assumes the same value of createdBy. |
|
||||
+----------------+--------+--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| lastUpdateTime | Date | ``Mandatory:true`` ``ReadOnly:false`` ``NotNull:true`` | Last Update time. At creation time it assumes the same value of creationTime. It is represented in the format yyyy-MM-dd HH:mm:ss.SSS Z |
|
||||
+----------------+--------+--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
|
||||
The **Metadata** current version is 1.0.0.
|
||||
|
||||
Changelog:
|
||||
|
||||
* **1.0.0**: First Version.
|
||||
|
||||
|
||||
.. _PropagationConstraint:
|
||||
|
||||
PropagationConstraint
|
||||
---------------------
|
||||
|
||||
|
@ -274,27 +106,7 @@ Changelog:
|
|||
* **1.0.0**: First Version;
|
||||
|
||||
|
||||
Vault
|
||||
-----
|
||||
|
||||
This type is used to properly manage values must be stored safely (e.g. encrypted) in the IS.
|
||||
|
||||
|
||||
.. table:: **Vault** ``extends`` **Property**
|
||||
|
||||
+-------+--------+--------------------------------------------------------+-------------------------------------+
|
||||
| Name | Type | Attributes | Description |
|
||||
+=======+========+========================================================+=====================================+
|
||||
| value | String | ``Mandatory:true`` ``ReadOnly:false`` ``NotNull:true`` | The value to store safely in the IS |
|
||||
+-------+--------+--------------------------------------------------------+-------------------------------------+
|
||||
|
||||
|
||||
The **Vault** current version is 1.0.0.
|
||||
|
||||
Changelog:
|
||||
|
||||
* **1.0.0**: First Version.
|
||||
|
||||
.. _Entity:
|
||||
|
||||
Entity
|
||||
======
|
||||
|
@ -304,13 +116,15 @@ This is the base type for any Entity
|
|||
|
||||
.. table:: **Entity**
|
||||
|
||||
+------------+----------+--------------------------------------------------------+--------------------------------------------------------------------------------------------+
|
||||
| Properties |
|
||||
+============+==========+========================================================+============================================================================================+
|
||||
| **Name** | **Type** | **Attributes** | **Description** |
|
||||
+------------+----------+--------------------------------------------------------+--------------------------------------------------------------------------------------------+
|
||||
| header | Header | ``Mandatory:true`` ``ReadOnly:false`` ``NotNull:true`` | Metadata associated with the instance that is automatically created/updated by the system. |
|
||||
+------------+----------+--------------------------------------------------------+--------------------------------------------------------------------------------------------+
|
||||
+------------+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------+
|
||||
| Properties |
|
||||
+============+============================+====================================================================================================================================================+============================================================================================+
|
||||
| **Name** | **Type** | **Attributes** | **Description** |
|
||||
+------------+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------+
|
||||
| id | String | ``Mandatory:true`` ``ReadOnly:true`` ``NotNull:true`` ``Regex:^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}$`` | This UUID is be used to identify the instance univocally. |
|
||||
+------------+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------+
|
||||
| metadata | :ref:`Metadata <Metadata>` | ``Mandatory:true`` ``ReadOnly:false`` ``NotNull:true`` | Metadata associated with the instance that is automatically created/updated by the system. |
|
||||
+------------+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------+
|
||||
|
||||
|
||||
The **Entity** current version is 1.0.0.
|
||||
|
@ -320,6 +134,8 @@ Changelog:
|
|||
* **1.0.0**: First Version.
|
||||
|
||||
|
||||
.. _Resource:
|
||||
|
||||
Resource
|
||||
--------
|
||||
|
||||
|
@ -348,6 +164,8 @@ Changelog:
|
|||
* **1.0.0**: First Version.
|
||||
|
||||
|
||||
.. _Facet:
|
||||
|
||||
Facet
|
||||
-----
|
||||
|
||||
|
@ -378,6 +196,8 @@ Changelog:
|
|||
* **1.0.0**: First Version.
|
||||
|
||||
|
||||
.. _Relation:
|
||||
|
||||
Relation
|
||||
========
|
||||
|
||||
|
@ -386,19 +206,19 @@ This is the base type for any Relation
|
|||
|
||||
.. table:: **Relation**
|
||||
|
||||
+-----------------------+-----------------------+----------------------------------------------------------+-----------------+----------------------------------------+
|
||||
| **Definition** |
|
||||
+=======================+=======================+==========================================================+=================+========================================+
|
||||
| **Source** | **Relation** | **Multiplicity** | **Target** | **Description** |
|
||||
+-----------------------+-----------------------+----------------------------------------------------------+-----------------+----------------------------------------+
|
||||
| Resource | Relation | 0..n | Entity | This is the base type for any Relation |
|
||||
+-----------------------+-----------------------+----------------------------------------------------------+-----------------+----------------------------------------+
|
||||
| **Properties** |
|
||||
+-----------------------+-----------------------+----------------------------------------------------------+-----------------+----------------------------------------+
|
||||
| **Name** | **Type** | **Attributes** | **Description** |
|
||||
+-----------------------+-----------------------+----------------------------------------------------------+-----------------+----------------------------------------+
|
||||
| propagationConstraint | PropagationConstraint | ``Mandatory:false`` ``ReadOnly:false`` ``NotNull:false`` | |
|
||||
+-----------------------+-----------------------+----------------------------------------------------------+-----------------+----------------------------------------+
|
||||
+----------------------------+------------------------------------------------------+----------------------------------------------------------+------------------------+----------------------------------------+
|
||||
| **Definition** |
|
||||
+============================+======================================================+==========================================================+========================+========================================+
|
||||
| **Source** | **Relation** | **Multiplicity** | **Target** | **Description** |
|
||||
+----------------------------+------------------------------------------------------+----------------------------------------------------------+------------------------+----------------------------------------+
|
||||
| :ref:`Resource <Resource>` | :ref:`Relation <Relation>` | 0..n | :ref:`Entity <Entity>` | This is the base type for any Relation |
|
||||
+----------------------------+------------------------------------------------------+----------------------------------------------------------+------------------------+----------------------------------------+
|
||||
| **Properties** |
|
||||
+----------------------------+------------------------------------------------------+----------------------------------------------------------+------------------------+----------------------------------------+
|
||||
| **Name** | **Type** | **Attributes** | **Description** |
|
||||
+----------------------------+------------------------------------------------------+----------------------------------------------------------+------------------------+----------------------------------------+
|
||||
| propagationConstraint | :ref:`PropagationConstraint <PropagationConstraint>` | ``Mandatory:false`` ``ReadOnly:false`` ``NotNull:false`` | |
|
||||
+----------------------------+------------------------------------------------------+----------------------------------------------------------+------------------------+----------------------------------------+
|
||||
|
||||
|
||||
The **Relation** current version is 1.0.0.
|
||||
|
@ -408,6 +228,8 @@ Changelog:
|
|||
* **1.0.0**: First Version.
|
||||
|
||||
|
||||
.. _IsRelatedTo:
|
||||
|
||||
IsRelatedTo
|
||||
-----------
|
||||
|
||||
|
@ -416,25 +238,25 @@ This is the base type for any IsRelatedTo relation
|
|||
|
||||
.. table:: **IsRelatedTo** ``extends`` **Relation**
|
||||
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+----------------------------------------------------+
|
||||
| **Definition** |
|
||||
+======================================================+==============+==================+=================+====================================================+
|
||||
| **Source** | **Relation** | **Multiplicity** | **Target** | **Description** |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+----------------------------------------------------+
|
||||
| Resource | IsRelatedTo | 0..n | Resource | This is the base type for any IsRelatedTo relation |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+----------------------------------------------------+
|
||||
| **Properties** |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+----------------------------------------------------+
|
||||
| **Name** | **Type** | **Attributes** | **Description** |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+----------------------------------------------------+
|
||||
| This type does not define any additional attributes. |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+----------------------------------------------------+
|
||||
| **Known Usage** |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+----------------------------------------------------+
|
||||
| **Source** | **Relation** | **Multiplicity** | **Target** | **Description** |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+----------------------------------------------------+
|
||||
| No specific known usage for this type. |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+----------------------------------------------------+
|
||||
+------------------------------------------------------+----------------------------------+------------------+----------------------------+----------------------------------------------------+
|
||||
| **Definition** |
|
||||
+======================================================+==================================+==================+============================+====================================================+
|
||||
| **Source** | **Relation** | **Multiplicity** | **Target** | **Description** |
|
||||
+------------------------------------------------------+----------------------------------+------------------+----------------------------+----------------------------------------------------+
|
||||
| :ref:`Resource <Resource>` | :ref:`IsRelatedTo <IsRelatedTo>` | 0..n | :ref:`Resource <Resource>` | This is the base type for any IsRelatedTo relation |
|
||||
+------------------------------------------------------+----------------------------------+------------------+----------------------------+----------------------------------------------------+
|
||||
| **Properties** |
|
||||
+------------------------------------------------------+----------------------------------+------------------+----------------------------+----------------------------------------------------+
|
||||
| **Name** | **Type** | **Attributes** | **Description** |
|
||||
+------------------------------------------------------+----------------------------------+------------------+----------------------------+----------------------------------------------------+
|
||||
| This type does not define any additional attributes. |
|
||||
+------------------------------------------------------+----------------------------------+------------------+----------------------------+----------------------------------------------------+
|
||||
| **Known Usage** |
|
||||
+------------------------------------------------------+----------------------------------+------------------+----------------------------+----------------------------------------------------+
|
||||
| **Source** | **Relation** | **Multiplicity** | **Target** | **Description** |
|
||||
+------------------------------------------------------+----------------------------------+------------------+----------------------------+----------------------------------------------------+
|
||||
| No specific known usage for this type. |
|
||||
+------------------------------------------------------+----------------------------------+------------------+----------------------------+----------------------------------------------------+
|
||||
|
||||
|
||||
The **IsRelatedTo** current version is 1.0.0.
|
||||
|
@ -444,6 +266,8 @@ Changelog:
|
|||
* **1.0.0**: First Version.
|
||||
|
||||
|
||||
.. _ConsistsOf:
|
||||
|
||||
ConsistsOf
|
||||
----------
|
||||
|
||||
|
@ -452,25 +276,25 @@ This is the base type for any ConsistsOf relation
|
|||
|
||||
.. table:: **ConsistsOf** ``extends`` **Relation**
|
||||
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+---------------------------------------------------+
|
||||
| **Definition** |
|
||||
+======================================================+==============+==================+=================+===================================================+
|
||||
| **Source** | **Relation** | **Multiplicity** | **Target** | **Description** |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+---------------------------------------------------+
|
||||
| Resource | ConsistsOf | 0..n | Facet | This is the base type for any ConsistsOf relation |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+---------------------------------------------------+
|
||||
| **Properties** |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+---------------------------------------------------+
|
||||
| **Name** | **Type** | **Attributes** | **Description** |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+---------------------------------------------------+
|
||||
| This type does not define any additional attributes. |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+---------------------------------------------------+
|
||||
| **Known Usage** |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+---------------------------------------------------+
|
||||
| **Source** | **Relation** | **Multiplicity** | **Target** | **Description** |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+---------------------------------------------------+
|
||||
| No specific known usage for this type. |
|
||||
+------------------------------------------------------+--------------+------------------+-----------------+---------------------------------------------------+
|
||||
+------------------------------------------------------+--------------------------------+------------------+----------------------+---------------------------------------------------+
|
||||
| **Definition** |
|
||||
+======================================================+================================+==================+======================+===================================================+
|
||||
| **Source** | **Relation** | **Multiplicity** | **Target** | **Description** |
|
||||
+------------------------------------------------------+--------------------------------+------------------+----------------------+---------------------------------------------------+
|
||||
| :ref:`Resource <Resource>` | :ref:`ConsistsOf <ConsistsOf>` | 0..n | :ref:`Facet <Facet>` | This is the base type for any ConsistsOf relation |
|
||||
+------------------------------------------------------+--------------------------------+------------------+----------------------+---------------------------------------------------+
|
||||
| **Properties** |
|
||||
+------------------------------------------------------+--------------------------------+------------------+----------------------+---------------------------------------------------+
|
||||
| **Name** | **Type** | **Attributes** | **Description** |
|
||||
+------------------------------------------------------+--------------------------------+------------------+----------------------+---------------------------------------------------+
|
||||
| This type does not define any additional attributes. |
|
||||
+------------------------------------------------------+--------------------------------+------------------+----------------------+---------------------------------------------------+
|
||||
| **Known Usage** |
|
||||
+------------------------------------------------------+--------------------------------+------------------+----------------------+---------------------------------------------------+
|
||||
| **Source** | **Relation** | **Multiplicity** | **Target** | **Description** |
|
||||
+------------------------------------------------------+--------------------------------+------------------+----------------------+---------------------------------------------------+
|
||||
| No specific known usage for this type. |
|
||||
+------------------------------------------------------+--------------------------------+------------------+----------------------+---------------------------------------------------+
|
||||
|
||||
|
||||
The **ConsistsOf** current version is 1.0.0.
|
||||
|
@ -479,8 +303,3 @@ Changelog:
|
|||
|
||||
* **1.0.0**: First Version.
|
||||
|
||||
|
||||
.. rubric:: Footnotes
|
||||
|
||||
.. [#FacetMerriamWebsterDef] https://www.merriam-webster.com/dictionary/facet
|
||||
.. [#FacetFreeDictionaryDef] https://www.thefreedictionary.com/facet
|
||||
|
|
12
pom.xml
12
pom.xml
|
@ -10,7 +10,7 @@
|
|||
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>information-system-model</artifactId>
|
||||
<version>6.0.0</version>
|
||||
<version>7.1.0-SNAPSHOT</version>
|
||||
<name>Information System Model</name>
|
||||
<description>Information System Model is the reference model of the gCube Information System</description>
|
||||
<packaging>jar</packaging>
|
||||
|
@ -31,7 +31,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-bom</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.4.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -60,8 +60,14 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-utils</artifactId>
|
||||
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
|
||||
<version>[2.2.0, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.io.StringWriter;
|
|||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||
import org.gcube.informationsystem.utils.TypeUtility;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -20,6 +21,12 @@ public class ElementImpl implements Element {
|
|||
*/
|
||||
private static final long serialVersionUID = 7338083489551084860L;
|
||||
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TypeUtility.getTypeName(this.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
|
@ -30,4 +37,5 @@ public class ElementImpl implements Element {
|
|||
return super.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package org.gcube.informationsystem.base.impl.entities;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import org.gcube.informationsystem.base.impl.ElementImpl;
|
||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||
|
||||
/**
|
||||
|
@ -19,20 +20,31 @@ public abstract class EntityElementImpl extends ElementImpl implements EntityEle
|
|||
*/
|
||||
private static final long serialVersionUID = -4488771434017342703L;
|
||||
|
||||
protected Header header;
|
||||
protected UUID uuid;
|
||||
protected Metadata metadata;
|
||||
|
||||
protected EntityElementImpl(){
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Header getHeader() {
|
||||
return header;
|
||||
public UUID getID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setID(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeader(Header header){
|
||||
this.header = header;
|
||||
public Metadata getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(Metadata metadata){
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,7 +55,7 @@ public abstract class EntityElementImpl extends ElementImpl implements EntityEle
|
|||
return stringWriter.toString();
|
||||
}catch(Exception e){
|
||||
try {
|
||||
ElementMapper.marshal(this.header, stringWriter);
|
||||
ElementMapper.marshal(this.metadata, stringWriter);
|
||||
return stringWriter.toString();
|
||||
} catch(Exception e1){
|
||||
return super.toString();
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.informationsystem.base.impl.properties;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -24,21 +25,34 @@ public class PropertyElementImpl extends ElementImpl implements Property {
|
|||
*/
|
||||
private static final long serialVersionUID = 1396998430221747445L;
|
||||
|
||||
protected List<String> supertypes;
|
||||
protected String expectedtype;
|
||||
|
||||
@JsonIgnore
|
||||
protected Map<String, Object> additionalProperties;
|
||||
|
||||
@JsonIgnore
|
||||
/**
|
||||
* Used to allow to have an additional property starting with '_' or '@'
|
||||
*/
|
||||
@JsonIgnore
|
||||
protected final Set<String> allowedAdditionalKeys;
|
||||
|
||||
public PropertyElementImpl() {
|
||||
super();
|
||||
this.additionalProperties = new HashMap<>();
|
||||
this.allowedAdditionalKeys = new HashSet<>();
|
||||
this.allowedAdditionalKeys.add(SUPERCLASSES_PROPERTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertypes() {
|
||||
return this.supertypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpectedtype() {
|
||||
return this.expectedtype;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
|
@ -75,7 +89,7 @@ public class PropertyElementImpl extends ElementImpl implements Property {
|
|||
if(value instanceof Map<?,?>) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> map = (Map<String,Object>) value;
|
||||
if(map.containsKey(Element.CLASS_PROPERTY)) {
|
||||
if(map.containsKey(Element.TYPE_PROPERTY)) {
|
||||
String reserialized = ElementMapper.getObjectMapper().writeValueAsString(map);
|
||||
Property property = ElementMapper.unmarshal(Property.class, reserialized);
|
||||
value = property;
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package org.gcube.informationsystem.base.impl.relations;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import org.gcube.informationsystem.base.impl.ElementImpl;
|
||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -17,7 +19,8 @@ public abstract class RelationElementImpl<S extends EntityElement, T extends Ent
|
|||
*/
|
||||
private static final long serialVersionUID = 28704968813390512L;
|
||||
|
||||
protected Header header;
|
||||
protected UUID uuid;
|
||||
protected Metadata metadata;
|
||||
|
||||
protected S source;
|
||||
protected T target;
|
||||
|
@ -25,21 +28,31 @@ public abstract class RelationElementImpl<S extends EntityElement, T extends Ent
|
|||
protected RelationElementImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
protected RelationElementImpl(S source, T target) {
|
||||
this();
|
||||
this.source = source;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Header getHeader() {
|
||||
return header;
|
||||
public void setID(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeader(Header header){
|
||||
this.header = header;
|
||||
public Metadata getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(Metadata metadata){
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -81,6 +81,7 @@ public enum AccessType {
|
|||
private static Logger logger = LoggerFactory.getLogger(AccessType.class);
|
||||
|
||||
private static AccessType[] modelTypes;
|
||||
private static AccessType[] erTypes;
|
||||
private static Set<String> names;
|
||||
|
||||
static {
|
||||
|
@ -96,6 +97,11 @@ public enum AccessType {
|
|||
AccessType.RESOURCE, AccessType.FACET,
|
||||
AccessType.IS_RELATED_TO, AccessType.CONSISTS_OF
|
||||
};
|
||||
|
||||
erTypes = new AccessType[] {
|
||||
AccessType.RESOURCE, AccessType.FACET,
|
||||
AccessType.IS_RELATED_TO, AccessType.CONSISTS_OF
|
||||
};
|
||||
}
|
||||
|
||||
private final Class<? extends Element> clz;
|
||||
|
@ -186,8 +192,20 @@ public enum AccessType {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an array of AccessTypes containing only
|
||||
* Model Types (i.e. Property, Resource, Facet, IsRelatedTo, ConsistsOf)
|
||||
*/
|
||||
public static AccessType[] getModelTypes() {
|
||||
return modelTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an array of AccessTypes containing only
|
||||
* Entity/Relation Model Types (i.e. Resource, Facet, IsRelatedTo, ConsistsOf)
|
||||
*/
|
||||
public static AccessType[] getERTypes() {
|
||||
return erTypes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ package org.gcube.informationsystem.base.reference;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
|
@ -15,21 +17,23 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Abstract
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = Element.CLASS_PROPERTY)
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY })
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = Element.TYPE_PROPERTY)
|
||||
// @JsonTypeIdResolver(ElementTypeIdResolver.class)
|
||||
@TypeMetadata(name = Element.NAME, description = "This is the base class for Element", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = Element.NAME, description = "This is the base type for Element", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface Element extends Serializable {
|
||||
|
||||
public static final String NAME = "Element"; //Element.class.getSimpleName();
|
||||
|
||||
public static final String CLASS_PROPERTY = "@class";
|
||||
|
||||
public static final String SUPERCLASSES_PROPERTY = "@superClasses";
|
||||
public static final String TYPE_PROPERTY = "type";
|
||||
|
||||
/**
|
||||
* DateTime Pattern to be used to serialize Dates in every element
|
||||
*/
|
||||
public static final String DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS Z";
|
||||
|
||||
@JsonIgnore
|
||||
public String getTypeName();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +1,36 @@
|
|||
package org.gcube.informationsystem.base.reference;
|
||||
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
|
||||
/**
|
||||
* This interfaces is an helper to identify elements could be identified via {@link Header}
|
||||
* This interfaces is an helper to identify elements could be identified via {@link Metadata}
|
||||
*
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY })
|
||||
public interface IdentifiableElement extends Element {
|
||||
|
||||
public static final String HEADER_PROPERTY = "header";
|
||||
|
||||
public Header getHeader();
|
||||
public static final String ID_PROPERTY = "id";
|
||||
public static final String METADATA_PROPERTY = "metadata";
|
||||
|
||||
@JsonGetter(value = ID_PROPERTY)
|
||||
public UUID getID();
|
||||
|
||||
@JsonSetter(value = ID_PROPERTY)
|
||||
public void setID(UUID uuid);
|
||||
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonGetter(value = METADATA_PROPERTY)
|
||||
public Metadata getMetadata();
|
||||
|
||||
@JsonSetter(value = METADATA_PROPERTY)
|
||||
public void setMetadata(Metadata metadata);
|
||||
|
||||
public void setHeader(Header header);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package org.gcube.informationsystem.base.reference.entities;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
|
@ -15,16 +18,26 @@ import org.gcube.informationsystem.utils.Version;
|
|||
*/
|
||||
@Abstract
|
||||
@JsonIgnoreProperties(ignoreUnknown=true)
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY })
|
||||
//@JsonDeserialize(as=EntityElementImpl.class) Do not uncomment to manage subclasses
|
||||
@TypeMetadata(name = EntityElement.NAME, description = "This is the base class for any EntityElement", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = EntityElement.NAME, description = "This is the base type for any EntityElement", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface EntityElement extends Element, IdentifiableElement {
|
||||
|
||||
public static final String NAME = "EntityElement"; //Entity.class.getSimpleName();
|
||||
|
||||
/* Overriding getHeader method to create Header property in type */
|
||||
@ISProperty(name=HEADER_PROPERTY, mandatory=true, nullable=false, description="Metadata associated with the instance that is automatically created/updated by the system.")
|
||||
@ISProperty(name = ID_PROPERTY, description = "This UUID is be used to identify the instance univocally.", readonly = true, mandatory = true, nullable = false)
|
||||
@Override
|
||||
public Header getHeader();
|
||||
public UUID getID();
|
||||
|
||||
@Override
|
||||
public void setID(UUID uuid);
|
||||
|
||||
@ISProperty(name=METADATA_PROPERTY, mandatory=true, nullable=false, description="Metadata associated with the instance that is automatically created/updated by the system.")
|
||||
@Override
|
||||
public Metadata getMetadata();
|
||||
|
||||
@Override
|
||||
public void setMetadata(Metadata metadata);
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonDeserialize(as=PropertyElementImpl.class)
|
||||
@TypeMetadata(name = PropertyElement.NAME, description = "This is the base class for any PropertyElement", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = PropertyElement.NAME, description = "This is the base type for any PropertyElement", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface PropertyElement extends Element {
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package org.gcube.informationsystem.base.reference.relations;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
|
@ -17,7 +19,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
*/
|
||||
@Abstract
|
||||
//@JsonDeserialize(as=RelationElementImpl.class) Do not uncomment to manage subclasses
|
||||
@TypeMetadata(name = RelationElement.NAME, description = "This is the base class for any RelationElement", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = RelationElement.NAME, description = "This is the base type for any RelationElement", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface RelationElement<S extends EntityElement, T extends EntityElement> extends Element, IdentifiableElement {
|
||||
|
||||
|
@ -26,10 +28,19 @@ public interface RelationElement<S extends EntityElement, T extends EntityElemen
|
|||
public static final String SOURCE_PROPERTY = "source";
|
||||
public static final String TARGET_PROPERTY = "target";
|
||||
|
||||
/* Overriding getHeader method to create Header property in type */
|
||||
@ISProperty(name = HEADER_PROPERTY, mandatory = true, nullable = false)
|
||||
@ISProperty(name = ID_PROPERTY, description = "This UUID is be used to identify the instance univocally.", readonly = true, mandatory = true, nullable = false)
|
||||
@Override
|
||||
public Header getHeader();
|
||||
public UUID getID();
|
||||
|
||||
@Override
|
||||
public void setID(UUID uuid);
|
||||
|
||||
@ISProperty(name=METADATA_PROPERTY, mandatory=true, nullable=false, description="Metadata associated with the instance that is automatically created/updated by the system.")
|
||||
@Override
|
||||
public Metadata getMetadata();
|
||||
|
||||
@Override
|
||||
public void setMetadata(Metadata metadata);
|
||||
|
||||
@JsonGetter(value=SOURCE_PROPERTY)
|
||||
public S getSource();
|
||||
|
|
|
@ -4,17 +4,25 @@
|
|||
package org.gcube.informationsystem.contexts.impl.entities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.gcube.informationsystem.base.impl.entities.EntityElementImpl;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.contexts.impl.relations.IsParentOfImpl;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
|
||||
import org.gcube.informationsystem.model.impl.properties.MetadataImpl;
|
||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||
import org.gcube.informationsystem.utils.UUIDManager;
|
||||
|
||||
/**
|
||||
|
@ -28,15 +36,31 @@ public final class ContextImpl extends EntityElementImpl implements Context {
|
|||
*/
|
||||
private static final long serialVersionUID = -5070590328223454087L;
|
||||
|
||||
protected UUID uuid;
|
||||
protected String name;
|
||||
|
||||
protected IsParentOf parent;
|
||||
protected List<IsParentOf> children;
|
||||
|
||||
@JsonIgnore
|
||||
protected Map<String, Object> additionalProperties;
|
||||
|
||||
@JsonIgnore
|
||||
/**
|
||||
* Used to allow to have an additional property starting with '_' or '@'
|
||||
*/
|
||||
protected final Set<String> allowedAdditionalKeys;
|
||||
|
||||
protected ContextImpl() {
|
||||
super();
|
||||
this.parent = null;
|
||||
this.children = new ArrayList<>();
|
||||
this.additionalProperties = new HashMap<>();
|
||||
this.allowedAdditionalKeys = new HashSet<>();
|
||||
}
|
||||
|
||||
public ContextImpl(UUID uuid) {
|
||||
this(null, uuid);
|
||||
}
|
||||
|
||||
public ContextImpl(String name) {
|
||||
|
@ -47,9 +71,23 @@ public final class ContextImpl extends EntityElementImpl implements Context {
|
|||
this();
|
||||
this.name = name;
|
||||
if(uuid == null){
|
||||
uuid = UUIDManager.generateValidRandomUUID();
|
||||
uuid = UUIDManager.getInstance().generateValidUUID();
|
||||
}
|
||||
this.header = new HeaderImpl(uuid);
|
||||
this.uuid = uuid;
|
||||
this.metadata = new MetadataImpl();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the uuid
|
||||
*/
|
||||
@Override
|
||||
public UUID getID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setID(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,8 +110,8 @@ public final class ContextImpl extends EntityElementImpl implements Context {
|
|||
public void setParent(UUID uuid) {
|
||||
Context parent = null;
|
||||
if(uuid!=null) {
|
||||
parent = new ContextImpl();
|
||||
parent.setHeader(new HeaderImpl(uuid));
|
||||
parent = new ContextImpl(uuid);
|
||||
parent.setMetadata(new MetadataImpl());
|
||||
}
|
||||
setParent(parent);
|
||||
}
|
||||
|
@ -121,8 +159,8 @@ public final class ContextImpl extends EntityElementImpl implements Context {
|
|||
|
||||
@Override
|
||||
public void addChild(UUID uuid) {
|
||||
Context child = new ContextImpl();
|
||||
child.setHeader(new HeaderImpl(uuid));
|
||||
Context child = new ContextImpl(uuid);
|
||||
child.setMetadata(new MetadataImpl());
|
||||
addChild(child);
|
||||
}
|
||||
|
||||
|
@ -139,4 +177,55 @@ public final class ContextImpl extends EntityElementImpl implements Context {
|
|||
children.add(isParentOf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAdditionalProperties(Map<String, Object> additionalProperties) {
|
||||
this.additionalProperties = additionalProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAdditionalProperty(String key) {
|
||||
return additionalProperties.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAdditionalProperty(String key, Object value) {
|
||||
|
||||
if(!allowedAdditionalKeys.contains(key)){
|
||||
if(key.startsWith("_")) {
|
||||
return;
|
||||
}
|
||||
if(key.startsWith("@")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Additional properties are not deserialized to the proper property type.
|
||||
The first attempt was to try to write a specific deserializer but it fails.
|
||||
This fix the issue.
|
||||
*/
|
||||
try {
|
||||
if(value instanceof Map<?,?>) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> map = (Map<String,Object>) value;
|
||||
if(map.containsKey(Element.TYPE_PROPERTY)) {
|
||||
String reserialized = ElementMapper.getObjectMapper().writeValueAsString(map);
|
||||
Property property = ElementMapper.unmarshal(Property.class, reserialized);
|
||||
value = property;
|
||||
}
|
||||
}
|
||||
}catch (Throwable e) {
|
||||
e.getMessage();
|
||||
// Any type of error/exception must be catched
|
||||
}
|
||||
/* END of fix to properly deserialize Property types*/
|
||||
|
||||
this.additionalProperties.put(key, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,16 +4,25 @@
|
|||
package org.gcube.informationsystem.contexts.reference.entities;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.base.reference.SchemaMixedElement;
|
||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.contexts.impl.entities.ContextImpl;
|
||||
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||
import org.gcube.informationsystem.serialization.AdditionalPropertiesSerializer;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
|
@ -25,16 +34,62 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonDeserialize(as = ContextImpl.class)
|
||||
@TypeMetadata(name = Context.NAME, description = "This class is the used to define a Context", version = Version.MINIMAL_VERSION_STRING)
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY})
|
||||
@TypeMetadata(name = Context.NAME, description = "This type is the used to define a Context", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface Context extends EntityElement {
|
||||
public interface Context extends EntityElement, SchemaMixedElement {
|
||||
|
||||
public static final String NAME = "Context"; // Context.class.getSimpleName();
|
||||
|
||||
public static final String NAME_PROPERTY = "name";
|
||||
public static final String PARENT_PROPERTY = "parent";
|
||||
public static final String CHILDREN_PROPERTY = "children";
|
||||
|
||||
|
||||
/**
|
||||
* {
|
||||
* ...
|
||||
* "availableAt" : [
|
||||
* "https://i-marine.d4science.org/group/alienandinvasivespecies",
|
||||
* "https://services.d4science.org/group/alienandinvasivespecies"
|
||||
* ]
|
||||
* ...
|
||||
* }
|
||||
* For non VRE context this field could be null or could have multiple value
|
||||
* For VRE it is normally one value only (but some exception could exists
|
||||
*/
|
||||
public static final String AVAILABLE_AT_PROPERTY = "availableAt";
|
||||
|
||||
//
|
||||
/**
|
||||
* This information is provided to allowed user only (by role)
|
||||
* {
|
||||
* ...
|
||||
* "fullpaths" : [
|
||||
* {
|
||||
* "fullpath": "/gcube/devsec/myTest",
|
||||
* "time": "2023-12-11 15:35:41.289 +0000", // Same of creationTime in metadata
|
||||
* },
|
||||
* {
|
||||
* "fullpath": "/gcube/devsec/myTestVRE",
|
||||
* "time": "2023-12-13 16:13:12.336 +0000",
|
||||
* }
|
||||
* {
|
||||
* "fullpath": "/gcube/devsec/myVRE",
|
||||
* "time": "2023-12-18 12:37:48.172 +0000", // Same of lastUpdateTime in metadata
|
||||
* }
|
||||
* ]
|
||||
* ...
|
||||
* }
|
||||
*/
|
||||
public static final String CONTEXT_FULLPATH_CHANGES_LOG_PROPERTY = "fullpathChangelog";
|
||||
|
||||
/**
|
||||
* This information is provided to allowed user only (by role)
|
||||
* The symmetric key for the context
|
||||
*/
|
||||
public static final String CONTEXT_KEY_PROPERTY = "key";
|
||||
|
||||
|
||||
@ISProperty(name = NAME_PROPERTY, mandatory = true, nullable = false)
|
||||
public String getName();
|
||||
|
||||
|
@ -62,5 +117,20 @@ public interface Context extends EntityElement {
|
|||
public void addChild(Context child);
|
||||
|
||||
public void addChild(IsParentOf isParentOf);
|
||||
|
||||
@JsonAnyGetter
|
||||
@JsonSerialize(using = AdditionalPropertiesSerializer.class)
|
||||
@Override
|
||||
public Map<String,Object> getAdditionalProperties();
|
||||
|
||||
@Override
|
||||
public void setAdditionalProperties(Map<String,Object> additionalProperties);
|
||||
|
||||
@Override
|
||||
public Object getAdditionalProperty(String key);
|
||||
|
||||
@JsonAnySetter
|
||||
@Override
|
||||
public void setAdditionalProperty(String key, Object value);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,10 @@ package org.gcube.informationsystem.contexts.reference.relations;
|
|||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||
import org.gcube.informationsystem.contexts.impl.relations.IsParentOfImpl;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
|
@ -20,7 +23,8 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonDeserialize(as = IsParentOfImpl.class)
|
||||
@TypeMetadata(name = IsParentOf.NAME, description = "This class is the used to define parental relations between Context", version = Version.MINIMAL_VERSION_STRING)
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY})
|
||||
@TypeMetadata(name = IsParentOf.NAME, description = "This type is the used to define parental relations between Context", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface IsParentOf extends RelationElement<Context,Context> {
|
||||
|
||||
|
|
|
@ -3,14 +3,15 @@ package org.gcube.informationsystem.discovery.knowledge;
|
|||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.tree.NodeInformation;
|
||||
import org.gcube.informationsystem.model.knowledge.TypeInformation;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class ClassInformation implements NodeInformation<Class<Element>> {
|
||||
public class ClassInformation implements TypeInformation<Class<Element>> {
|
||||
|
||||
@Override
|
||||
public String getIdentifier(Class<Element> clz) {
|
||||
|
@ -35,4 +36,14 @@ public class ClassInformation implements NodeInformation<Class<Element>> {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType(Class<Element> clz) {
|
||||
return AccessType.getAccessType(clz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Element> getRoot(AccessType accessType) {
|
||||
return accessType.getTypeClass();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class ModelKnowledgeValidator implements DiscoveredElementAction<Element>
|
|||
}
|
||||
|
||||
String typeName = TypeMapper.getType(e);
|
||||
if(node.getTree().getRoot().getNodeElement() == e) {
|
||||
if(node.getTree().getRootNode().getNodeElement() == e) {
|
||||
logger.info("{}- Type {} is the root type", stringBuffer.toString(), typeName);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ package org.gcube.informationsystem.model.impl.entities;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
|
||||
import org.gcube.informationsystem.model.impl.properties.MetadataImpl;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
|
@ -14,7 +14,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@TypeMetadata(name = Facet.NAME, description = "This is a dummy class for Facet", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = Facet.NAME, description = "This is a dummy type for Facet", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public class DummyFacet extends FacetImpl implements Facet {
|
||||
|
||||
|
@ -25,7 +25,8 @@ public class DummyFacet extends FacetImpl implements Facet {
|
|||
|
||||
public DummyFacet(UUID uuid) {
|
||||
super();
|
||||
this.header = new HeaderImpl(uuid);
|
||||
this.uuid = uuid;
|
||||
this.metadata = new MetadataImpl();
|
||||
}
|
||||
|
||||
public DummyFacet(){
|
||||
|
|
|
@ -5,7 +5,7 @@ package org.gcube.informationsystem.model.impl.entities;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
|
||||
import org.gcube.informationsystem.model.impl.properties.MetadataImpl;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
|
@ -14,7 +14,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@TypeMetadata(name = Resource.NAME, description = "This is a dummy class for Resource", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = Resource.NAME, description = "This is a dummy type for Resource", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public class DummyResource extends ResourceImpl implements Resource {
|
||||
|
||||
|
@ -25,7 +25,8 @@ public class DummyResource extends ResourceImpl implements Resource {
|
|||
|
||||
public DummyResource(UUID uuid){
|
||||
super();
|
||||
this.header = new HeaderImpl(uuid);
|
||||
this.uuid = uuid;
|
||||
this.metadata = new MetadataImpl();
|
||||
}
|
||||
|
||||
public DummyResource(){
|
||||
|
|
|
@ -3,8 +3,14 @@
|
|||
*/
|
||||
package org.gcube.informationsystem.model.impl.entities;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import org.gcube.informationsystem.base.impl.entities.EntityElementImpl;
|
||||
import org.gcube.informationsystem.model.reference.ERElement;
|
||||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||
|
||||
/**
|
||||
|
@ -18,9 +24,31 @@ public abstract class EntityImpl extends EntityElementImpl implements Entity {
|
|||
*/
|
||||
private static final long serialVersionUID = -4488771434017342703L;
|
||||
|
||||
protected List<String> supertypes;
|
||||
protected String expectedtype;
|
||||
protected Map<UUID,String> contexts;
|
||||
|
||||
protected EntityImpl(){
|
||||
super();
|
||||
this.header = null;
|
||||
this.metadata = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertypes() {
|
||||
return this.supertypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpectedtype() {
|
||||
return this.expectedtype;
|
||||
}
|
||||
|
||||
public Map<UUID,String> getContexts(){
|
||||
return this.contexts;
|
||||
}
|
||||
|
||||
@JsonSetter(value = ERElement.CONTEXTS_PROPERTY)
|
||||
protected void setContexts(Map<UUID,String> contexts) {
|
||||
this.contexts = contexts;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ public abstract class FacetImpl extends EntityImpl implements Facet {
|
|||
super();
|
||||
this.additionalProperties = new HashMap<>();
|
||||
this.allowedAdditionalKeys = new HashSet<>();
|
||||
this.allowedAdditionalKeys.add(SUPERCLASSES_PROPERTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,7 +76,7 @@ public abstract class FacetImpl extends EntityImpl implements Facet {
|
|||
if(value instanceof Map<?,?>) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> map = (Map<String,Object>) value;
|
||||
if(map.containsKey(Element.CLASS_PROPERTY)) {
|
||||
if(map.containsKey(Element.TYPE_PROPERTY)) {
|
||||
String reserialized = ElementMapper.getObjectMapper().writeValueAsString(map);
|
||||
Property property = ElementMapper.unmarshal(Property.class, reserialized);
|
||||
value = property;
|
||||
|
|
|
@ -177,14 +177,12 @@ public abstract class ResourceImpl extends EntityImpl implements Resource {
|
|||
throw new RuntimeException(message);
|
||||
}
|
||||
|
||||
if (relation.getSource().getHeader()!= null &&
|
||||
relation.getSource().getHeader().getUUID() != null &&
|
||||
this.header !=null &&
|
||||
this.header.getUUID() != null &&
|
||||
relation.getSource().getHeader().getUUID().compareTo(this.header.getUUID())!=0) {
|
||||
|
||||
if (relation.getSource().getMetadata()!= null &&
|
||||
relation.getSource().getID() != null &&
|
||||
this.metadata !=null &&
|
||||
this.uuid != null &&
|
||||
relation.getSource().getID().compareTo(this.uuid)!=0) {
|
||||
throw new RuntimeException(message);
|
||||
|
||||
}
|
||||
|
||||
if(relation.getSource()!=this){
|
||||
|
|
|
@ -5,13 +5,13 @@ package org.gcube.informationsystem.model.impl.properties;
|
|||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import org.gcube.informationsystem.model.reference.properties.Vault;
|
||||
import org.gcube.informationsystem.model.reference.properties.Encrypted;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value = Vault.NAME)
|
||||
public class VaultImpl extends PropertyImpl implements Vault {
|
||||
@JsonTypeName(value = Encrypted.NAME)
|
||||
public class EncryptedImpl extends PropertyImpl implements Encrypted {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
@ -21,7 +21,7 @@ public class VaultImpl extends PropertyImpl implements Vault {
|
|||
@JsonIgnore
|
||||
protected String value;
|
||||
|
||||
public VaultImpl() {
|
||||
public EncryptedImpl() {
|
||||
super();
|
||||
}
|
||||
|
|
@ -4,49 +4,30 @@
|
|||
package org.gcube.informationsystem.model.impl.properties;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value=Header.NAME)
|
||||
public final class HeaderImpl extends PropertyImpl implements Header {
|
||||
@JsonTypeName(value=Metadata.NAME)
|
||||
public final class MetadataImpl extends PropertyImpl implements Metadata {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
*/
|
||||
private static final long serialVersionUID = 5102553511155113169L;
|
||||
|
||||
protected UUID uuid;
|
||||
protected String createdBy;
|
||||
protected Date creationTime;
|
||||
protected String lastUpdateBy;
|
||||
protected Date lastUpdateTime;
|
||||
|
||||
public HeaderImpl() {
|
||||
public MetadataImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
public HeaderImpl(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the uuid
|
||||
*/
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUUID(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreatedBy() {
|
||||
return createdBy;
|
|
@ -19,6 +19,10 @@ public final class PropagationConstraintImpl extends PropertyImpl implements Pro
|
|||
*/
|
||||
private static final long serialVersionUID = -4708881022038107688L;
|
||||
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING)
|
||||
@JsonProperty(value=ADD_PROPERTY)
|
||||
protected AddConstraint addConstraint;
|
||||
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING)
|
||||
@JsonProperty(value=DELETE_PROPERTY)
|
||||
protected DeleteConstraint deleteConstraint;
|
||||
|
@ -27,14 +31,20 @@ public final class PropagationConstraintImpl extends PropertyImpl implements Pro
|
|||
@JsonProperty(value=REMOVE_PROPERTY)
|
||||
protected RemoveConstraint removeConstraint;
|
||||
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING)
|
||||
@JsonProperty(value=ADD_PROPERTY)
|
||||
protected AddConstraint addConstraint;
|
||||
|
||||
public PropagationConstraintImpl(){
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddConstraint getAddConstraint() {
|
||||
return this.addConstraint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAddConstraint(AddConstraint addConstraint) {
|
||||
this.addConstraint = addConstraint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeleteConstraint getDeleteConstraint() {
|
||||
return this.deleteConstraint;
|
||||
|
@ -55,14 +65,4 @@ public final class PropagationConstraintImpl extends PropertyImpl implements Pro
|
|||
this.removeConstraint = removeConstraint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddConstraint getAddConstraint() {
|
||||
return this.addConstraint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAddConstraint(AddConstraint addConstraint) {
|
||||
this.addConstraint = addConstraint;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@TypeMetadata(name = IsRelatedTo.NAME, description = "This is a dummy class for IsRelatedTo", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = IsRelatedTo.NAME, description = "This is a dummy type for IsRelatedTo", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public class DummyIsRelatedTo<S extends Resource, T extends Resource>
|
||||
extends IsRelatedToImpl<S, T> implements IsRelatedTo<S, T>{
|
||||
|
|
|
@ -5,13 +5,17 @@ package org.gcube.informationsystem.model.impl.relations;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import org.gcube.informationsystem.base.impl.relations.RelationElementImpl;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.model.reference.ERElement;
|
||||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
||||
|
@ -31,6 +35,10 @@ public abstract class RelationImpl<S extends Resource, T extends Entity>
|
|||
*/
|
||||
private static final long serialVersionUID = -6249979476879235053L;
|
||||
|
||||
protected List<String> supertypes;
|
||||
protected String expectedtype;
|
||||
protected Map<UUID,String> contexts;
|
||||
|
||||
protected PropagationConstraint propagationConstraint;
|
||||
|
||||
@JsonIgnore
|
||||
|
@ -45,7 +53,6 @@ public abstract class RelationImpl<S extends Resource, T extends Entity>
|
|||
super();
|
||||
this.additionalProperties = new HashMap<>();
|
||||
this.allowedAdditionalKeys = new HashSet<>();
|
||||
this.allowedAdditionalKeys.add(SUPERCLASSES_PROPERTY);
|
||||
}
|
||||
|
||||
protected RelationImpl(S source, T target,
|
||||
|
@ -56,6 +63,26 @@ public abstract class RelationImpl<S extends Resource, T extends Entity>
|
|||
this.propagationConstraint = propagationConstraint;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getSupertypes() {
|
||||
return this.supertypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpectedtype() {
|
||||
return this.expectedtype;
|
||||
}
|
||||
|
||||
public Map<UUID,String> getContexts(){
|
||||
return this.contexts;
|
||||
}
|
||||
|
||||
@JsonSetter(value = ERElement.CONTEXTS_PROPERTY)
|
||||
protected void setContexts(Map<UUID,String> contexts) {
|
||||
this.contexts = contexts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropagationConstraint getPropagationConstraint() {
|
||||
return this.propagationConstraint;
|
||||
|
@ -105,7 +132,7 @@ public abstract class RelationImpl<S extends Resource, T extends Entity>
|
|||
if(value instanceof Map<?,?>) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> map = (Map<String,Object>) value;
|
||||
if(map.containsKey(Element.CLASS_PROPERTY)) {
|
||||
if(map.containsKey(Element.TYPE_PROPERTY)) {
|
||||
String reserialized = ElementMapper.getObjectMapper().writeValueAsString(map);
|
||||
Property property = ElementMapper.unmarshal(Property.class, reserialized);
|
||||
value = property;
|
||||
|
|
|
@ -0,0 +1,315 @@
|
|||
package org.gcube.informationsystem.model.knowledge;
|
||||
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
||||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||
import org.gcube.informationsystem.tree.Node;
|
||||
import org.gcube.informationsystem.tree.Tree;
|
||||
import org.gcube.informationsystem.types.PropertyTypeName;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.impl.properties.PropertyDefinitionImpl;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.types.reference.entities.FacetType;
|
||||
import org.gcube.informationsystem.types.reference.entities.ResourceType;
|
||||
import org.gcube.informationsystem.types.reference.properties.LinkedEntity;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
import org.gcube.informationsystem.types.reference.relations.ConsistsOfType;
|
||||
import org.gcube.informationsystem.types.reference.relations.IsRelatedToType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class ModelKnowledge<T, TI extends TypeInformation<T>> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ModelKnowledge.class);
|
||||
|
||||
protected TI typeInformation;
|
||||
protected Map<AccessType, Tree<T>> trees;
|
||||
|
||||
protected UsageKnowledge<Entry<String,PropertyDefinition>> propertyUsage;
|
||||
protected Map<AccessType, UsageKnowledge<LinkedEntity>> erTypesUsage;
|
||||
|
||||
protected Map<String, AccessType> locate;
|
||||
|
||||
public ModelKnowledge(TI typeInformation) {
|
||||
this.typeInformation = typeInformation;
|
||||
reset();
|
||||
}
|
||||
|
||||
protected void reset() {
|
||||
|
||||
this.trees = new HashMap<>();
|
||||
this.erTypesUsage = new HashMap<>();
|
||||
this.locate = new HashMap<>();
|
||||
|
||||
AccessType[] modelTypes = AccessType.getModelTypes();
|
||||
for(AccessType accessType : modelTypes) {
|
||||
|
||||
/*
|
||||
* T t = typeInformation.getRoot(accessType);
|
||||
* Tree<T> tree = new Tree<>(t, typeInformation);
|
||||
*/
|
||||
|
||||
Tree<T> tree = new Tree<>(typeInformation);
|
||||
trees.put(accessType, tree);
|
||||
|
||||
if(accessType == AccessType.PROPERTY) {
|
||||
/*
|
||||
* In this case we get the type which uses such a property
|
||||
* and the property definition.
|
||||
* In this way we have a complete overview of the usage of the
|
||||
* property type
|
||||
*/
|
||||
propertyUsage = new UsageKnowledge<>(accessType);
|
||||
}else {
|
||||
UsageKnowledge<LinkedEntity> usageKnowledge = new UsageKnowledge<LinkedEntity>(accessType);
|
||||
erTypesUsage.put(accessType, usageKnowledge);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void addUsage(LinkedEntity linkedEntity, UsageKnowledge<LinkedEntity> relationUsage, UsageKnowledge<LinkedEntity> targetEntityUsage) {
|
||||
if (linkedEntity != null) {
|
||||
UsageKnowledge<LinkedEntity> resourceUsage = erTypesUsage.get(AccessType.RESOURCE);
|
||||
String source = linkedEntity.getSource();
|
||||
resourceUsage.add(source, linkedEntity);
|
||||
String relation = linkedEntity.getRelation();
|
||||
relationUsage.add(relation, linkedEntity);
|
||||
String target = linkedEntity.getTarget();
|
||||
targetEntityUsage.add(target, linkedEntity);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addAllUsage(Collection<LinkedEntity> linkedEntities, UsageKnowledge<LinkedEntity> relationUsage, UsageKnowledge<LinkedEntity> targetEntityUsage) {
|
||||
if(linkedEntities!=null) {
|
||||
for(LinkedEntity le : linkedEntities) {
|
||||
addUsage(le, relationUsage, targetEntityUsage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addPropertyUsage(T t, Set<PropertyDefinition> properties) {
|
||||
if(properties==null || properties.size()==0) {
|
||||
return;
|
||||
}
|
||||
String typeName = typeInformation.getIdentifier(t);
|
||||
for(PropertyDefinition propertyDefinition : properties) {
|
||||
PropertyTypeName propertyTypeName = ((PropertyDefinitionImpl) propertyDefinition).getPropertyTypeName();
|
||||
if(propertyTypeName.isGenericType()) {
|
||||
SimpleEntry<String,PropertyDefinition> entry = new SimpleEntry<>(typeName, propertyDefinition);
|
||||
propertyUsage.add(propertyTypeName.getGenericClassName(), entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addEntityMetadataUsage(T t) {
|
||||
Type type = TypeMapper.createTypeDefinition(EntityElement.class);
|
||||
addPropertyUsage(t, type.getProperties());
|
||||
}
|
||||
|
||||
protected void addRelationMetadataUsage(T t) {
|
||||
Type type = TypeMapper.createTypeDefinition(RelationElement.class);
|
||||
addPropertyUsage(t, type.getProperties());
|
||||
}
|
||||
|
||||
protected void addPropagationConstraintUsage(T t) {
|
||||
Type type = TypeMapper.createTypeDefinition(Relation.class);
|
||||
addPropertyUsage(t, type.getProperties());
|
||||
}
|
||||
|
||||
public void addAllType(Collection<T> types) {
|
||||
Set<T> toRetry = new HashSet<>();
|
||||
|
||||
for(T t : types) {
|
||||
logger.trace("Going to add {}", typeInformation.getIdentifier(t));
|
||||
try {
|
||||
addType(t);
|
||||
}catch (RuntimeException e) {
|
||||
toRetry.add(t);
|
||||
}
|
||||
}
|
||||
|
||||
if(types.size()==toRetry.size()) {
|
||||
throw new RuntimeException("Unable to find parent for " + toRetry.toString());
|
||||
}
|
||||
|
||||
if(toRetry.size()>0) {
|
||||
addAllType(toRetry);
|
||||
}
|
||||
}
|
||||
|
||||
public void addType(T t) {
|
||||
AccessType accessType = typeInformation.getAccessType(t);
|
||||
String typeName = typeInformation.getIdentifier(t);
|
||||
|
||||
if(locate.get(typeName)!=null) {
|
||||
logger.trace("The type {} was already added to the ModelKnowledge", typeName);
|
||||
return;
|
||||
}
|
||||
|
||||
Tree<T> tree = trees.get(accessType);
|
||||
tree.addNode(t);
|
||||
locate.put(typeName, accessType);
|
||||
|
||||
UsageKnowledge<LinkedEntity> resourceUsage = erTypesUsage.get(AccessType.RESOURCE);
|
||||
UsageKnowledge<LinkedEntity> facetUsage = erTypesUsage.get(AccessType.FACET);
|
||||
UsageKnowledge<LinkedEntity> isRelatedToUsage = erTypesUsage.get(AccessType.IS_RELATED_TO);
|
||||
UsageKnowledge<LinkedEntity> consistsOfUsage = erTypesUsage.get(AccessType.CONSISTS_OF);
|
||||
|
||||
switch (accessType) {
|
||||
case PROPERTY:
|
||||
// Nothing to do
|
||||
break;
|
||||
|
||||
case RESOURCE:
|
||||
ResourceType resourceType = (ResourceType) t;
|
||||
addAllUsage(resourceType.getFacets(), consistsOfUsage, facetUsage);
|
||||
addAllUsage(resourceType.getResources(), isRelatedToUsage, resourceUsage);
|
||||
|
||||
/*
|
||||
* Metadata is defined in parent type i.e. EntityElement.
|
||||
* We want to have a reference to all Base type
|
||||
*/
|
||||
if(typeName.compareTo(Resource.NAME)==0) {
|
||||
addEntityMetadataUsage(t);
|
||||
}
|
||||
break;
|
||||
|
||||
case FACET:
|
||||
FacetType facetType = (FacetType) t;
|
||||
/*
|
||||
* Metadata is defined in parent type i.e. EntityElement.
|
||||
* We want to have a reference to all Base type
|
||||
*/
|
||||
if(typeName.compareTo(Facet.NAME)==0) {
|
||||
addEntityMetadataUsage(t);
|
||||
}
|
||||
addPropertyUsage(t, facetType.getProperties());
|
||||
|
||||
break;
|
||||
|
||||
case IS_RELATED_TO:
|
||||
IsRelatedToType isRelatedToType = (IsRelatedToType) t;
|
||||
/*
|
||||
* Metadata is defined in parent type i.e. RelationElement.
|
||||
* We want to have a reference to all Base type
|
||||
*/
|
||||
if(typeName.compareTo(IsRelatedTo.NAME)==0) {
|
||||
addRelationMetadataUsage(t);
|
||||
addPropagationConstraintUsage(t);
|
||||
}
|
||||
addPropertyUsage(t, isRelatedToType.getProperties());
|
||||
break;
|
||||
|
||||
case CONSISTS_OF:
|
||||
ConsistsOfType consistsOfType = (ConsistsOfType) t;
|
||||
/*
|
||||
* Metadata is defined in parent type i.e. RelationElement.
|
||||
* We want to have a reference to all Base type
|
||||
*/
|
||||
if(typeName.compareTo(ConsistsOf.NAME)==0) {
|
||||
addRelationMetadataUsage(t);
|
||||
addPropagationConstraintUsage(t);
|
||||
}
|
||||
addPropertyUsage(t, consistsOfType.getProperties());
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Tree<T> getTree(AccessType accessType) {
|
||||
return trees.get(accessType);
|
||||
}
|
||||
|
||||
public UsageKnowledge<?> getModelTypesUsage(AccessType accessType) {
|
||||
List<AccessType> modelTypes = Arrays.asList(AccessType.getModelTypes());
|
||||
if(!modelTypes.contains(accessType)) {
|
||||
throw new RuntimeException("Only ModelTypes are allowed, i.e. " + modelTypes.toString());
|
||||
}
|
||||
if(accessType == AccessType.PROPERTY) {
|
||||
return propertyUsage;
|
||||
}else {
|
||||
return erTypesUsage.get(accessType);
|
||||
}
|
||||
}
|
||||
|
||||
public UsageKnowledge<LinkedEntity> getERTypesUsage(AccessType accessType) {
|
||||
List<AccessType> erTypes = Arrays.asList(AccessType.getERTypes());
|
||||
if(!erTypes.contains(accessType)) {
|
||||
throw new RuntimeException("Only ERTypes are allowed, i.e. " + erTypes.toString());
|
||||
}
|
||||
return erTypesUsage.get(accessType);
|
||||
}
|
||||
|
||||
public UsageKnowledge<Entry<String,PropertyDefinition>> getPropertyUsage(){
|
||||
return propertyUsage;
|
||||
}
|
||||
|
||||
public UsageKnowledge<LinkedEntity> getResourceUsage() {
|
||||
return erTypesUsage.get(AccessType.RESOURCE);
|
||||
}
|
||||
|
||||
public UsageKnowledge<LinkedEntity> getFacetUsage() {
|
||||
return erTypesUsage.get(AccessType.FACET);
|
||||
}
|
||||
|
||||
public UsageKnowledge<LinkedEntity> getIsRelatedToUsage() {
|
||||
return erTypesUsage.get(AccessType.IS_RELATED_TO);
|
||||
}
|
||||
|
||||
public UsageKnowledge<LinkedEntity> getConsistsOfUsage() {
|
||||
return erTypesUsage.get(AccessType.CONSISTS_OF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type if it is contained in the Knowledge
|
||||
* @param typeName the type we are looking for
|
||||
* @return the Type
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public T getTypeByName(String typeName) throws RuntimeException {
|
||||
return getNodeByName(typeName).getNodeElement();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the node fro the type if it is contained in the Knowledge
|
||||
* @param typeName the type we are looking for
|
||||
* @return the Type
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public Node<T> getNodeByName(String typeName) throws RuntimeException {
|
||||
AccessType accessType = locate.get(typeName);
|
||||
if(accessType==null) {
|
||||
throw new RuntimeException("The type " + typeName + " is not contained in the Knowledge");
|
||||
}
|
||||
|
||||
Tree<T> tree = trees.get(accessType);
|
||||
return tree.getNodeByIdentifier(typeName);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.gcube.informationsystem.model.knowledge;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.tree.NodeInformation;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public interface TypeInformation<T> extends NodeInformation<T> {
|
||||
|
||||
public AccessType getAccessType(T t);
|
||||
|
||||
public T getRoot(AccessType accessType);
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.gcube.informationsystem.model.knowledge;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public interface TypesDiscoverer<T> {
|
||||
|
||||
/**
|
||||
* This function discover all available types of a certain
|
||||
* AccessType. Allowed AccessTypes are only IS Model Types
|
||||
* see {@link AccessType#getModelTypes()}
|
||||
* @param accessType
|
||||
* @return
|
||||
*/
|
||||
public Collection<T> discover(AccessType accessType);
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.gcube.informationsystem.model.knowledge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class UsageKnowledge<U> {
|
||||
|
||||
protected Map<String, List<U>> map;
|
||||
|
||||
public UsageKnowledge(AccessType accessType){
|
||||
this.map = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
public void add(String typeName, U u) {
|
||||
List<U> list = map.get(typeName);
|
||||
if(list==null) {
|
||||
list = new ArrayList<>();
|
||||
map.put(typeName, list);
|
||||
}
|
||||
list.add(u);
|
||||
}
|
||||
|
||||
public List<U> getUsage(String typeName){
|
||||
List<U> list = map.get(typeName);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,13 @@
|
|||
package org.gcube.informationsystem.model.reference;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
|
||||
/**
|
||||
|
@ -8,6 +16,16 @@ import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
|||
*
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public interface ERElement extends IdentifiableElement {
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, ModelElement.SUPERTYPES_PROPERTY, ModelElement.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, ERElement.CONTEXTS_PROPERTY })
|
||||
public interface ERElement extends IdentifiableElement, ModelElement {
|
||||
|
||||
/**
|
||||
* Used when requested to include contexts in metadata.
|
||||
* This is not a native property (it is just generated by server for administration clients convenience)
|
||||
*/
|
||||
public static final String CONTEXTS_PROPERTY = "contexts";
|
||||
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonGetter(value = CONTEXTS_PROPERTY)
|
||||
public Map<UUID,String> getContexts();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package org.gcube.informationsystem.model.reference;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, ModelElement.SUPERTYPES_PROPERTY, ModelElement.EXPECTED_TYPE_PROPERTY })
|
||||
public interface ModelElement extends Element {
|
||||
|
||||
public static final String SUPERTYPES_PROPERTY = "supertypes";
|
||||
|
||||
/*
|
||||
* This is the key used by the deserializer to indicate the expected type
|
||||
* which instead has been deserialized using the best available
|
||||
* supertype
|
||||
*/
|
||||
public static final String EXPECTED_TYPE_PROPERTY = "expectedtype";
|
||||
|
||||
@JsonInclude(Include.NON_EMPTY)
|
||||
@JsonGetter(value = SUPERTYPES_PROPERTY)
|
||||
public List<String> getSupertypes();
|
||||
|
||||
@JsonInclude(Include.NON_EMPTY)
|
||||
@JsonGetter(value = EXPECTED_TYPE_PROPERTY)
|
||||
public String getExpectedtype();
|
||||
|
||||
}
|
|
@ -3,8 +3,12 @@
|
|||
*/
|
||||
package org.gcube.informationsystem.model.reference.entities;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.model.reference.ERElement;
|
||||
import org.gcube.informationsystem.model.reference.ModelElement;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
|
@ -16,6 +20,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Abstract
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, ModelElement.SUPERTYPES_PROPERTY, ModelElement.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, ERElement.CONTEXTS_PROPERTY })
|
||||
//@JsonDeserialize(as=EntityImpl.class) Do not uncomment to manage subclasses
|
||||
@TypeMetadata(name = Entity.NAME, description = "This is the base type for any Entity", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
|
|
|
@ -8,12 +8,17 @@ import java.util.UUID;
|
|||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.model.reference.ERElement;
|
||||
import org.gcube.informationsystem.model.reference.ModelElement;
|
||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
||||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
import org.gcube.informationsystem.types.annotations.RelatedResourcesEntry;
|
||||
import org.gcube.informationsystem.types.annotations.ResourceSchema;
|
||||
import org.gcube.informationsystem.types.annotations.ResourceSchemaEntry;
|
||||
import org.gcube.informationsystem.types.annotations.RelatedResourcesEntry;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
import org.gcube.informationsystem.utils.Version;
|
||||
|
@ -25,6 +30,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
*/
|
||||
@Abstract
|
||||
@JsonIgnoreProperties(ignoreUnknown=true)
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, ModelElement.SUPERTYPES_PROPERTY, ModelElement.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, ERElement.CONTEXTS_PROPERTY, Resource.CONSISTS_OF_PROPERTY, Resource.IS_RELATED_TO_PROPERTY })
|
||||
// @JsonDeserialize(as=ResourceImpl.class) Do not uncomment to manage subclasses
|
||||
@ResourceSchema(
|
||||
facets={
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.gcube.informationsystem.model.reference.properties;
|
|||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.gcube.informationsystem.model.impl.properties.VaultImpl;
|
||||
import org.gcube.informationsystem.model.impl.properties.EncryptedImpl;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
|
@ -12,12 +12,12 @@ import org.gcube.informationsystem.utils.Version;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonDeserialize(as=VaultImpl.class)
|
||||
@TypeMetadata(name = Vault.NAME, description = "This type is used to properly manage values must be stored safely (e.g. encrypted) in the IS.", version = Version.MINIMAL_VERSION_STRING)
|
||||
@JsonDeserialize(as=EncryptedImpl.class)
|
||||
@TypeMetadata(name = Encrypted.NAME, description = "This type is used to properly manage values must be stored safely (e.g. encrypted) in the IS.", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface Vault extends Property {
|
||||
public interface Encrypted extends Property {
|
||||
|
||||
public static final String NAME = "Vault"; // Vault.class.getSimpleName();
|
||||
public static final String NAME = "Encrypted"; // Encrypted.class.getSimpleName();
|
||||
|
||||
public static final String VALUE = "value";
|
||||
|
|
@ -4,12 +4,11 @@
|
|||
package org.gcube.informationsystem.model.reference.properties;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
|
||||
import org.gcube.informationsystem.model.impl.properties.MetadataImpl;
|
||||
import org.gcube.informationsystem.types.annotations.Final;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
|
@ -17,35 +16,27 @@ import org.gcube.informationsystem.types.reference.TypeMetadata;
|
|||
import org.gcube.informationsystem.utils.Version;
|
||||
|
||||
/**
|
||||
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#Header
|
||||
*
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonDeserialize(as=HeaderImpl.class)
|
||||
@TypeMetadata(name = Header.NAME, description = "This type provides metadata per every IdentifiableElement", version = Version.MINIMAL_VERSION_STRING)
|
||||
@JsonDeserialize(as=MetadataImpl.class)
|
||||
@TypeMetadata(name = Metadata.NAME, description = "This type provides metadata per every IdentifiableElement", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
@Final
|
||||
public interface Header extends Property {
|
||||
public interface Metadata extends Property {
|
||||
|
||||
public static final String NAME = "Header"; // Header.class.getSimpleName();
|
||||
public static final String NAME = "Metadata"; // Metadata.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* Used to set Creator when the user is not known
|
||||
*/
|
||||
public static final String UNKNOWN_USER = "UNKNOWN_USER";
|
||||
public static final String HIDDEN_FOR_PRIVACY_USER = "HIDDEN_FOR_PRIVACY";
|
||||
|
||||
public static final String UUID_PROPERTY = "uuid";
|
||||
public static final String CREATED_BY_PROPERTY = "createdBy";
|
||||
public static final String CREATION_TIME_PROPERTY = "creationTime";
|
||||
public static final String LAST_UPDATE_BY_PROPERTY = "lastUpdateBy";
|
||||
public static final String LAST_UPDATE_TIME_PROPERTY = "lastUpdateTime";
|
||||
|
||||
/**
|
||||
* Used when requested to include contexts in header.
|
||||
* This is not a native property (it is just generated by server for administration clients convenience)
|
||||
*/
|
||||
public static final String __CONTEXTS = "contexts";
|
||||
|
||||
@ISProperty(name = CREATED_BY_PROPERTY, description = "The user that created the Entity or the Relation. It is initialized at Creation Time.", readonly = true, mandatory = true, nullable = false)
|
||||
public String getCreatedBy();
|
||||
|
||||
|
@ -59,10 +50,5 @@ public interface Header extends Property {
|
|||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Element.DATETIME_PATTERN)
|
||||
@ISProperty(name = LAST_UPDATE_TIME_PROPERTY, description = "Last Update time. At creation time it assumes the same value of " + CREATION_TIME_PROPERTY + ". It is represented in the format " + Element.DATETIME_PATTERN, mandatory = true, nullable = false)
|
||||
public Date getLastUpdateTime();
|
||||
|
||||
@ISProperty(name = UUID_PROPERTY, description = "This UUID is be used to identify the Entity or the Relation univocally.", readonly = true, mandatory = true, nullable = false)
|
||||
public UUID getUUID();
|
||||
|
||||
public void setUUID(UUID uuid);
|
||||
|
||||
}
|
|
@ -34,10 +34,28 @@ import org.gcube.informationsystem.utils.Version;
|
|||
public interface PropagationConstraint extends Property {
|
||||
|
||||
public static final String NAME = "PropagationConstraint"; // PropagationConstraint.class.getSimpleName();
|
||||
|
||||
|
||||
public static final String ADD_PROPERTY = "add";
|
||||
public static final String DELETE_PROPERTY = "delete";
|
||||
public static final String REMOVE_PROPERTY = "remove";
|
||||
public static final String ADD_PROPERTY = "add";
|
||||
|
||||
public enum AddConstraint {
|
||||
|
||||
/**
|
||||
* When an 'add' action is performed on the source Entity of the relation,
|
||||
* or directly on the relation, then the same 'add' action is performed on
|
||||
* the relation and its target Entity.
|
||||
*/
|
||||
propagate,
|
||||
|
||||
/**
|
||||
* When an 'add' action is performed on the source Entity of the relation,
|
||||
* is performed on source relation only. Trying to perform an 'add' action on
|
||||
* the relation has no effects.
|
||||
*/
|
||||
unpropagate
|
||||
|
||||
}
|
||||
|
||||
public enum DeleteConstraint {
|
||||
|
||||
|
@ -89,24 +107,12 @@ public interface PropagationConstraint extends Property {
|
|||
keep
|
||||
|
||||
}
|
||||
|
||||
@ISProperty(name=ADD_PROPERTY, description = "It indicates the behaviour to implement for the target Entity when an 'add' action is performed on the source Resource. Add action is the operation of adding an instance to a context.", mandatory = true, nullable = false)
|
||||
public AddConstraint getAddConstraint();
|
||||
|
||||
public void setAddConstraint(AddConstraint addConstraint);
|
||||
|
||||
public enum AddConstraint {
|
||||
|
||||
/**
|
||||
* When an 'add' action is performed on the source Entity of the relation,
|
||||
* or directly on the relation, then the same 'add' action is performed on
|
||||
* the relation and its target Entity.
|
||||
*/
|
||||
propagate,
|
||||
|
||||
/**
|
||||
* When an 'add' action is performed on the source Entity of the relation,
|
||||
* is performed on source relation only. Trying to perform an 'add' action on
|
||||
* the relation has no effects.
|
||||
*/
|
||||
unpropagate
|
||||
|
||||
}
|
||||
|
||||
@ISProperty(name=DELETE_PROPERTY, description = "It indicates the behaviour to implement for the target Entity when a 'delete' action is performed on the source Resource. Delet action is the operation of deleting an instance (it has an impact on all contexts).", mandatory = true, nullable = false)
|
||||
public DeleteConstraint getDeleteConstraint();
|
||||
|
@ -119,10 +125,4 @@ public interface PropagationConstraint extends Property {
|
|||
|
||||
public void setRemoveConstraint(RemoveConstraint removeConstraint);
|
||||
|
||||
|
||||
@ISProperty(name=ADD_PROPERTY, description = "It indicates the behaviour to implement for the target Entity when an 'add' action is performed on the source Resource. Add action is the operation of adding an instance to a context.", mandatory = true, nullable = false)
|
||||
public AddConstraint getAddConstraint();
|
||||
|
||||
public void setAddConstraint(AddConstraint addConstraint);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,11 +7,14 @@ import java.util.Map;
|
|||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.SchemaMixedElement;
|
||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.model.impl.properties.PropertyImpl;
|
||||
import org.gcube.informationsystem.model.reference.ModelElement;
|
||||
import org.gcube.informationsystem.serialization.AdditionalPropertiesSerializer;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
|
@ -24,10 +27,11 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
// @JsonIgnoreProperties(ignoreUnknown=true)
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, ModelElement.SUPERTYPES_PROPERTY, ModelElement.EXPECTED_TYPE_PROPERTY })
|
||||
@JsonDeserialize(as=PropertyImpl.class)
|
||||
@TypeMetadata(name = Property.NAME, description = "This is the base type for any Property", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface Property extends PropertyElement, SchemaMixedElement {
|
||||
public interface Property extends PropertyElement, SchemaMixedElement, ModelElement {
|
||||
|
||||
public static final String NAME = "Property"; //Property.class.getSimpleName();
|
||||
|
||||
|
|
|
@ -10,10 +10,16 @@ import org.gcube.com.fasterxml.jackson.annotation.JsonAnySetter;
|
|||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.base.reference.SchemaMixedElement;
|
||||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||
import org.gcube.informationsystem.model.reference.ERElement;
|
||||
import org.gcube.informationsystem.model.reference.ModelElement;
|
||||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
||||
|
@ -30,6 +36,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#Relation
|
||||
*/
|
||||
@Abstract
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, ModelElement.SUPERTYPES_PROPERTY, ModelElement.EXPECTED_TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, ERElement.CONTEXTS_PROPERTY, Relation.PROPAGATION_CONSTRAINT_PROPERTY })
|
||||
// @JsonDeserialize(as=RelationImpl.class) Do not uncomment to manage subclasses
|
||||
@TypeMetadata(name = Relation.NAME, description = "This is the base type for any Relation", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
|
@ -39,6 +46,7 @@ public interface Relation<S extends Resource, T extends Entity> extends Relation
|
|||
|
||||
public static final String PROPAGATION_CONSTRAINT_PROPERTY = "propagationConstraint";
|
||||
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties({Resource.CONSISTS_OF_PROPERTY, Resource.IS_RELATED_TO_PROPERTY})
|
||||
@JsonGetter(value = SOURCE_PROPERTY)
|
||||
@Override
|
||||
|
@ -56,6 +64,7 @@ public interface Relation<S extends Resource, T extends Entity> extends Relation
|
|||
@Override
|
||||
public void setTarget(T target);
|
||||
|
||||
@JsonGetter(value = PROPAGATION_CONSTRAINT_PROPERTY)
|
||||
@ISProperty(name = PROPAGATION_CONSTRAINT_PROPERTY)
|
||||
public PropagationConstraint getPropagationConstraint();
|
||||
|
||||
|
|
|
@ -24,11 +24,15 @@ import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
|
|||
import org.gcube.com.fasterxml.jackson.databind.node.TextNode;
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.model.reference.ModelElement;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
|
||||
/**
|
||||
* This is not used anymore.
|
||||
* Keeping the class in case something is not solved
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Deprecated
|
||||
public class ElementDeserializer<ISM extends Element> extends StdDeserializer<ISM> {
|
||||
|
||||
private static final long serialVersionUID = -2551569658316955137L;
|
||||
|
@ -57,10 +61,13 @@ public class ElementDeserializer<ISM extends Element> extends StdDeserializer<IS
|
|||
List<TextNode> toBeKeepSuperClasses = new ArrayList<>();
|
||||
|
||||
ObjectNode objectNode = (ObjectNode) treeNode;
|
||||
if(!objectNode.has(ModelElement.EXPECTED_TYPE_PROPERTY)) {
|
||||
objectNode.set(ModelElement.EXPECTED_TYPE_PROPERTY, objectNode.get(Element.TYPE_PROPERTY));
|
||||
}
|
||||
|
||||
try {
|
||||
JsonNode superClassesTreeNode = objectNode
|
||||
.get(Element.SUPERCLASSES_PROPERTY);
|
||||
.get(ModelElement.SUPERTYPES_PROPERTY);
|
||||
if (superClassesTreeNode != null
|
||||
&& superClassesTreeNode.isArray()) {
|
||||
ArrayNode arrayNode = (ArrayNode) superClassesTreeNode;
|
||||
|
@ -120,7 +127,7 @@ public class ElementDeserializer<ISM extends Element> extends StdDeserializer<IS
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
String typeName = TypeMapper.getType((Class<? extends Element>) candidatedSuperClass);
|
||||
objectNode.set(Element.CLASS_PROPERTY, new TextNode(typeName));
|
||||
objectNode.set(Element.TYPE_PROPERTY, new TextNode(typeName));
|
||||
JsonParser jsonParser = jsonFactory.createParser(objectNode
|
||||
.toString());
|
||||
jsonParser.nextToken();
|
||||
|
|
|
@ -22,7 +22,8 @@ import org.gcube.com.fasterxml.jackson.databind.JavaType;
|
|||
import org.gcube.com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import org.gcube.com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.gcube.com.fasterxml.jackson.databind.exc.InvalidTypeIdException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.JsonNodeType;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
@ -31,6 +32,8 @@ import org.gcube.informationsystem.base.reference.AccessType;
|
|||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.discovery.Discovery;
|
||||
import org.gcube.informationsystem.discovery.knowledge.Knowledge;
|
||||
import org.gcube.informationsystem.model.reference.ModelElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -58,6 +61,7 @@ public abstract class ElementMapper {
|
|||
static {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.getSerializationConfig().with(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
|
||||
|
||||
/*
|
||||
* Instructing Jackson to serialize any Date in the defined pattern
|
||||
|
@ -80,7 +84,8 @@ public abstract class ElementMapper {
|
|||
if(!Type.class.isAssignableFrom(clz)) {
|
||||
Class<Element> dummyClz = accessType.getDummyImplementationClass();
|
||||
if(dummyClz != null) {
|
||||
ElementMapper.registerSubtypes(clz, dummyClz);
|
||||
// ElementMapper.registerSubtypes(clz, dummyClz);
|
||||
ElementMapper.registerSubtype(dummyClz);
|
||||
}else {
|
||||
ElementMapper.registerSubtype(clz);
|
||||
}
|
||||
|
@ -113,14 +118,15 @@ public abstract class ElementMapper {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public static <El extends Element> void registerSubtypes(Class<El> clz, Class<El> implementationClass) {
|
||||
String typeName = TypeMapper.getType(clz);
|
||||
SimpleModule isModule = new SimpleModule(typeName);
|
||||
isModule.addDeserializer(clz, new ElementDeserializer<>(clz, mapper));
|
||||
mapper.registerModule(isModule);
|
||||
registerSubtype(implementationClass);
|
||||
}
|
||||
|
||||
// This add the ElementDeserializer which has been deprecated thank to the fix in
|
||||
// public static <El extends Element> void registerSubtypes(Class<El> clz, Class<El> implementationClass) {
|
||||
// String typeName = TypeMapper.getType(clz);
|
||||
// SimpleModule isModule = new SimpleModule(typeName);
|
||||
// isModule.addDeserializer(clz, new ElementDeserializer<>(clz, mapper));
|
||||
// mapper.registerModule(isModule);
|
||||
// registerSubtype(implementationClass);
|
||||
// }
|
||||
|
||||
public static <El extends Element> void registerSubtype(Class<El> clz) {
|
||||
String typeName = TypeMapper.getType(clz);
|
||||
|
@ -193,64 +199,111 @@ public abstract class ElementMapper {
|
|||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(unknownType);
|
||||
stringBuffer.append(" is an unknown type. Please provide ");
|
||||
stringBuffer.append(Element.SUPERCLASSES_PROPERTY);
|
||||
stringBuffer.append(ModelElement.SUPERTYPES_PROPERTY);
|
||||
stringBuffer.append(" property as string array to allow to instantiate the most appropriated class.");
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
protected static JsonNode setAvailableSuperclass(JsonNode jsonNode) {
|
||||
String unknownType = jsonNode.get(Element.CLASS_PROPERTY).asText();
|
||||
ArrayNode arrayNode = (ArrayNode) jsonNode.get(Element.SUPERCLASSES_PROPERTY);
|
||||
protected static ObjectNode setTypeToBestAvailable(ObjectNode objectNode) {
|
||||
String unknownType = objectNode.get(Element.TYPE_PROPERTY).asText();
|
||||
ArrayNode arrayNode = (ArrayNode) objectNode.get(ModelElement.SUPERTYPES_PROPERTY);
|
||||
|
||||
// TODO save original class and superclasses
|
||||
|
||||
String candidatedSuperClass = null;
|
||||
for(int i = 0; i < arrayNode.size(); i++) {
|
||||
String superClass = arrayNode.get(i).asText();
|
||||
if(knownTypes.containsKey(superClass)) {
|
||||
candidatedSuperClass = superClass;
|
||||
try {
|
||||
// Checking if it is one of the base type. In some cases we need to use dummy
|
||||
// implementation
|
||||
AccessType accessType = Enum.valueOf(AccessType.class, superClass.toUpperCase());
|
||||
// It is one of the BaseType.
|
||||
// Looking if we need to set the dummy implementation class
|
||||
if(accessType.getDummyImplementationClass()!=null) {
|
||||
// This should not happen because the type has been assigned already to the dummy class.
|
||||
candidatedSuperClass = accessType.getDummyImplementationClass().getSimpleName();
|
||||
String candidatedSupertype = null;
|
||||
if(arrayNode!=null) {
|
||||
for(int i = 0; i < arrayNode.size(); i++) {
|
||||
String superType = arrayNode.get(i).asText();
|
||||
if(knownTypes.containsKey(superType)) {
|
||||
candidatedSupertype = superType;
|
||||
try {
|
||||
// Checking if it is one of the base type. In some cases we need to use dummy
|
||||
// implementation
|
||||
AccessType accessType = AccessType.getAccessType(superType);
|
||||
// It is one of the BaseType.
|
||||
// Looking if we need to set the dummy implementation class
|
||||
if(accessType.getDummyImplementationClass()!=null) {
|
||||
// This should not happen because the type has been assigned already to the dummy class.
|
||||
candidatedSupertype = accessType.getDummyImplementationClass().getSimpleName();
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
// can continue discovery
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
// can continue discovery
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(candidatedSuperClass!=null) {
|
||||
((ObjectNode) jsonNode).set(Element.CLASS_PROPERTY, new TextNode(candidatedSuperClass));
|
||||
return jsonNode;
|
||||
if(candidatedSupertype!=null) {
|
||||
if(!objectNode.has(ModelElement.EXPECTED_TYPE_PROPERTY)) {
|
||||
objectNode.set(ModelElement.EXPECTED_TYPE_PROPERTY, objectNode.get(Element.TYPE_PROPERTY));
|
||||
}
|
||||
objectNode.set(Element.TYPE_PROPERTY, new TextNode(candidatedSupertype));
|
||||
objectNode.remove(ModelElement.SUPERTYPES_PROPERTY);
|
||||
return objectNode;
|
||||
}
|
||||
|
||||
StringBuffer stringBuffer = getError(unknownType);
|
||||
logger.trace("Unable to unmarshall {}. {}", jsonNode.toString(), stringBuffer.toString());
|
||||
logger.trace("Unable to unmarshall {}. {}", objectNode.toString(), stringBuffer.toString());
|
||||
throw new RuntimeException(stringBuffer.toString());
|
||||
}
|
||||
|
||||
protected static JsonNode analizeFullJson(JsonNode jsonNode) {
|
||||
String cls = jsonNode.get(Element.CLASS_PROPERTY).asText();
|
||||
if(!knownTypes.containsKey(cls)) {
|
||||
jsonNode = setAvailableSuperclass(jsonNode);
|
||||
protected static JsonNode analizeTypes(ObjectNode objectNode) {
|
||||
String cls = null;
|
||||
|
||||
JsonNode typeJN = objectNode.get(Element.TYPE_PROPERTY);
|
||||
if(typeJN !=null) {
|
||||
cls = objectNode.get(Element.TYPE_PROPERTY).asText();
|
||||
}
|
||||
Iterator<String> iterator = jsonNode.fieldNames();
|
||||
|
||||
if(cls==null && objectNode.getNodeType()==JsonNodeType.OBJECT) {
|
||||
cls = Property.NAME;
|
||||
}
|
||||
|
||||
if(!knownTypes.containsKey(cls)) {
|
||||
objectNode = setTypeToBestAvailable(objectNode);
|
||||
}
|
||||
Iterator<String> iterator = objectNode.fieldNames();
|
||||
while(iterator.hasNext()) {
|
||||
String fieldName = iterator.next();
|
||||
JsonNode jn = jsonNode.get(fieldName);
|
||||
if(jn.getNodeType() == JsonNodeType.OBJECT) {
|
||||
jn = analizeFullJson(jn);
|
||||
((ObjectNode) jsonNode).set(fieldName, jn);
|
||||
JsonNode jn = objectNode.get(fieldName);
|
||||
switch (jn.getNodeType()) {
|
||||
case OBJECT:
|
||||
jn = analizeTypes((ObjectNode)jn);
|
||||
break;
|
||||
|
||||
case ARRAY:
|
||||
jn = analizeTypes((ArrayNode) jn);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
objectNode.replace(fieldName, jn);
|
||||
}
|
||||
return jsonNode;
|
||||
return objectNode;
|
||||
}
|
||||
|
||||
protected static ArrayNode analizeTypes(ArrayNode arrayNode) {
|
||||
ArrayNode ret = mapper.createArrayNode();
|
||||
|
||||
for(JsonNode jsonNode : arrayNode) {
|
||||
|
||||
switch (jsonNode.getNodeType()) {
|
||||
case OBJECT:
|
||||
jsonNode = analizeTypes((ObjectNode) jsonNode);
|
||||
break;
|
||||
|
||||
case ARRAY:
|
||||
jsonNode = analizeTypes((ArrayNode) jsonNode);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ret.add(jsonNode);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -267,10 +320,17 @@ public abstract class ElementMapper {
|
|||
throws JsonParseException, JsonMappingException, IOException {
|
||||
try {
|
||||
return mapper.readValue(reader, clz);
|
||||
} catch (JsonMappingException e) {
|
||||
} catch (InvalidTypeIdException e) {
|
||||
if(!ModelElement.class.isAssignableFrom(clz)) {
|
||||
throw e;
|
||||
}
|
||||
JsonNode jsonNode = mapper.readTree(reader);
|
||||
jsonNode = analizeFullJson(jsonNode);
|
||||
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
|
||||
jsonNode = analizeTypes((ObjectNode) jsonNode);
|
||||
try {
|
||||
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
|
||||
}catch (Throwable t) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,10 +348,17 @@ public abstract class ElementMapper {
|
|||
throws JsonParseException, JsonMappingException, IOException {
|
||||
try {
|
||||
return mapper.readValue(stream, clz);
|
||||
} catch (JsonMappingException e) {
|
||||
} catch (InvalidTypeIdException e) {
|
||||
if(!ModelElement.class.isAssignableFrom(clz)) {
|
||||
throw e;
|
||||
}
|
||||
JsonNode jsonNode = mapper.readTree(stream);
|
||||
jsonNode = analizeFullJson(jsonNode);
|
||||
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
|
||||
jsonNode = analizeTypes((ObjectNode) jsonNode);
|
||||
try {
|
||||
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
|
||||
}catch (Throwable t) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,11 +375,18 @@ public abstract class ElementMapper {
|
|||
throws JsonParseException, JsonMappingException, IOException {
|
||||
try {
|
||||
return mapper.readValue(string, clz);
|
||||
} catch (JsonMappingException e) {
|
||||
} catch (InvalidTypeIdException e) {
|
||||
if(!ModelElement.class.isAssignableFrom(clz)) {
|
||||
throw e;
|
||||
}
|
||||
JsonNode jsonNode = mapper.readTree(string);
|
||||
jsonNode = analizeFullJson(jsonNode);
|
||||
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
|
||||
}
|
||||
jsonNode = analizeTypes((ObjectNode) jsonNode);
|
||||
try {
|
||||
return ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode));
|
||||
}catch (Throwable t) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static <El extends Element> List<El> unmarshalList(Class<El> clz, String string)
|
||||
|
@ -320,12 +394,19 @@ public abstract class ElementMapper {
|
|||
JavaType type = mapper.getTypeFactory().constructCollectionType(ArrayList.class, clz);
|
||||
try {
|
||||
return mapper.readValue(string, type);
|
||||
} catch (JsonMappingException e) {
|
||||
} catch (InvalidTypeIdException e) {
|
||||
if(!ModelElement.class.isAssignableFrom(clz)) {
|
||||
throw e;
|
||||
}
|
||||
List<El> ret = new ArrayList<>();
|
||||
ArrayNode arrayNode = (ArrayNode) mapper.readTree(string);
|
||||
for(JsonNode jsonNode : arrayNode) {
|
||||
jsonNode = analizeFullJson(jsonNode);
|
||||
ret.add(ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode)));
|
||||
try {
|
||||
for(JsonNode jsonNode : arrayNode) {
|
||||
jsonNode = analizeTypes((ObjectNode) jsonNode);
|
||||
ret.add(ElementMapper.unmarshal(clz, mapper.writeValueAsString(jsonNode)));
|
||||
}
|
||||
}catch (Throwable t) {
|
||||
throw e;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -336,12 +417,16 @@ public abstract class ElementMapper {
|
|||
JavaType type = mapper.getTypeFactory().constructCollectionType(ArrayList.class, Element.class);
|
||||
try {
|
||||
return mapper.readValue(string, type);
|
||||
} catch (JsonMappingException e) {
|
||||
} catch (InvalidTypeIdException e) {
|
||||
List<El> ret = new ArrayList<>();
|
||||
ArrayNode arrayNode = (ArrayNode) mapper.readTree(string);
|
||||
for(JsonNode jsonNode : arrayNode) {
|
||||
jsonNode = analizeFullJson(jsonNode);
|
||||
ret.add((El) ElementMapper.unmarshal(Element.class, mapper.writeValueAsString(jsonNode)));
|
||||
try {
|
||||
for(JsonNode jsonNode : arrayNode) {
|
||||
jsonNode = analizeTypes((ObjectNode) jsonNode);
|
||||
ret.add((El) ElementMapper.unmarshal(Element.class, mapper.writeValueAsString(jsonNode)));
|
||||
}
|
||||
}catch (Throwable t) {
|
||||
throw e;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -2,10 +2,13 @@ package org.gcube.informationsystem.tree;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public interface NodeInformation<T> {
|
||||
|
||||
public abstract String getIdentifier(T t);
|
||||
public String getIdentifier(T t);
|
||||
|
||||
public abstract Set<String> getParentIdentifiers(T root, T t);
|
||||
public Set<String> getParentIdentifiers(T root, T t);
|
||||
|
||||
}
|
||||
|
|
|
@ -11,18 +11,53 @@ public class Tree<T> {
|
|||
|
||||
private boolean allowMultipleInheritance;
|
||||
|
||||
private Node<T> root;
|
||||
private Node<T> rootNode;
|
||||
private NodeInformation<T> ni;
|
||||
private Map<String, Node<T>> locate;
|
||||
|
||||
public Tree(T t, NodeInformation<T> ni) throws Exception {
|
||||
public Tree() {
|
||||
this.allowMultipleInheritance = true;
|
||||
this.ni = ni;
|
||||
this.locate = new HashMap<>();
|
||||
this.root = new Node<>(t);
|
||||
this.root.setTree(this);
|
||||
String identifier = ni.getIdentifier(t);
|
||||
this.locate.put(identifier, root);
|
||||
}
|
||||
|
||||
public Tree(NodeInformation<T> ni) {
|
||||
this();
|
||||
setNodeInformation(ni);
|
||||
}
|
||||
|
||||
public Tree(T root, NodeInformation<T> ni) {
|
||||
this(ni);
|
||||
setRoot(root);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the NodeInformation if and only if it was not previously set.
|
||||
* Otherwise this function has no effect.
|
||||
* @param ni the NodeInformation to set
|
||||
*/
|
||||
public void setNodeInformation(NodeInformation<T> ni) {
|
||||
if(this.ni==null) {
|
||||
this.ni = ni;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the root if and only if it was not previously set.
|
||||
* Otherwise this function has no effect.
|
||||
* This function raises a RuntimeException is the
|
||||
* NodeInformation was not previously set.
|
||||
* @param root the root to set
|
||||
*/
|
||||
public void setRoot(T root) throws RuntimeException {
|
||||
if(this.ni==null) {
|
||||
throw new RuntimeException("You must set the NodeInformation instance first");
|
||||
}
|
||||
if(this.rootNode==null) {
|
||||
this.rootNode = new Node<>(root);
|
||||
this.rootNode.setTree(this);
|
||||
String identifier = ni.getIdentifier(root);
|
||||
this.locate.put(identifier, rootNode);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAllowMultipleInheritance(boolean allowMultipleInheritance) {
|
||||
|
@ -43,17 +78,25 @@ public class Tree<T> {
|
|||
Node<T> node = new Node<>(t);
|
||||
node.setTree(this);
|
||||
|
||||
Set<String> parentIdentifiers = ni.getParentIdentifiers(root.getNodeElement(), t);
|
||||
for(String parentIdentifier : parentIdentifiers) {
|
||||
Node<T> parentNode = locate.get(parentIdentifier);
|
||||
if(parentNode==null) {
|
||||
throw new RuntimeException("I can find parent for " + identifier + ". Missing parent is " + parentIdentifier);
|
||||
Set<String> parentIdentifiers = ni.getParentIdentifiers(rootNode!= null ? rootNode.getNodeElement() : null, t);
|
||||
if(parentIdentifiers==null || parentIdentifiers.size()==0) {
|
||||
if(this.rootNode==null) {
|
||||
this.rootNode = node;
|
||||
}else {
|
||||
throw new RuntimeException("A Tree cannot have two root. " + t.toString() + " has not parent.");
|
||||
}
|
||||
|
||||
parentNode.addChild(node);
|
||||
|
||||
if(!allowMultipleInheritance) {
|
||||
break;
|
||||
} else {
|
||||
for(String parentIdentifier : parentIdentifiers) {
|
||||
Node<T> parentNode = locate.get(parentIdentifier);
|
||||
if(parentNode==null) {
|
||||
throw new RuntimeException("I can find parent for " + identifier + ". Missing parent is " + parentIdentifier);
|
||||
}
|
||||
|
||||
parentNode.addChild(node);
|
||||
|
||||
if(!allowMultipleInheritance) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,16 +105,20 @@ public class Tree<T> {
|
|||
return node;
|
||||
}
|
||||
|
||||
public Node<T> getRoot() {
|
||||
return root;
|
||||
public Node<T> getRootNode() {
|
||||
return rootNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return root.toString();
|
||||
return rootNode.toString();
|
||||
}
|
||||
|
||||
public void elaborate(NodeElaborator<T> nodeElaborator) throws Exception {
|
||||
root.elaborate(nodeElaborator);
|
||||
rootNode.elaborate(nodeElaborator);
|
||||
}
|
||||
|
||||
public Node<T> getNodeByIdentifier(String identifier){
|
||||
return locate.get(identifier);
|
||||
}
|
||||
}
|
|
@ -27,6 +27,30 @@ public class PropertyTypeName {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(PropertyTypeName.class);
|
||||
|
||||
public enum BaseTypeGroup {
|
||||
|
||||
ANY( BaseType.values()),
|
||||
BOOLEAN( new BaseType[]{ BaseType.BOOLEAN } ),
|
||||
NUMERIC( new BaseType[]{ BaseType.INTEGER, BaseType.SHORT, BaseType.LONG, BaseType.FLOAT }),
|
||||
STRING( new BaseType[]{ BaseType.STRING }),
|
||||
DATE( new BaseType[]{ BaseType.DATE } ),
|
||||
BITS( new BaseType[]{ BaseType.BINARY, BaseType.BYTE } ),
|
||||
COMPLEX( new BaseType[]{ BaseType.PROPERTY } ),
|
||||
COLLECTION( new BaseType[]{ BaseType.LIST, BaseType.SET } ),
|
||||
MAP( new BaseType[]{ BaseType.MAP });
|
||||
|
||||
private final BaseType[] group;
|
||||
|
||||
private BaseTypeGroup(BaseType[] group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public BaseType[] getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum BaseType {
|
||||
|
||||
BOOLEAN("Boolean"),
|
||||
|
|
|
@ -201,32 +201,4 @@ public class TypeMapper {
|
|||
return map;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
private final static String NAME = "NAME";
|
||||
|
||||
public static String getStaticStringFieldByName(Class<? extends Element> clz, String fieldName, String defaultValue){
|
||||
Field field;
|
||||
try {
|
||||
field = clz.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
return (String) field.get(null);
|
||||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <O extends Object> O getStaticFieldByName(Class<? extends Element> clz, String fieldName, O defaultValue){
|
||||
Field field;
|
||||
try {
|
||||
field = clz.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
return (O) field.get(null);
|
||||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
@ -20,7 +21,7 @@ import org.gcube.informationsystem.base.reference.Element;
|
|||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
import org.gcube.informationsystem.types.annotations.Final;
|
||||
|
@ -31,6 +32,7 @@ import org.gcube.informationsystem.types.impl.properties.PropertyTypeImpl;
|
|||
import org.gcube.informationsystem.types.impl.relations.RelationTypeImpl;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
import org.gcube.informationsystem.utils.TypeUtility;
|
||||
import org.gcube.informationsystem.utils.Version;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -57,9 +59,9 @@ public class TypeImpl implements Type {
|
|||
DEFAULT_CHANGELOG_MAP_KEY_AS_STRING.put(Version.MINIMAL_VERSION_STRING, Version.MINIMAL_VERSION_DESCRIPTION);
|
||||
}
|
||||
|
||||
protected UUID uuid;
|
||||
protected Metadata metadata;
|
||||
|
||||
protected Header header;
|
||||
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected Version version;
|
||||
|
@ -73,7 +75,7 @@ public class TypeImpl implements Type {
|
|||
@JsonProperty(value = FINAL_PROPERTY)
|
||||
protected boolean finalClass;
|
||||
|
||||
protected Set<String> superClasses;
|
||||
protected Set<String> extendedTypes;
|
||||
|
||||
protected Set<PropertyDefinition> properties;
|
||||
|
||||
|
@ -186,15 +188,25 @@ public class TypeImpl implements Type {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Header getHeader() {
|
||||
return header;
|
||||
public UUID getID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeader(Header header) {
|
||||
this.header = header;
|
||||
public void setID(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Metadata getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(Metadata metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -263,8 +275,8 @@ public class TypeImpl implements Type {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSuperClasses() {
|
||||
return superClasses;
|
||||
public Set<String> getExtendedTypes() {
|
||||
return extendedTypes;
|
||||
}
|
||||
|
||||
@JsonInclude(Include.NON_EMPTY)
|
||||
|
@ -277,5 +289,10 @@ public class TypeImpl implements Type {
|
|||
public AccessType getAccessType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TypeUtility.getTypeName(this.getClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
|||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.queries.templates.reference.entities.QueryTemplate;
|
||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||
import org.gcube.informationsystem.types.impl.TypeImpl;
|
||||
|
@ -66,17 +66,17 @@ public class EntityTypeImpl extends TypeImpl implements EntityType {
|
|||
if(EntityType.class.isAssignableFrom(clz)){
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends EntityType> c = (Class<? extends EntityType>) clz;
|
||||
this.superClasses = retrieveSuperClasses(c, EntityType.class, EntityElement.NAME);
|
||||
this.extendedTypes = retrieveSuperClasses(c, EntityType.class, EntityElement.NAME);
|
||||
} else if(Context.class.isAssignableFrom(clz)){
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends Context> c = (Class<? extends Context>) clz;
|
||||
this.superClasses = retrieveSuperClasses(c, Context.class, EntityElement.NAME);
|
||||
this.extendedTypes = retrieveSuperClasses(c, Context.class, EntityElement.NAME);
|
||||
} else if(QueryTemplate.class.isAssignableFrom(clz)){
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends QueryTemplate> c = (Class<? extends QueryTemplate>) clz;
|
||||
this.superClasses = retrieveSuperClasses(c, QueryTemplate.class, EntityElement.NAME);
|
||||
this.extendedTypes = retrieveSuperClasses(c, QueryTemplate.class, EntityElement.NAME);
|
||||
} else if(EntityElement.class.isAssignableFrom(clz)){
|
||||
this.superClasses = retrieveSuperClasses(clz, EntityElement.class, null);
|
||||
this.extendedTypes = retrieveSuperClasses(clz, EntityElement.class, null);
|
||||
} else {
|
||||
throw new RuntimeException("Type Hierachy Error for class " + clz.getSimpleName());
|
||||
}
|
||||
|
@ -91,16 +91,16 @@ public class EntityTypeImpl extends TypeImpl implements EntityType {
|
|||
* We need to copy them.
|
||||
*/
|
||||
|
||||
protected Header header;
|
||||
protected Metadata metadata;
|
||||
|
||||
@Override
|
||||
public Header getHeader() {
|
||||
return header;
|
||||
public Metadata getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeader(Header header){
|
||||
this.header = header;
|
||||
public void setMetadata(Metadata metadata){
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,7 +111,7 @@ public class EntityTypeImpl extends TypeImpl implements EntityType {
|
|||
return stringWriter.toString();
|
||||
}catch(Exception e){
|
||||
try {
|
||||
ElementMapper.marshal(this.header, stringWriter);
|
||||
ElementMapper.marshal(this.metadata, stringWriter);
|
||||
return stringWriter.toString();
|
||||
} catch(Exception e1){
|
||||
return super.toString();
|
||||
|
|
|
@ -29,7 +29,7 @@ public final class FacetTypeImpl extends EntityTypeImpl implements FacetType {
|
|||
|
||||
public FacetTypeImpl(Class<? extends Facet> clz) {
|
||||
super(clz);
|
||||
this.superClasses = retrieveSuperClasses(clz, Facet.class, Entity.NAME);
|
||||
this.extendedTypes = retrieveSuperClasses(clz, Facet.class, Entity.NAME);
|
||||
this.properties = retrieveListOfProperties(clz);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public final class ResourceTypeImpl extends EntityTypeImpl implements ResourceTy
|
|||
public ResourceTypeImpl(Class<? extends Resource> clz) {
|
||||
super(clz);
|
||||
|
||||
this.superClasses = retrieveSuperClasses(clz, Resource.class, Entity.NAME);
|
||||
this.extendedTypes = retrieveSuperClasses(clz, Resource.class, Entity.NAME);
|
||||
|
||||
setResourceSchemaEntries(clz);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
|||
import org.gcube.informationsystem.types.PropertyTypeName;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
import org.gcube.informationsystem.utils.TypeUtility;
|
||||
import org.gcube.informationsystem.utils.Version;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -156,12 +157,12 @@ public final class PropertyDefinitionImpl implements PropertyDefinition {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
public String getPropertyType() {
|
||||
return propertyTypeName.toString();
|
||||
}
|
||||
|
||||
@JsonSetter(value = PropertyDefinition.TYPE_PROPERTY)
|
||||
public void setType(String type) {
|
||||
@JsonSetter(value = PropertyDefinition.PROPERTY_TYPE_PROPERTY)
|
||||
public void setPropertyType(String type) {
|
||||
this.propertyTypeName = new PropertyTypeName(type);
|
||||
}
|
||||
|
||||
|
@ -281,4 +282,9 @@ public final class PropertyDefinitionImpl implements PropertyDefinition {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TypeUtility.getTypeName(this.getClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public final class PropertyTypeImpl<P extends PropertyElement> extends TypeImpl
|
|||
|
||||
public PropertyTypeImpl(Class<P> clz) {
|
||||
super(clz);
|
||||
this.superClasses = retrieveSuperClasses(clz, PropertyElement.class,
|
||||
this.extendedTypes = retrieveSuperClasses(clz, PropertyElement.class,
|
||||
clz == PropertyElement.class ? null : PropertyElement.NAME);
|
||||
|
||||
this.properties = retrieveListOfProperties(clz);
|
||||
|
@ -83,7 +83,7 @@ public final class PropertyTypeImpl<P extends PropertyElement> extends TypeImpl
|
|||
return stringWriter.toString();
|
||||
}catch(Exception e){
|
||||
try {
|
||||
ElementMapper.marshal(this.header, stringWriter);
|
||||
ElementMapper.marshal(this.metadata, stringWriter);
|
||||
return stringWriter.toString();
|
||||
} catch(Exception e1){
|
||||
return super.toString();
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class ConsistsOfTypeImpl extends RelationTypeImpl<ResourceType, Fac
|
|||
public ConsistsOfTypeImpl(Class<? extends ConsistsOf<? extends Resource, ? extends Facet>> clz) {
|
||||
super(clz);
|
||||
|
||||
this.superClasses = retrieveSuperClasses(clz, ConsistsOf.class, Relation.NAME);
|
||||
this.extendedTypes = retrieveSuperClasses(clz, ConsistsOf.class, Relation.NAME);
|
||||
|
||||
this.properties = retrieveListOfProperties(clz);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public final class IsRelatedToTypeImpl extends RelationTypeImpl<ResourceType, Re
|
|||
public IsRelatedToTypeImpl(Class<? extends IsRelatedTo<? extends Resource, ? extends Resource>> clz) {
|
||||
super(clz);
|
||||
|
||||
this.superClasses = retrieveSuperClasses(clz, IsRelatedTo.class, Relation.NAME);
|
||||
this.extendedTypes = retrieveSuperClasses(clz, IsRelatedTo.class, Relation.NAME);
|
||||
|
||||
this.properties = retrieveListOfProperties(clz);
|
||||
|
||||
|
|
|
@ -58,13 +58,13 @@ public class RelationTypeImpl<S extends EntityType, T extends EntityType>
|
|||
if(RelationType.class.isAssignableFrom(clz)) {
|
||||
@SuppressWarnings({"unchecked"})
|
||||
Class<RelationType<?,?>> c = (Class<RelationType<?,?>>) clz;
|
||||
this.superClasses = retrieveSuperClasses(c, RelationType.class, RelationElement.NAME);
|
||||
this.extendedTypes = retrieveSuperClasses(c, RelationType.class, RelationElement.NAME);
|
||||
} else if(IsParentOf.class.isAssignableFrom(clz)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends IsParentOf> c = (Class<? extends IsParentOf>) clz;
|
||||
this.superClasses = retrieveSuperClasses(c, IsParentOf.class, RelationElement.NAME);
|
||||
this.extendedTypes = retrieveSuperClasses(c, IsParentOf.class, RelationElement.NAME);
|
||||
} else if(RelationElement.class.isAssignableFrom(clz)) {
|
||||
this.superClasses = retrieveSuperClasses(clz, RelationElement.class, null);
|
||||
this.extendedTypes = retrieveSuperClasses(clz, RelationElement.class, null);
|
||||
} else {
|
||||
throw new RuntimeException("Type Hierachy Error");
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public class RelationTypeImpl<S extends EntityType, T extends EntityType>
|
|||
return stringWriter.toString();
|
||||
}catch(Exception e){
|
||||
try {
|
||||
ElementMapper.marshal(this.header, stringWriter);
|
||||
ElementMapper.marshal(this.metadata, stringWriter);
|
||||
return stringWriter.toString();
|
||||
} catch(Exception e1){
|
||||
return super.toString();
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package org.gcube.informationsystem.types.knowledge;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class TypeInformation implements org.gcube.informationsystem.model.knowledge.TypeInformation<Type> {
|
||||
|
||||
@Override
|
||||
public String getIdentifier(Type type) {
|
||||
return type.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getParentIdentifiers(Type root, Type type) {
|
||||
if(root!=null && type.getName().compareTo(root.getName())==0) {
|
||||
return new LinkedHashSet<>();
|
||||
}
|
||||
if(root==null && AccessType.getAccessType(type.getName())!=null) {
|
||||
return new LinkedHashSet<>();
|
||||
}
|
||||
return type.getExtendedTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType(Type type) {
|
||||
return type.getAccessType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getRoot(AccessType accessType) {
|
||||
return TypeMapper.createTypeDefinition(accessType.getTypeClass());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package org.gcube.informationsystem.types.knowledge;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.model.knowledge.ModelKnowledge;
|
||||
import org.gcube.informationsystem.model.knowledge.TypesDiscoverer;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class TypesKnowledge {
|
||||
|
||||
private static TypesKnowledge instance;
|
||||
|
||||
public synchronized static TypesKnowledge getInstance() {
|
||||
if(instance==null) {
|
||||
instance = new TypesKnowledge();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
// in millisec
|
||||
public static final long DEFAULT_EXPIRING_TIMEOUT;
|
||||
|
||||
static {
|
||||
DEFAULT_EXPIRING_TIMEOUT = TimeUnit.HOURS.toMillis(6);
|
||||
|
||||
}
|
||||
|
||||
protected boolean initialized;
|
||||
public int expiringTimeout;
|
||||
|
||||
// in millisec used only for logging and debugging
|
||||
protected Calendar creationTime;
|
||||
// in millisec
|
||||
protected Calendar expiringTime;
|
||||
|
||||
protected ModelKnowledge<Type, TypeInformation> modelKnowledge;
|
||||
protected TypesDiscoverer<Type> typesDiscoverer;
|
||||
|
||||
public TypesKnowledge() {
|
||||
initialized = false;
|
||||
expiringTimeout = (int) DEFAULT_EXPIRING_TIMEOUT;
|
||||
modelKnowledge = new ModelKnowledge<>(new TypeInformation());
|
||||
}
|
||||
|
||||
public void setExpiringTimeout(int expiringTimeout) {
|
||||
this.expiringTimeout = expiringTimeout;
|
||||
}
|
||||
|
||||
public TypesDiscoverer<Type> getTypesDiscoverer() {
|
||||
return typesDiscoverer;
|
||||
}
|
||||
|
||||
public void setTypesDiscoverer(TypesDiscoverer<Type> typesDiscoverer) {
|
||||
this.typesDiscoverer = typesDiscoverer;
|
||||
}
|
||||
|
||||
public ModelKnowledge<Type, TypeInformation> getModelKnowledge() {
|
||||
if(!initialized) {
|
||||
discover();
|
||||
}else {
|
||||
Calendar now = Calendar.getInstance();
|
||||
if(now.after(expiringTime)) {
|
||||
renew();
|
||||
}
|
||||
}
|
||||
return modelKnowledge;
|
||||
}
|
||||
|
||||
protected synchronized void init(boolean forceReinitialization) {
|
||||
if(typesDiscoverer!=null && (initialized==false || forceReinitialization)) {
|
||||
initialized = false;
|
||||
modelKnowledge = new ModelKnowledge<>(new TypeInformation());
|
||||
AccessType[] modelTypes = AccessType.getModelTypes();
|
||||
for(AccessType modelType : modelTypes) {
|
||||
Collection<Type> types = typesDiscoverer.discover(modelType);
|
||||
modelKnowledge.addAllType(types);
|
||||
}
|
||||
initialized = true;
|
||||
this.creationTime = Calendar.getInstance();
|
||||
this.expiringTime = Calendar.getInstance();
|
||||
this.expiringTime.setTimeInMillis(creationTime.getTimeInMillis());
|
||||
this.expiringTime.add(Calendar.MILLISECOND, -1);
|
||||
this.expiringTime.add(Calendar.MILLISECOND, expiringTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method do nothing if TypesDiscoverer
|
||||
* was not set.
|
||||
* Otherwise initialized the ModelKnowledge
|
||||
* if it was not already initialized.
|
||||
* To enforce rediscovery use renew method.
|
||||
*/
|
||||
public void discover() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force reinitialization of
|
||||
*/
|
||||
public void renew() {
|
||||
init(true);
|
||||
}
|
||||
}
|
|
@ -2,12 +2,17 @@ package org.gcube.informationsystem.types.reference;
|
|||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
import org.gcube.informationsystem.utils.Version;
|
||||
|
@ -17,12 +22,13 @@ import org.gcube.informationsystem.utils.Version;
|
|||
*/
|
||||
@Abstract
|
||||
@JsonIgnoreProperties(ignoreUnknown=true)
|
||||
@TypeMetadata(name = Type.NAME, description = "This is the base class to define any Type", version = Version.MINIMAL_VERSION_STRING)
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, IdentifiableElement.ID_PROPERTY, IdentifiableElement.METADATA_PROPERTY })
|
||||
@TypeMetadata(name = Type.NAME, description = "This is the base type to define any Type", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
//@JsonDeserialize(as=TypeImpl.class) Do not uncomment to manage subclasses
|
||||
public interface Type extends IdentifiableElement {
|
||||
|
||||
public static final String NAME = "Type"; //Type.class.getSimpleName();
|
||||
public static final String NAME = "Type"; // Type.class.getSimpleName();
|
||||
|
||||
public static final String NAME_PROPERTY = "name";
|
||||
public static final String DESCRIPTION_PROPERTY = "description";
|
||||
|
@ -30,9 +36,26 @@ public interface Type extends IdentifiableElement {
|
|||
public static final String CHANGELOG_PROPERTY = "changelog";
|
||||
public static final String ABSTRACT_PROPERTY = "abstract";
|
||||
public static final String FINAL_PROPERTY = "final";
|
||||
public static final String TYPE_SUPERCLASSES_PROPERTY = "superClasses";
|
||||
/* Cannot use 'supertypes' which conflicts with Element */
|
||||
public static final String EXTENDED_TYPES_PROPERTY = "extendedTypes";
|
||||
public static final String PROPERTIES_PROPERTY = "properties";
|
||||
|
||||
@JsonGetter(value = ID_PROPERTY)
|
||||
@Override
|
||||
public UUID getID();
|
||||
|
||||
@JsonSetter(value = ID_PROPERTY)
|
||||
@Override
|
||||
public void setID(UUID uuid);
|
||||
|
||||
@JsonGetter(value = METADATA_PROPERTY)
|
||||
@Override
|
||||
public Metadata getMetadata();
|
||||
|
||||
@JsonSetter(value = METADATA_PROPERTY)
|
||||
@Override
|
||||
public void setMetadata(Metadata metadata);
|
||||
|
||||
public String getName();
|
||||
|
||||
public String getDescription();
|
||||
|
@ -55,7 +78,8 @@ public interface Type extends IdentifiableElement {
|
|||
@JsonGetter(value = FINAL_PROPERTY)
|
||||
public boolean isFinal();
|
||||
|
||||
public Set<String> getSuperClasses();
|
||||
@JsonGetter(value = EXTENDED_TYPES_PROPERTY)
|
||||
public Set<String> getExtendedTypes();
|
||||
|
||||
public Set<PropertyDefinition> getProperties();
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ import org.gcube.informationsystem.utils.Version;
|
|||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonDeserialize(as = EntityTypeImpl.class)
|
||||
@TypeMetadata(name = EntityType.NAME, description = "This class provides information for any EntityType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = EntityType.NAME, description = "This type provides information for any EntityType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface EntityType extends Type, EntityElement {
|
||||
|
||||
public static final String NAME = "EntityType"; //EntityType.class.getSimpleName();
|
||||
|
||||
/* TypeDefinition is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||
/* Type is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||
|
||||
@Override
|
||||
@ISProperty(name = Type.NAME_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||
|
@ -38,9 +38,9 @@ public interface EntityType extends Type, EntityElement {
|
|||
public boolean isAbstract();
|
||||
|
||||
@Override
|
||||
@ISProperty(name = Type.TYPE_SUPERCLASSES_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||
public Set<String> getSuperClasses();
|
||||
@ISProperty(name = Type.EXTENDED_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||
public Set<String> getExtendedTypes();
|
||||
|
||||
/* {@link Type} is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||
/* Type is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonDeserialize(as = FacetTypeImpl.class)
|
||||
@TypeMetadata(name = FacetType.NAME, description = "This class provides information for the definition of any FacetType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = FacetType.NAME, description = "This type provides information for the definition of any FacetType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
@Final
|
||||
public interface FacetType extends EntityType {
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonDeserialize(as=ResourceTypeImpl.class)
|
||||
@TypeMetadata(name = ResourceType.NAME, description = "This class provides information for the definition of any ResourceType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = ResourceType.NAME, description = "This type provides information for the definition of any ResourceType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
@Final
|
||||
public interface ResourceType extends EntityType {
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonDeserialize(as = PropertyDefinitionImpl.class)
|
||||
@TypeMetadata(name = PropertyDefinition.NAME, description = "This class provides information for the definition of any properties", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = PropertyDefinition.NAME, description = "This type provides information for the definition of any properties", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
@Final
|
||||
public interface PropertyDefinition extends PropertyElement, Comparable<PropertyDefinition> {
|
||||
|
@ -30,7 +30,7 @@ public interface PropertyDefinition extends PropertyElement, Comparable<Property
|
|||
public static final String MAX_PROPERTY = "max";
|
||||
public static final String MIN_PROPERTY = "min";
|
||||
public static final String REGEX_PROPERTY = "regexp";
|
||||
public static final String TYPE_PROPERTY = "type";
|
||||
public static final String PROPERTY_TYPE_PROPERTY = "propertyType";
|
||||
|
||||
@ISProperty(name = NAME_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||
public String getName();
|
||||
|
@ -56,7 +56,7 @@ public interface PropertyDefinition extends PropertyElement, Comparable<Property
|
|||
@ISProperty(name = REGEX_PROPERTY, readonly = false, mandatory = true, nullable = false)
|
||||
public String getRegexp();
|
||||
|
||||
@ISProperty(name = TYPE_PROPERTY, readonly = false, mandatory = true, nullable = false)
|
||||
public String getType();
|
||||
@ISProperty(name = PROPERTY_TYPE_PROPERTY, readonly = false, mandatory = true, nullable = false)
|
||||
public String getPropertyType();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package org.gcube.informationsystem.types.reference.properties;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.types.annotations.Final;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.impl.properties.PropertyTypeImpl;
|
||||
|
@ -20,19 +22,32 @@ import org.gcube.informationsystem.utils.Version;
|
|||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonDeserialize(as = PropertyTypeImpl.class)
|
||||
@TypeMetadata(name = PropertyType.NAME, description = "This class provides information for any PropertyType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = PropertyType.NAME, description = "This type provides information for any PropertyType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
@Final
|
||||
public interface PropertyType<P extends PropertyElement> extends PropertyElement, Type {
|
||||
|
||||
public static final String NAME = "PropertyType"; // PropertyTypeDefinition.class.getSimpleName();
|
||||
public static final String NAME = "PropertyType"; // PropertyType.class.getSimpleName();
|
||||
|
||||
@ISProperty(name=IdentifiableElement.HEADER_PROPERTY, mandatory=true, nullable=false)
|
||||
public Header getHeader();
|
||||
@JsonGetter(value = ID_PROPERTY)
|
||||
@ISProperty(name = ID_PROPERTY, description = "This UUID is be used to identify the instance univocally.", readonly = true, mandatory = true, nullable = false)
|
||||
@Override
|
||||
public UUID getID();
|
||||
|
||||
@JsonSetter(value = ID_PROPERTY)
|
||||
@Override
|
||||
public void setID(UUID uuid);
|
||||
|
||||
public void setHeader(Header header);
|
||||
@JsonGetter(value = METADATA_PROPERTY)
|
||||
@ISProperty(name=METADATA_PROPERTY, mandatory=true, nullable=false, description="Metadata associated with the instance that is automatically created/updated by the system.")
|
||||
@Override
|
||||
public Metadata getMetadata();
|
||||
|
||||
/* TypeDefinition is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||
@JsonSetter(value = METADATA_PROPERTY)
|
||||
@Override
|
||||
public void setMetadata(Metadata metadata);
|
||||
|
||||
/* Type is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||
|
||||
@Override
|
||||
@ISProperty(name = Type.NAME_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||
|
@ -47,12 +62,12 @@ public interface PropertyType<P extends PropertyElement> extends PropertyElement
|
|||
public boolean isAbstract();
|
||||
|
||||
@Override
|
||||
@ISProperty(name = Type.TYPE_SUPERCLASSES_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||
public Set<String> getSuperClasses();
|
||||
@ISProperty(name = Type.EXTENDED_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||
public Set<String> getExtendedTypes();
|
||||
|
||||
@ISProperty(name = Type.PROPERTIES_PROPERTY, readonly = false, mandatory = true, nullable = false)
|
||||
public Set<PropertyDefinition> getProperties();
|
||||
|
||||
/* TypeDefinition is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||
/*Type is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonDeserialize(as = ConsistsOfTypeImpl.class)
|
||||
@TypeMetadata(name = ConsistsOfType.NAME, description = "This class provides information for any ConsistsOfType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = ConsistsOfType.NAME, description = "This type provides information for any ConsistsOfType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
@Final
|
||||
public interface ConsistsOfType extends RelationType<ResourceType, FacetType> {
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonDeserialize(as = IsRelatedToTypeImpl.class)
|
||||
@TypeMetadata(name = IsRelatedToType.NAME, description = "This class provides information for any IsRelatedToType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = IsRelatedToType.NAME, description = "This type provides information for any IsRelatedToType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
@Final
|
||||
public interface IsRelatedToType extends RelationType<ResourceType, ResourceType> {
|
||||
|
|
|
@ -19,14 +19,14 @@ import org.gcube.informationsystem.utils.Version;
|
|||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonDeserialize(as = RelationTypeImpl.class)
|
||||
@TypeMetadata(name = RelationType.NAME, description = "This class provides information for any RelationType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@TypeMetadata(name = RelationType.NAME, description = "This type provides information for any RelationType", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
public interface RelationType<S extends EntityType, T extends EntityType>
|
||||
extends Type, RelationElement<S,T> {
|
||||
|
||||
public static final String NAME = "RelationType"; // RelationType.class.getSimpleName();
|
||||
|
||||
/* TypeDefinition is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||
/* Type is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||
|
||||
@Override
|
||||
@ISProperty(name = Type.NAME_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||
|
@ -41,8 +41,8 @@ public interface RelationType<S extends EntityType, T extends EntityType>
|
|||
public boolean isAbstract();
|
||||
|
||||
@Override
|
||||
@ISProperty(name = Type.TYPE_SUPERCLASSES_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||
public Set<String> getSuperClasses();
|
||||
@ISProperty(name = Type.EXTENDED_TYPES_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||
public Set<String> getExtendedTypes();
|
||||
|
||||
@Override
|
||||
@ISProperty(name = Type.PROPERTIES_PROPERTY, readonly = false, mandatory = true, nullable = false)
|
||||
|
@ -54,11 +54,6 @@ public interface RelationType<S extends EntityType, T extends EntityType>
|
|||
@Override
|
||||
public T getTarget();
|
||||
|
||||
/* TypeDefinition is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||
/*@JsonGetter(value=SOURCE_PROPERTY)
|
||||
public String getSourceType();
|
||||
|
||||
@JsonGetter(value=TARGET_PROPERTY)
|
||||
public String getTargetType();*/
|
||||
/* Type is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package org.gcube.informationsystem.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class JsonUtility {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(JsonUtility.class);
|
||||
|
||||
public static JsonNode getJsonNode(String json) throws JsonProcessingException, IOException {
|
||||
if(json==null || json.compareTo("")==0){
|
||||
return null;
|
||||
}
|
||||
logger.trace("Trying to get Jsonnode from {}", json);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode jsonNode = mapper.readTree(json);
|
||||
return jsonNode;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package org.gcube.informationsystem.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class TypeUtility {
|
||||
|
||||
public static String getTypeName(JsonNode jsonNode){
|
||||
if(jsonNode.has(Element.TYPE_PROPERTY)) {
|
||||
return jsonNode.get(Element.TYPE_PROPERTY).asText();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getTypeName(String json) throws JsonProcessingException, IOException{
|
||||
JsonNode jsonNode = JsonUtility.getJsonNode(json);
|
||||
return getTypeName(jsonNode);
|
||||
}
|
||||
|
||||
public static <E extends Element> String getTypeName(Class<E> clz){
|
||||
return TypeMapper.getType(clz);
|
||||
}
|
||||
|
||||
}
|
|
@ -10,8 +10,17 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class UUIDManager {
|
||||
|
||||
public static final Set<String> RESERVED_UUID_STRING;
|
||||
public static final Set<UUID> RESERVED_UUID;
|
||||
private static final Set<String> RESERVED_UUID_STRING;
|
||||
private static final Set<UUID> RESERVED_UUID;
|
||||
|
||||
private static UUIDManager uuidManager;
|
||||
|
||||
public static UUIDManager getInstance() {
|
||||
if(uuidManager==null) {
|
||||
uuidManager = new UUIDManager();
|
||||
}
|
||||
return uuidManager;
|
||||
}
|
||||
|
||||
private UUIDManager() {
|
||||
|
||||
|
@ -31,27 +40,42 @@ public final class UUIDManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isReservedUUID(UUID uuid) {
|
||||
public boolean isReservedUUID(UUID uuid) {
|
||||
return RESERVED_UUID.contains(uuid);
|
||||
}
|
||||
|
||||
public static boolean isReservedUUID(String uuid) {
|
||||
public boolean isReservedUUID(String uuid) {
|
||||
return RESERVED_UUID_STRING.contains(uuid);
|
||||
}
|
||||
|
||||
public static Set<String> getAllReservedUUIDAsStrings(){
|
||||
public Set<String> getAllReservedUUIDAsStrings(){
|
||||
return new TreeSet<>(RESERVED_UUID_STRING);
|
||||
}
|
||||
|
||||
public static Set<UUID> getAllReservedUUID(){
|
||||
public Set<UUID> getAllReservedUUID(){
|
||||
return new TreeSet<>(RESERVED_UUID);
|
||||
}
|
||||
|
||||
public static UUID generateValidRandomUUID() {
|
||||
UUID generated = UUID.randomUUID();
|
||||
while(RESERVED_UUID.contains(generated)) {
|
||||
generated = UUID.randomUUID();
|
||||
}
|
||||
return generated;
|
||||
public UUID generateValidUUID() {
|
||||
return generateValidUUID(null);
|
||||
}
|
||||
|
||||
public UUID generateValidUUID(UUID uuid) {
|
||||
uuid = uuid==null ? UUID.randomUUID() : uuid;
|
||||
while(RESERVED_UUID.contains(uuid)) {
|
||||
uuid = UUID.randomUUID();
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public UUID validateUUID(UUID uuid) throws Exception {
|
||||
if(RESERVED_UUID.contains(uuid)) {
|
||||
throw new Exception(uuid.toString() + " UUID is reserved. All the following UUID are reserved " + getAllReservedUUIDAsStrings().toString());
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package org.gcube.informationsystem.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class UUIDUtility {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(UUIDUtility.class);
|
||||
|
||||
public static UUID getUUID(JsonNode jsonNode){
|
||||
if(jsonNode.has(IdentifiableElement.ID_PROPERTY)) {
|
||||
JsonNode jsonNodeID = jsonNode.get(IdentifiableElement.ID_PROPERTY);
|
||||
if(jsonNodeID!=null && jsonNodeID.isTextual()) {
|
||||
return UUID.fromString(jsonNodeID.asText());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static UUID getUUID(String json) throws JsonProcessingException, IOException {
|
||||
logger.trace("Trying to get UUID of {} ", json);
|
||||
JsonNode jsonNode = JsonUtility.getJsonNode(json);
|
||||
return getUUID(jsonNode);
|
||||
}
|
||||
|
||||
public static String getUUIDAsString(JsonNode jsonNode){
|
||||
UUID uuid = getUUID(jsonNode);
|
||||
if(uuid!=null) {
|
||||
return uuid.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getUUIDAsString(String json) throws JsonProcessingException, IOException{
|
||||
return getUUID(json).toString();
|
||||
}
|
||||
|
||||
public static UUID fromString(String uuidString) throws Exception {
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
UUIDManager.getInstance().validateUUID(uuid);
|
||||
return uuid;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.informationsystem.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class Utility {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(Utility.class);
|
||||
|
||||
public static UUID getUUIDFromJsonNode(JsonNode jsonNode){
|
||||
JsonNode header = jsonNode.get(Entity.HEADER_PROPERTY);
|
||||
UUID uuid = UUID.fromString(header.get(Header.UUID_PROPERTY).asText());
|
||||
logger.trace("UUID got from {} is : {} ", jsonNode.toString(), uuid);
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public static UUID getUUIDFromJSONString(String json) throws JsonProcessingException, IOException {
|
||||
logger.trace("Trying to get UUID from {} of {} ", Header.class.getSimpleName(), json);
|
||||
JsonNode jsonNode = getJSONNode(json);
|
||||
return getUUIDFromJsonNode(jsonNode);
|
||||
}
|
||||
|
||||
public static JsonNode getJSONNode(String json) throws JsonProcessingException, IOException {
|
||||
if(json==null || json.compareTo("")==0){
|
||||
return null;
|
||||
}
|
||||
logger.trace("Trying to get Jsonnode from {}", json);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode jsonNode = mapper.readTree(json);
|
||||
return jsonNode;
|
||||
}
|
||||
|
||||
}
|
|
@ -15,7 +15,7 @@ import org.gcube.common.authorization.utils.secret.SecretUtility;
|
|||
import org.gcube.common.keycloak.KeycloakClientFactory;
|
||||
import org.gcube.common.keycloak.model.TokenResponse;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -112,7 +112,7 @@ public class ContextTest {
|
|||
}
|
||||
|
||||
public static String getUser() {
|
||||
String user = Header.UNKNOWN_USER;
|
||||
String user = Metadata.UNKNOWN_USER;
|
||||
try {
|
||||
user = SecretManagerProvider.instance.get().getUser().getUsername();
|
||||
} catch(Exception e) {
|
||||
|
|
|
@ -41,8 +41,8 @@ public class DiscoveryTest {
|
|||
Assert.assertTrue(type.getDescription().compareTo(expected.getDescription())==0);
|
||||
Assert.assertTrue(type.isAbstract() == expected.isAbstract());
|
||||
|
||||
Assert.assertTrue(type.getSuperClasses().containsAll(expected.getSuperClasses()));
|
||||
Assert.assertTrue(expected.getSuperClasses().containsAll(type.getSuperClasses()));
|
||||
Assert.assertTrue(type.getExtendedTypes().containsAll(expected.getExtendedTypes()));
|
||||
Assert.assertTrue(expected.getExtendedTypes().containsAll(type.getExtendedTypes()));
|
||||
|
||||
|
||||
Map<Version, String> typeChangelog = type.getChangelog();
|
||||
|
@ -82,7 +82,7 @@ public class DiscoveryTest {
|
|||
for(PropertyDefinition propertyDefinition : type.getProperties()) {
|
||||
if(propertyDefinition.getName().compareTo(PropertyType.PROPERTIES_PROPERTY)==0) {
|
||||
logger.debug("{}", propertyDefinition);
|
||||
Assert.assertTrue(propertyDefinition.getType().compareTo("Set<PropertyDefinition>")==0);
|
||||
Assert.assertTrue(propertyDefinition.getPropertyType().compareTo("Set<PropertyDefinition>")==0);
|
||||
}
|
||||
}
|
||||
String typeDefinitionJsonString = TypeMapper.serializeTypeDefinition(type);
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
package org.gcube.informationsystem.model.impl.properties;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.core.JsonParseException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class HeaderTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(HeaderTest.class);
|
||||
|
||||
@Test
|
||||
public void headerTest() throws Exception {
|
||||
HeaderImpl header = new HeaderImpl(UUID.randomUUID());
|
||||
Date date = Calendar.getInstance().getTime();
|
||||
header.creationTime = date;
|
||||
header.lastUpdateTime = date;
|
||||
header.createdBy = Header.UNKNOWN_USER;
|
||||
|
||||
String json = ElementMapper.marshal(header);
|
||||
logger.debug(json);
|
||||
|
||||
|
||||
Property property = ElementMapper.unmarshal(Property.class, json);
|
||||
Assert.assertTrue(property instanceof Header);
|
||||
Assert.assertTrue(((Header) property).getCreationTime().compareTo(date)==0);
|
||||
Assert.assertTrue(((Header) property).getLastUpdateTime().compareTo(date)==0);
|
||||
logger.debug(ElementMapper.marshal(property));
|
||||
|
||||
Header h = ElementMapper.unmarshal(Header.class, json);
|
||||
Assert.assertTrue(property instanceof Header);
|
||||
Assert.assertTrue(h.getCreationTime().compareTo(date)==0);
|
||||
Assert.assertTrue(h.getLastUpdateTime().compareTo(date)==0);
|
||||
logger.debug(ElementMapper.marshal(h));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testContextsInHeader() throws JsonParseException, JsonMappingException, IOException {
|
||||
|
||||
String headerJson = "{\"@class\":\"Header\",\"uuid\":\"cee84aaf-030c-4170-b554-836e7df3f611\",\"creator\":\"UNKNOWN_USER\",\"modifiedBy\":null,\"creationTime\":\"2020-11-09 10:01:25.415 +0000\",\"lastUpdateTime\":\"2020-11-09 10:01:25.415 +0000\",\"contexts\":[\"167114e0-9027-4e9e-83af-57973a8f8f08\",\"bad5f350-345c-11e9-9f49-cef9b1608c3f\"]}";
|
||||
|
||||
Property property = ElementMapper.unmarshal(Property.class, headerJson);
|
||||
logger.debug("{}", property);
|
||||
|
||||
Header h = ElementMapper.unmarshal(Header.class, headerJson);
|
||||
logger.debug("{}", h);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> contexts = (List<String>) h.getAdditionalProperty(Header.__CONTEXTS);
|
||||
logger.debug("Contexts UUIDs are {}", contexts);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package org.gcube.informationsystem.model.impl.properties;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class MetadataTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(MetadataTest.class);
|
||||
|
||||
@Test
|
||||
public void metadataTest() throws Exception {
|
||||
MetadataImpl metadata = new MetadataImpl();
|
||||
Date date = Calendar.getInstance().getTime();
|
||||
metadata.creationTime = date;
|
||||
metadata.lastUpdateTime = date;
|
||||
metadata.createdBy = Metadata.UNKNOWN_USER;
|
||||
metadata.lastUpdateBy = Metadata.UNKNOWN_USER;
|
||||
|
||||
String json = ElementMapper.marshal(metadata);
|
||||
logger.debug(json);
|
||||
|
||||
|
||||
Property property = ElementMapper.unmarshal(Property.class, json);
|
||||
Assert.assertTrue(property instanceof Metadata);
|
||||
Assert.assertTrue(((Metadata) property).getCreationTime().compareTo(date)==0);
|
||||
Assert.assertTrue(((Metadata) property).getLastUpdateTime().compareTo(date)==0);
|
||||
logger.debug(ElementMapper.marshal(property));
|
||||
|
||||
Metadata h = ElementMapper.unmarshal(Metadata.class, json);
|
||||
Assert.assertTrue(property instanceof Metadata);
|
||||
Assert.assertTrue(h.getCreationTime().compareTo(date)==0);
|
||||
Assert.assertTrue(h.getLastUpdateTime().compareTo(date)==0);
|
||||
logger.debug(ElementMapper.marshal(h));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
package org.gcube.informationsystem.model.impl.properties;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.model.reference.ERElement;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
||||
|
@ -77,8 +78,8 @@ public class PropagationConstraintTest {
|
|||
RemoveConstraint removeConstraint = RemoveConstraint.cascade;
|
||||
DeleteConstraint deleteConstraint = DeleteConstraint.keep;
|
||||
String marshalled = "{\"" +
|
||||
Element.CLASS_PROPERTY + "\":\"MyPropagationConstraint\",\"" +
|
||||
Element.SUPERCLASSES_PROPERTY + "\":[\"" + PropagationConstraint.NAME + "\", \"" + Property.NAME + "\"],\"" +
|
||||
Element.TYPE_PROPERTY + "\":\"MyPropagationConstraint\",\"" +
|
||||
ERElement.SUPERTYPES_PROPERTY + "\":[\"" + PropagationConstraint.NAME + "\", \"" + Property.NAME + "\"],\"" +
|
||||
PropagationConstraint.ADD_PROPERTY + "\":\""+ addConstraint + "\",\""+
|
||||
PropagationConstraint.REMOVE_PROPERTY + "\":\"" + removeConstraint + "\",\""+
|
||||
PropagationConstraint.DELETE_PROPERTY + "\":\"" + deleteConstraint +
|
||||
|
@ -108,56 +109,46 @@ public class PropagationConstraintTest {
|
|||
DeleteConstraint deleteConstraint = DeleteConstraint.keep;
|
||||
|
||||
String pcString = "{" +
|
||||
"\"" + Element.CLASS_PROPERTY + "\":\"My" + PropagationConstraint.NAME + "\"," +
|
||||
"\"" + Element.SUPERCLASSES_PROPERTY + "\":[\"" + PropagationConstraint.NAME + "\", \"" + Property.NAME + "\"],\"" +
|
||||
"\"" + Element.TYPE_PROPERTY + "\":\"My" + PropagationConstraint.NAME + "\"," +
|
||||
"\"" + ERElement.SUPERTYPES_PROPERTY + "\":[\"" + PropagationConstraint.NAME + "\", \"" + Property.NAME + "\"],\"" +
|
||||
PropagationConstraint.ADD_PROPERTY + "\":\""+ addConstraint + "\",\"" +
|
||||
PropagationConstraint.REMOVE_PROPERTY + "\":\"" + removeConstraint + "\",\"" +
|
||||
PropagationConstraint.DELETE_PROPERTY + "\":\"" + deleteConstraint + "\"" +
|
||||
"}";
|
||||
logger.debug(pcString);
|
||||
|
||||
HeaderImpl header = new HeaderImpl();
|
||||
header.setUUID(UUID.randomUUID());
|
||||
header.createdBy = "luca.frosini";
|
||||
header.lastUpdateBy = "luca.frosini";
|
||||
header.creationTime = Calendar.getInstance().getTime();
|
||||
header.lastUpdateTime = Calendar.getInstance().getTime();
|
||||
MetadataImpl metadata = new MetadataImpl();
|
||||
metadata.createdBy = "luca.frosini";
|
||||
metadata.lastUpdateBy = "luca.frosini";
|
||||
metadata.creationTime = Calendar.getInstance().getTime();
|
||||
metadata.lastUpdateTime = Calendar.getInstance().getTime();
|
||||
|
||||
String hString = ElementMapper.marshal(header);
|
||||
String hString = ElementMapper.marshal(metadata);
|
||||
|
||||
|
||||
String consistsOfString = "{" +
|
||||
"\"" + Element.CLASS_PROPERTY + "\":\"" + ConsistsOf.NAME + "\"," +
|
||||
"\"" + Element.TYPE_PROPERTY + "\":\"" + ConsistsOf.NAME + "\"," +
|
||||
"\"" + ConsistsOf.PROPAGATION_CONSTRAINT_PROPERTY + "\":"+ pcString + "," +
|
||||
"\"" + ConsistsOf.HEADER_PROPERTY + "\": " + hString + "," +
|
||||
"\"" + ConsistsOf.METADATA_PROPERTY + "\": " + hString + "," +
|
||||
"\"" + ConsistsOf.SOURCE_PROPERTY + "\":{" +
|
||||
"\"@class\":\"MyEService\"," +
|
||||
"\"@superClasses\":[\"EService\", \"Service\", \"Resource\"]," +
|
||||
"\"header\":"+ "{" +
|
||||
"\"@class\":\"Header\"," +
|
||||
"\"uuid\":\"4a971915-ca90-48cf-9975-63ee2dd28605\"," +
|
||||
"\"creator\":null, " +
|
||||
"\"creationTime\":null, " +
|
||||
"\"lastUpdateTime\":null}" +
|
||||
"\"" + IdentifiableElement.ID_PROPERTY + "\":\"4a971915-ca90-48cf-9975-63ee2dd28605\"," +
|
||||
"\"" + Element.TYPE_PROPERTY + "\":\"MyEService\"," +
|
||||
"\"" + ERElement.SUPERTYPES_PROPERTY + "\":[\"EService\", \"Service\", \"Resource\"]," +
|
||||
"\"" + ConsistsOf.METADATA_PROPERTY + "\": " + hString +
|
||||
"}," +
|
||||
"\"" + ConsistsOf.TARGET_PROPERTY + "\":{" +
|
||||
"\"@class\":\"MySoftwareFacet\"," +
|
||||
"\"@superClasses\":[\"SoftwareFacet\", \"Facet\"]," +
|
||||
"\"header\":"+ "{" +
|
||||
"\"@class\":\"Header\"," +
|
||||
"\"uuid\":\"3ace4bd0-e5cd-49a3-97a8-a0a9468ce6d4\"," +
|
||||
"\"creator\":null, " +
|
||||
"\"creationTime\":null, " +
|
||||
"\"lastUpdateTime\":null" +
|
||||
"}" +
|
||||
",\"name\":\"WhnManager\"," +
|
||||
"\"" + IdentifiableElement.ID_PROPERTY + "\":\"3ace4bd0-e5cd-49a3-97a8-a0a9468ce6d4\"," +
|
||||
"\"" + Element.TYPE_PROPERTY + "\":\"MySoftwareFacet\"," +
|
||||
"\"" + ERElement.SUPERTYPES_PROPERTY + "\":[\"SoftwareFacet\", \"Facet\"]," +
|
||||
"\"" + ConsistsOf.METADATA_PROPERTY + "\": " + hString + "," +
|
||||
"\"name\":\"WhnManager\"," +
|
||||
"\"group\":\"VREManagement\"," +
|
||||
"\"version\":\"2.0.0-SNAPSHOT\"," +
|
||||
"\"description\":\"Web Hosting Node Service\"," +
|
||||
"\"qualifier\":null,\"optional\":false" +
|
||||
"}" +
|
||||
"}";
|
||||
logger.debug(consistsOfString);
|
||||
logger.debug("--- {}", consistsOfString);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ConsistsOf<Resource,Facet> consistsOf = ElementMapper.unmarshal(ConsistsOf.class, consistsOfString);
|
||||
|
|
|
@ -6,7 +6,7 @@ package org.gcube.informationsystem.types;
|
|||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -21,7 +21,7 @@ public class EntitySchemaDefinition {
|
|||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
Class<? extends PropertyElement> clz = Header.class;
|
||||
Class<? extends PropertyElement> clz = Metadata.class;
|
||||
String json = TypeMapper.serializeType(clz);
|
||||
logger.trace(json);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package org.gcube.informationsystem.types;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
|
@ -8,10 +11,10 @@ import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
|||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.Encrypted;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||
import org.gcube.informationsystem.model.reference.properties.Vault;
|
||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
||||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||
|
@ -20,6 +23,7 @@ import org.gcube.informationsystem.queries.templates.reference.properties.Templa
|
|||
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||
import org.gcube.informationsystem.types.annotations.Final;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||
import org.gcube.informationsystem.types.reference.entities.EntityType;
|
||||
import org.gcube.informationsystem.types.reference.entities.FacetType;
|
||||
|
@ -60,6 +64,13 @@ public class SerializationTest {
|
|||
EntityType resourceTypeDefinitionSelf = (EntityType) TypeMapper.createTypeDefinition(ResourceType.class);
|
||||
logger.info(ElementMapper.marshal(resourceTypeDefinitionSelf));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entityElementDefinition() throws Exception{
|
||||
Type type = TypeMapper.createTypeDefinition(EntityElement.class);
|
||||
logger.info(ElementMapper.marshal(type));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPropertyTypeDefinition() throws Exception{
|
||||
|
@ -89,9 +100,9 @@ public class SerializationTest {
|
|||
logger.info(ElementMapper.marshal(property));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
PropertyType<Header> header = (PropertyType<Header>) TypeMapper.createTypeDefinition(Header.class);
|
||||
Assert.assertTrue(header.getAccessType()==AccessType.PROPERTY);
|
||||
logger.info(ElementMapper.marshal(header));
|
||||
PropertyType<Metadata> metadataType = (PropertyType<Metadata>) TypeMapper.createTypeDefinition(Metadata.class);
|
||||
Assert.assertTrue(metadataType.getAccessType()==AccessType.PROPERTY);
|
||||
logger.info(ElementMapper.marshal(metadataType));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
PropertyType<PropagationConstraint> propagationConstraint = (PropertyType<PropagationConstraint>) TypeMapper.createTypeDefinition(PropagationConstraint.class);
|
||||
|
@ -99,7 +110,7 @@ public class SerializationTest {
|
|||
logger.info(ElementMapper.marshal(propagationConstraint));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
PropertyType<Vault> vault = (PropertyType<Vault>) TypeMapper.createTypeDefinition(Vault.class);
|
||||
PropertyType<Encrypted> vault = (PropertyType<Encrypted>) TypeMapper.createTypeDefinition(Encrypted.class);
|
||||
Assert.assertTrue(vault.getAccessType()==AccessType.PROPERTY);
|
||||
logger.info(ElementMapper.marshal(vault));
|
||||
|
||||
|
@ -198,19 +209,19 @@ public class SerializationTest {
|
|||
|
||||
@Test
|
||||
public void testTypeSerialization() throws Exception {
|
||||
String serialized = TypeMapper.serializeType(Header.class);
|
||||
String serialized = TypeMapper.serializeType(Metadata.class);
|
||||
logger.info(serialized);
|
||||
@SuppressWarnings("unchecked")
|
||||
PropertyType<Header> propertyType = (PropertyType<Header>) TypeMapper.deserializeTypeDefinition(serialized);
|
||||
PropertyType<Metadata> propertyType = (PropertyType<Metadata>) TypeMapper.deserializeTypeDefinition(serialized);
|
||||
Version typeVersion = propertyType.getVersion();
|
||||
logger.debug("Version {}", typeVersion.toString());
|
||||
logger.info(ElementMapper.marshal(propertyType));
|
||||
|
||||
String json = "{\"@class\":\"PropertyType\",\"header\":null,\"name\":\"Header\",\"description\":\"This class provides metadata per every IdentifiableElement\",\"superClasses\":[\"Property\"],\"properties\":[{\"@class\":\"PropertyDefinition\",\"name\":\"creationTime\",\"description\":\"Creation time. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"Date\"},{\"@class\":\"PropertyDefinition\",\"name\":\"lastUpdateTime\",\"description\":\"Last Update time. At creation time it assumes the same value of creationTime. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"Date\"},{\"@class\":\"PropertyDefinition\",\"name\":\"createdBy\",\"description\":\"The user that created the Entity or the Relation. It is initialized at creation time. \",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"String\"},{\"@class\":\"PropertyDefinition\",\"name\":\"uuid\",\"description\":\"This UUID is be used to identify the Entity or the Relation univocally.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":\"^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}$\",\"type\":\"String\"},{\"@class\":\"PropertyDefinition\",\"name\":\"lastUpdateBy\",\"description\":\"The user that made the last update to the Entity or the Relation. At creation time, it assumes the same value of creator.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"String\"}],\"accessType\":\"PROPERTY\",\"abstract\":false,\"version\":\"1.0.0\",\"changelog\":{\"1.0.0\":\"First Version\"}}";
|
||||
String json = "{\"" + Element.TYPE_PROPERTY + "\":\"PropertyType\",\"metadata\":null,\"name\":\"Metadata\",\"description\":\"This class provides metadata per every IdentifiableElement\",\"typeSuperTypes\":[\"Property\"],\"properties\":[{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"creationTime\",\"description\":\"Creation time. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"Date\"},{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"lastUpdateTime\",\"description\":\"Last Update time. At creation time it assumes the same value of creationTime. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"Date\"},{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"createdBy\",\"description\":\"The user that created the Entity or the Relation. It is initialized at creation time. \",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"String\"},{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"" + IdentifiableElement.ID_PROPERTY + "\",\"description\":\"This ID is be used to identify the Entity or the Relation univocally.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":\"^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}$\",\"propertyType\":\"String\"},{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"lastUpdateBy\",\"description\":\"The user that made the last update to the Entity or the Relation. At creation time, it assumes the same value of creator.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"String\"}],\"accessType\":\"PROPERTY\",\"abstract\":false,\"version\":\"1.0.0\",\"changelog\":{\"1.0.0\":\"First Version\"}}";
|
||||
logger.info(json);
|
||||
@SuppressWarnings("unchecked")
|
||||
PropertyType<Header> headerType = (PropertyType<Header>) TypeMapper.deserializeTypeDefinition(json);
|
||||
logger.info(ElementMapper.marshal(headerType));
|
||||
PropertyType<Metadata> metadataType = (PropertyType<Metadata>) TypeMapper.deserializeTypeDefinition(json);
|
||||
logger.info(ElementMapper.marshal(metadataType));
|
||||
|
||||
}
|
||||
|
||||
|
@ -243,4 +254,20 @@ public class SerializationTest {
|
|||
public void testVersionNotHighest() throws Exception{
|
||||
TypeMapper.serializeType(TestVersionNotHighest.class);
|
||||
}
|
||||
|
||||
public static final String PG_OK = "{\"type\":\"PropagationConstraint\",\"add\":\"propagate\",\"delete\":\"cascade\",\"remove\":\"cascadeWhenOrphan\"}";
|
||||
public static final String PG_NO = "{\"type\":\"PropagationConstraint\",\"add\":\"propagate\",\"delete\":\"propagate\",\"remove\":\"cascadeWhenOrphan\"}";
|
||||
public static final String PG_EXT = "{\"type\":\"MyPropagationConstraint\",\"supertypes\":[\"PropagationConstraint\",\"Property\"], \"add\":\"propagate\",\"delete\":\"cascade\",\"remove\":\"cascadeWhenOrphan\"}";
|
||||
|
||||
@Test
|
||||
public void testPropagationConstraintMarshalling() throws Exception {
|
||||
ElementMapper.unmarshal(PropagationConstraint.class, PG_OK);
|
||||
ElementMapper.unmarshal(PropagationConstraint.class, PG_EXT);
|
||||
}
|
||||
|
||||
@Test(expected = JsonMappingException.class)
|
||||
public void testWrongPropagationConstraintMarshalling() throws Exception {
|
||||
ElementMapper.unmarshal(PropagationConstraint.class, PG_NO);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.gcube.informationsystem.types;
|
||||
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.model.reference.properties.Vault;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.model.reference.properties.Encrypted;
|
||||
import org.gcube.informationsystem.types.PropertyTypeName.BaseType;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -17,7 +17,7 @@ public class TypeNameTest {
|
|||
|
||||
@Test
|
||||
public void getBaseType() throws Exception {
|
||||
Class<?> clz = Header.class;
|
||||
Class<?> clz = Metadata.class;
|
||||
BaseType baseType = PropertyTypeName.getBaseTypeByClass(clz);
|
||||
logger.debug("{} for class {} is {}", BaseType.class.getSimpleName(), clz, baseType);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class TypeNameTest {
|
|||
if(baseType.ordinal()>=BaseType.PROPERTY.ordinal()) {
|
||||
if(baseType == BaseType.PROPERTY) {
|
||||
stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(Vault.NAME);
|
||||
stringBuffer.append(Encrypted.NAME);
|
||||
checkPropertyTypeName(stringBuffer.toString(), baseType);
|
||||
} else {
|
||||
for(BaseType b : BaseType.values()) {
|
||||
|
@ -79,7 +79,7 @@ public class TypeNameTest {
|
|||
}
|
||||
|
||||
if(b == BaseType.PROPERTY) {
|
||||
sb.append(Vault.NAME);
|
||||
sb.append(Encrypted.NAME);
|
||||
} else {
|
||||
sb.append(b.toString());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
package org.gcube.informationsystem.types.knowledge;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.model.knowledge.ModelKnowledge;
|
||||
import org.gcube.informationsystem.model.knowledge.UsageKnowledge;
|
||||
import org.gcube.informationsystem.tree.Node;
|
||||
import org.gcube.informationsystem.tree.NodeElaborator;
|
||||
import org.gcube.informationsystem.tree.Tree;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.types.reference.properties.LinkedEntity;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class ModelKnowledgeTest{
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ModelKnowledgeTest.class);
|
||||
|
||||
protected File getTypesDirectory() throws Exception {
|
||||
URL logbackFileURL = ModelKnowledgeTest.class.getClassLoader().getResource("logback-test.xml");
|
||||
File logbackFile = new File(logbackFileURL.toURI());
|
||||
File resourcesDirectory = logbackFile.getParentFile();
|
||||
return new File(resourcesDirectory, "types");
|
||||
}
|
||||
|
||||
protected String readFile(File file) throws IOException {
|
||||
byte[] encoded = Files.readAllBytes(file.toPath());
|
||||
return new String(encoded, Charset.defaultCharset());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
ModelKnowledge<Type, TypeInformation> modelKnowledge = TypesKnowledge.getInstance().getModelKnowledge();
|
||||
|
||||
File typesDirectory = getTypesDirectory();
|
||||
|
||||
AccessType[] modelTypes = AccessType.getModelTypes();
|
||||
for(AccessType modelType : modelTypes) {
|
||||
File file = new File(typesDirectory, modelType.getName() + ".json");
|
||||
String json = readFile(file);
|
||||
List<Type> types = TypeMapper.deserializeTypeDefinitions(json);
|
||||
modelKnowledge.addAllType(types);
|
||||
logger.trace("-------------------------------------------------------");
|
||||
}
|
||||
|
||||
for(AccessType modelType : modelTypes) {
|
||||
Tree<Type> tree = modelKnowledge.getTree(modelType);
|
||||
|
||||
tree.elaborate(new NodeElaborator<Type>() {
|
||||
|
||||
@Override
|
||||
public void elaborate(Node<Type> node, int level) throws Exception {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (int i = 0; i < level; ++i) {
|
||||
stringBuffer.append(Node.INDENTATION);
|
||||
}
|
||||
|
||||
String typeName = node.getNodeElement().getName();
|
||||
logger.info("{}- {}{}", stringBuffer.toString(), typeName, level==0 ? " (ROOT)" : "");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
logger.info("---------------------------------------------------\n\n\n");
|
||||
|
||||
for(AccessType modelType : modelTypes) {
|
||||
Tree<Type> tree = modelKnowledge.getTree(modelType);
|
||||
UsageKnowledge<?> usageKnowledge = modelKnowledge.getModelTypesUsage(modelType);
|
||||
|
||||
tree.elaborate(new NodeElaborator<Type>() {
|
||||
|
||||
@Override
|
||||
public void elaborate(Node<Type> node, int level) throws Exception {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (int i = 0; i < level; ++i) {
|
||||
stringBuffer.append(Node.INDENTATION);
|
||||
}
|
||||
|
||||
Type type = node.getNodeElement();
|
||||
String typeName = type.getName();
|
||||
|
||||
|
||||
if(type.getAccessType()!=AccessType.PROPERTY) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<LinkedEntity> usage = (List<LinkedEntity>) usageKnowledge.getUsage(typeName);
|
||||
logger.info("{}- {}{} {}", stringBuffer.toString(), typeName, level==0 ? " (ROOT) " : "", usage!=null ? "known static usage " + usage : "No known static usage");
|
||||
}else {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map.Entry<String,PropertyDefinition>> usage = (List<Entry<String, PropertyDefinition>>) usageKnowledge.getUsage(typeName);
|
||||
logger.info("{}- {}{} {}", stringBuffer.toString(), typeName, level==0 ? " (ROOT) " : "", usage!=null ? "known static usage " + usage : "No known static usage");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -14,22 +14,51 @@ public class UUIDManagerTest {
|
|||
|
||||
@Test
|
||||
public void testReservedUUID() {
|
||||
Set<UUID> allUUID = UUIDManager.getAllReservedUUID();
|
||||
UUIDManager uuidManager = UUIDManager.getInstance();
|
||||
|
||||
Set<UUID> allUUID = uuidManager.getAllReservedUUID();
|
||||
logger.debug("Reserved UUIDs are {}", allUUID);
|
||||
|
||||
Set<String> allUUIDAsString = UUIDManager.getAllReservedUUIDAsStrings();
|
||||
Set<String> allUUIDAsString = uuidManager.getAllReservedUUIDAsStrings();
|
||||
Assert.assertTrue(allUUID.size()==allUUIDAsString.size());
|
||||
Assert.assertTrue(allUUID.size()==16);
|
||||
Assert.assertTrue(allUUIDAsString.size()==16);
|
||||
for(UUID uuid : allUUID) {
|
||||
Assert.assertTrue(UUIDManager.isReservedUUID(uuid));
|
||||
Assert.assertTrue(UUIDManager.isReservedUUID(uuid.toString()));
|
||||
Assert.assertTrue(uuidManager.isReservedUUID(uuid));
|
||||
Assert.assertTrue(uuidManager.isReservedUUID(uuid.toString()));
|
||||
}
|
||||
|
||||
for(String uuidString : allUUIDAsString) {
|
||||
Assert.assertTrue(UUIDManager.isReservedUUID(UUID.fromString(uuidString)));
|
||||
Assert.assertTrue(UUIDManager.isReservedUUID(uuidString));
|
||||
Assert.assertTrue(uuidManager.isReservedUUID(UUID.fromString(uuidString)));
|
||||
Assert.assertTrue(uuidManager.isReservedUUID(uuidString));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGenerateUUID() {
|
||||
UUIDManager uuidManager = UUIDManager.getInstance();
|
||||
|
||||
Set<UUID> allReservedUUID = uuidManager.getAllReservedUUID();
|
||||
|
||||
UUID uuid = uuidManager.generateValidUUID();
|
||||
|
||||
Assert.assertTrue(!allReservedUUID.contains(uuid));
|
||||
|
||||
uuid = UUID.randomUUID();
|
||||
|
||||
uuid = uuidManager.generateValidUUID(uuid);
|
||||
|
||||
Assert.assertTrue(!allReservedUUID.contains(uuid));
|
||||
|
||||
for(UUID reservedUUID : allReservedUUID) {
|
||||
uuid = uuidManager.generateValidUUID(reservedUUID);
|
||||
Assert.assertTrue(reservedUUID.compareTo(uuid)!=0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
<logger name="org.gcube" level="WARN" />
|
||||
<logger name="org.gcube.informationsystem" level="INFO" />
|
||||
<logger name="org.gcube.informationsystem" level="TRACE" />
|
||||
<logger name="org.gcube.informationsystem.resourceregistry.dbinitialization" level="WARN" />
|
||||
|
||||
<root level="WARN">
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
{
|
||||
"@class": "EService",
|
||||
"type": "EService",
|
||||
"consistsOf": [
|
||||
{
|
||||
"@class": "ConsistsOf",
|
||||
"type": "ConsistsOf",
|
||||
"propagationConstraint" : {
|
||||
"add": "propagate"
|
||||
},
|
||||
"target": {
|
||||
"@class": "StateFacet",
|
||||
"type": "StateFacet",
|
||||
"value": "$state"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@class": "IsIdentifiedBy",
|
||||
"type": "IsIdentifiedBy",
|
||||
"target": {
|
||||
"@class": "SoftwareFacet",
|
||||
"type": "SoftwareFacet",
|
||||
"name": "$name",
|
||||
"group": "$group"
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue