dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30434
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15445: exposed metadata property on Schema, will be used to find classes that are used for metadata impo...
------------------------------------------------------------
revno: 15445
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-05-28 11:57:38 +0200
message:
exposed metadata property on Schema, will be used to find classes that are used for metadata import/export. Updated SchemaDescripors with metadata info.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DashboardSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementOperandSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/InterpretationSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/MessageConversationSchemaDescriptor.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java 2014-04-13 03:59:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java 2014-05-28 09:57:38 +0000
@@ -41,26 +41,67 @@
@JacksonXmlRootElement( localName = "property", namespace = DxfNamespaces.DXF_2_0 )
public class Property
{
+ /**
+ * Name of property.
+ */
private String name;
+ /**
+ * Description if provided, will be fetched from @Description annotation.
+ *
+ * @see org.hisp.dhis.common.annotation.Description
+ */
private String description;
+ /**
+ * Usually equals to name, but for lists the name and xmlName might differ.
+ */
private String xmlName;
+ /**
+ * XML-Namespace used for this property.
+ */
private String xmlNamespace;
+ /**
+ * Is this property exposed as a attribute in XML.
+ */
private boolean xmlAttribute;
+ /**
+ * Name of collection wrapper.
+ */
private String xmlCollectionName;
+ /**
+ * Class for property.
+ */
private Class<?> klass;
+ /**
+ * Direct link to getter for this property.
+ */
private Method getterMethod;
+ /**
+ * Is this a Collection sub-class.
+ *
+ * @see java.util.Collection
+ */
private boolean collection;
+ /**
+ * Is this class a sub-class of IdentifiableObject
+ *
+ * @see org.hisp.dhis.common.IdentifiableObject
+ */
private boolean identifiableObject;
+ /**
+ * Is this class a sub-class of NameableObject
+ *
+ * @see org.hisp.dhis.common.NameableObject
+ */
private boolean nameableObject;
public Property( Method getterMethod )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java 2014-05-27 12:49:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java 2014-05-28 09:57:38 +0000
@@ -47,22 +47,58 @@
@JacksonXmlRootElement( localName = "schema", namespace = DxfNamespaces.DXF_2_0 )
public class Schema
{
+ /**
+ * Class that is described in this schema.
+ */
private Class<?> klass;
+ /**
+ * Is this class a sub-class of IdentifiableObject
+ *
+ * @see org.hisp.dhis.common.IdentifiableObject
+ */
private boolean identifiableObject;
+ /**
+ * Is this class a sub-class of NameableObject
+ *
+ * @see org.hisp.dhis.common.NameableObject
+ */
private boolean nameableObject;
+ /**
+ * Singular name.
+ */
private String singular;
+ /**
+ * Plural name.
+ */
private String plural;
+ /**
+ * Is sharing supported for instances of this class.
+ */
private boolean shareable;
+ /**
+ * Points to Web-API endpoint (if exposed).
+ */
private String apiEndpoint;
+ /**
+ * Is this class considered metadata, this is mainly used for our metadata importer/exporter.
+ */
+ private boolean metadata;
+
+ /**
+ * List of authorities required for doing operations on this class.
+ */
private List<Authority> authorities = Lists.newArrayList();
+ /**
+ * List of all exposed properties on this class.
+ */
private List<Property> properties = Lists.newArrayList();
public Schema( Class<?> klass, String singular, String plural )
@@ -72,6 +108,7 @@
this.nameableObject = NameableObject.class.isAssignableFrom( klass );
this.singular = singular;
this.plural = plural;
+ this.metadata = true;
}
@JsonProperty
@@ -154,6 +191,18 @@
}
@JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public boolean isMetadata()
+ {
+ return metadata;
+ }
+
+ public void setMetadata( boolean metadata )
+ {
+ this.metadata = metadata;
+ }
+
+ @JsonProperty
@JacksonXmlElementWrapper( localName = "authorities", namespace = DxfNamespaces.DXF_2_0 )
@JacksonXmlProperty( localName = "authority", namespace = DxfNamespaces.DXF_2_0 )
public List<Authority> getAuthorities()
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DashboardSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DashboardSchemaDescriptor.java 2014-05-27 12:49:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DashboardSchemaDescriptor.java 2014-05-28 09:57:38 +0000
@@ -53,6 +53,7 @@
{
Schema schema = new Schema( Dashboard.class, "dashboard", "dashboards" );
schema.setApiEndpoint( API_ENDPOINT );
+ schema.setMetadata( false );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_DASHBOARD_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementOperandSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementOperandSchemaDescriptor.java 2014-03-26 09:23:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementOperandSchemaDescriptor.java 2014-05-28 09:57:38 +0000
@@ -39,9 +39,19 @@
@Component
public class DataElementOperandSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "dataElementOperand";
+
+ public static final String PLURAL = "dataElementOperands";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- return new Schema( DataElementOperand.class, "dataElementOperand", "dataElementOperands" );
+ Schema schema = new Schema( DataElementOperand.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
+ schema.setMetadata( false );
+
+ return schema;
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/InterpretationSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/InterpretationSchemaDescriptor.java 2014-05-27 13:18:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/InterpretationSchemaDescriptor.java 2014-05-28 09:57:38 +0000
@@ -50,6 +50,7 @@
{
Schema schema = new Schema( Interpretation.class, SINGULAR, PLURAL );
schema.setApiEndpoint( API_ENDPOINT );
+ schema.setMetadata( false );
schema.setShareable( true );
return schema;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/MessageConversationSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/MessageConversationSchemaDescriptor.java 2014-05-27 13:18:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/MessageConversationSchemaDescriptor.java 2014-05-28 09:57:38 +0000
@@ -50,6 +50,7 @@
{
Schema schema = new Schema( MessageConversation.class, SINGULAR, PLURAL );
schema.setApiEndpoint( API_ENDPOINT );
+ schema.setMetadata( false );
return schema;
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java 2014-05-28 09:57:38 +0000
@@ -29,14 +29,15 @@
*/
import com.google.common.collect.Lists;
-import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.webapi.controller.WebMetaData;
-import org.hisp.dhis.webapi.controller.WebOptions;
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.PagerUtils;
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.dataelement.DataElementOperandService;
+import org.hisp.dhis.schema.descriptors.DataElementOperandSchemaDescriptor;
+import org.hisp.dhis.webapi.controller.AbstractCrudController;
+import org.hisp.dhis.webapi.controller.WebMetaData;
+import org.hisp.dhis.webapi.controller.WebOptions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@@ -55,11 +56,9 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping(value = DataElementOperandController.RESOURCE_PATH)
+@RequestMapping( value = DataElementOperandSchemaDescriptor.API_ENDPOINT )
public class DataElementOperandController extends AbstractCrudController<DataElementOperand>
{
- public static final String RESOURCE_PATH = "/dataElementOperands";
-
private DataElementOperandService dataElementOperandService;
@Autowired