dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30401
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15433: expose endpoint in schemaDescriptors, wip
------------------------------------------------------------
revno: 15433
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-05-27 14:49:13 +0200
message:
expose endpoint in schemaDescriptors, wip
modified:
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/AttributeSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryComboSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionComboSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionGroupSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionGroupSetSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategorySchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ChartSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ConceptSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ConstantSchemaDescriptor.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/DataApprovalLevelSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataDictionarySchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementGroupSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementGroupSetSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataSetSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DocumentSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/EventReportSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/IndicatorGroupSchemaDescriptor.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/IndicatorGroupSetSchemaDescriptor.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AttributeController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConceptController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConstantController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalLevelController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataDictionaryController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DocumentController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryComboController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionComboController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionGroupController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionGroupSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/indicator/IndicatorGroupController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/indicator/IndicatorGroupSetController.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/Schema.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java 2014-03-27 01:36:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Schema.java 2014-05-27 12:49:13 +0000
@@ -59,6 +59,8 @@
private boolean shareable;
+ private String apiEndpoint;
+
private List<Authority> authorities = Lists.newArrayList();
private List<Property> properties = Lists.newArrayList();
@@ -135,6 +137,23 @@
}
@JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public String getApiEndpoint()
+ {
+ return apiEndpoint;
+ }
+
+ public void setApiEndpoint( String apiEndpoint )
+ {
+ this.apiEndpoint = apiEndpoint;
+ }
+
+ public boolean haveEndpoint()
+ {
+ return getApiEndpoint() != null;
+ }
+
+ @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/AttributeSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/AttributeSchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/AttributeSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,10 +42,17 @@
@Component
public class AttributeSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "attribute";
+
+ public static final String PLURAL = "attributes";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( Attribute.class, "attribute", "attributes" );
+ Schema schema = new Schema( Attribute.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE, Lists.newArrayList( "F_ATTRIBUTE_ADD" ) ) );
schema.getAuthorities().add( new Authority( AuthorityType.DELETE, Lists.newArrayList( "F_ATTRIBUTE_DELETE" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryComboSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryComboSchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryComboSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class CategoryComboSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "categoryCombo";
+
+ public static final String PLURAL = "categoryCombos";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( DataElementCategoryCombo.class, "categoryCombo", "categoryCombos" );
-
+ Schema schema = new Schema( DataElementCategoryCombo.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_CATEGORY_COMBO_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionComboSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionComboSchemaDescriptor.java 2014-05-26 10:58:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionComboSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class CategoryOptionComboSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "categoryOptionCombo";
+
+ public static final String PLURAL = "categoryOptionCombos";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( DataElementCategoryOptionCombo.class, "categoryOptionCombo", "categoryOptionCombos" );
-
+ Schema schema = new Schema( DataElementCategoryOptionCombo.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( false );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE,
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionGroupSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionGroupSchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionGroupSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class CategoryOptionGroupSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "categoryOptionGroup";
+
+ public static final String PLURAL = "categoryOptionGroups";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( CategoryOptionGroup.class, "categoryOptionGroup", "categoryOptionGroups" );
-
+ Schema schema = new Schema( CategoryOptionGroup.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_CATEGORY_OPTION_GROUP_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionGroupSetSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionGroupSetSchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionGroupSetSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class CategoryOptionGroupSetSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "categoryOptionGroupSet";
+
+ public static final String PLURAL = "categoryOptionGroupSets";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( CategoryOptionGroupSet.class, "categoryOptionGroupSet", "categoryOptionGroupSets" );
-
+ Schema schema = new Schema( CategoryOptionGroupSet.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_CATEGORY_OPTION_GROUP_SET_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionSchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategoryOptionSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class CategoryOptionSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "categoryOption";
+
+ public static final String PLURAL = "categoryOptions";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( DataElementCategoryOption.class, "categoryOption", "categoryOptions" );
-
+ Schema schema = new Schema( DataElementCategoryOption.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_CATEGORY_OPTION_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategorySchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategorySchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/CategorySchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class CategorySchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "category";
+
+ public static final String PLURAL = "categories";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( DataElementCategory.class, "category", "categories" );
-
+ Schema schema = new Schema( DataElementCategory.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_CATEGORY_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ChartSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ChartSchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ChartSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class ChartSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "chart";
+
+ public static final String PLURAL = "charts";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( Chart.class, "chart", "charts" );
-
+ Schema schema = new Schema( Chart.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_CHART_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ConceptSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ConceptSchemaDescriptor.java 2014-03-26 09:23:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ConceptSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -39,9 +39,18 @@
@Component
public class ConceptSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "concept";
+
+ public static final String PLURAL = "concepts";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- return new Schema( Concept.class, "concept", "concepts" );
+ Schema schema = new Schema( Concept.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
+
+ return schema;
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ConstantSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ConstantSchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/ConstantSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,10 +42,17 @@
@Component
public class ConstantSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "constant";
+
+ public static final String PLURAL = "constants";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( Constant.class, "constant", "constants" );
+ Schema schema = new Schema( Constant.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE, Lists.newArrayList( "F_CONSTANT_ADD" ) ) );
schema.getAuthorities().add( new Authority( AuthorityType.DELETE, Lists.newArrayList( "F_CONSTANT_DELETE" ) ) );
=== 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-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DashboardSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,12 +42,19 @@
@Component
public class DashboardSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "dashboard";
+
+ public static final String PLURAL = "dashboards";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
Schema schema = new Schema( Dashboard.class, "dashboard", "dashboards" );
-
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
+
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_DASHBOARD_PUBLIC_ADD" ) ) );
return schema;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataApprovalLevelSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataApprovalLevelSchemaDescriptor.java 2014-04-04 12:42:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataApprovalLevelSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.google.common.collect.Lists;
import org.hisp.dhis.dataapproval.DataApprovalLevel;
import org.hisp.dhis.schema.Authority;
import org.hisp.dhis.schema.AuthorityType;
@@ -35,22 +36,26 @@
import org.hisp.dhis.schema.SchemaDescriptor;
import org.springframework.stereotype.Component;
-import com.google.common.collect.Lists;
-
@Component
public class DataApprovalLevelSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "dataApprovalLevel";
+
+ public static final String PLURAL = "dataApprovalLevels";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( DataApprovalLevel.class, "dataApprovalLevel", "dataApprovalLevels" );
-
+ Schema schema = new Schema( DataApprovalLevel.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
-
+
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_SYSTEM_SETTING" ) ) );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PRIVATE, Lists.newArrayList( "F_SYSTEM_SETTING" ) ) );
schema.getAuthorities().add( new Authority( AuthorityType.DELETE, Lists.newArrayList( "F_SYSTEM_SETTING" ) ) );
-
+
return schema;
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataDictionarySchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataDictionarySchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataDictionarySchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class DataDictionarySchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "dataDictionary";
+
+ public static final String PLURAL = "dataDictionaries";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( DataDictionary.class, "dataDictionary", "dataDictionaries" );
-
+ Schema schema = new Schema( DataDictionary.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_DATADICTIONARY_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementGroupSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementGroupSchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementGroupSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class DataElementGroupSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "dataElementGroup";
+
+ public static final String PLURAL = "dataElementGroups";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( DataElementGroup.class, "dataElementGroup", "dataElementGroups" );
-
+ Schema schema = new Schema( DataElementGroup.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_DATAELEMENTGROUP_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementGroupSetSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementGroupSetSchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementGroupSetSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class DataElementGroupSetSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "dataElementGroupSet";
+
+ public static final String PLURAL = "dataElementGroupSets";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( DataElementGroupSet.class, "dataElementGroupSet", "dataElementGroupSets" );
-
+ Schema schema = new Schema( DataElementGroupSet.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_DATAELEMENTGROUPSET_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementSchemaDescriptor.java 2014-03-26 13:27:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataElementSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class DataElementSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "dataElement";
+
+ public static final String PLURAL = "dataElements";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( DataElement.class, "dataElement", "dataElements" );
-
+ Schema schema = new Schema( DataElement.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_DATAELEMENT_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataSetSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataSetSchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DataSetSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class DataSetSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "dataSet";
+
+ public static final String PLURAL = "dataSets";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( DataSet.class, "dataSet", "dataSets" );
-
+ Schema schema = new Schema( DataSet.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_DATASET_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DocumentSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DocumentSchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/DocumentSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class DocumentSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "document";
+
+ public static final String PLURAL = "documents";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( Document.class, "document", "documents" );
-
+ Schema schema = new Schema( Document.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_DOCUMENT_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/EventReportSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/EventReportSchemaDescriptor.java 2014-03-27 15:10:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/EventReportSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.google.common.collect.Lists;
import org.hisp.dhis.eventreport.EventReport;
import org.hisp.dhis.schema.Authority;
import org.hisp.dhis.schema.AuthorityType;
@@ -35,16 +36,20 @@
import org.hisp.dhis.schema.SchemaDescriptor;
import org.springframework.stereotype.Component;
-import com.google.common.collect.Lists;
-
@Component
public class EventReportSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "eventReport";
+
+ public static final String PLURAL = "eventReports";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( EventReport.class, "eventReport", "eventReports" );
-
+ Schema schema = new Schema( EventReport.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_EVENTREPORT_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/IndicatorGroupSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/IndicatorGroupSchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/IndicatorGroupSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class IndicatorGroupSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "indicatorGroup";
+
+ public static final String PLURAL = "indicatorGroups";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( IndicatorGroup.class, "indicatorGroup", "indicatorGroups" );
-
+ Schema schema = new Schema( IndicatorGroup.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_INDICATORGROUP_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/IndicatorGroupSetSchemaDescriptor.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/IndicatorGroupSetSchemaDescriptor.java 2014-03-26 14:28:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/descriptors/IndicatorGroupSetSchemaDescriptor.java 2014-05-27 12:49:13 +0000
@@ -42,11 +42,17 @@
@Component
public class IndicatorGroupSetSchemaDescriptor implements SchemaDescriptor
{
+ public static final String SINGULAR = "indicatorGroupSet";
+
+ public static final String PLURAL = "indicatorGroupSets";
+
+ public static final String API_ENDPOINT = "/" + PLURAL;
+
@Override
public Schema getSchema()
{
- Schema schema = new Schema( IndicatorGroupSet.class, "indicatorGroupSet", "indicatorGroupSets" );
-
+ Schema schema = new Schema( IndicatorGroupSet.class, SINGULAR, PLURAL );
+ schema.setApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_INDICATORGROUPSET_PUBLIC_ADD" ) ) );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AttributeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AttributeController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AttributeController.java 2014-05-27 12:49:13 +0000
@@ -29,6 +29,7 @@
*/
import org.hisp.dhis.attribute.Attribute;
+import org.hisp.dhis.schema.descriptors.AttributeSchemaDescriptor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -36,9 +37,8 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = AttributeController.RESOURCE_PATH )
+@RequestMapping( value = AttributeSchemaDescriptor.API_ENDPOINT )
public class AttributeController
extends AbstractCrudController<Attribute>
{
- public static final String RESOURCE_PATH = "/attributes";
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java 2014-05-27 12:49:13 +0000
@@ -28,19 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.webapi.utils.ContextUtils.DATE_PATTERN;
-import static org.hisp.dhis.common.DimensionalObjectUtils.getUniqueDimensions;
-import static org.hisp.dhis.common.DimensionalObjectUtils.toDimension;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.hisp.dhis.webapi.utils.ContextUtils;
-import org.hisp.dhis.webapi.utils.ContextUtils.CacheStrategy;
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.ChartService;
import org.hisp.dhis.common.DimensionService;
@@ -57,8 +44,10 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.schema.descriptors.ChartSchemaDescriptor;
import org.hisp.dhis.system.util.CodecUtils;
-import org.hisp.dhis.user.UserService;
+import org.hisp.dhis.webapi.utils.ContextUtils;
+import org.hisp.dhis.webapi.utils.ContextUtils.CacheStrategy;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.springframework.beans.factory.annotation.Autowired;
@@ -71,29 +60,34 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+
+import static org.hisp.dhis.common.DimensionalObjectUtils.getUniqueDimensions;
+import static org.hisp.dhis.common.DimensionalObjectUtils.toDimension;
+import static org.hisp.dhis.webapi.utils.ContextUtils.DATE_PATTERN;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
* @author Lars Helge Overland
*/
@Controller
-@RequestMapping( value = ChartController.RESOURCE_PATH )
+@RequestMapping( value = ChartSchemaDescriptor.API_ENDPOINT )
public class ChartController
extends AbstractCrudController<Chart>
{
- public static final String RESOURCE_PATH = "/charts";
-
@Autowired
private ChartService chartService;
@Autowired
- private UserService userService;
-
- @Autowired
private DataElementService dataElementService;
-
+
@Autowired
private DataElementCategoryService categoryService;
-
+
@Autowired
private IndicatorService indicatorService;
@@ -102,7 +96,7 @@
@Autowired
private DimensionService dimensionService;
-
+
@Autowired
private I18nManager i18nManager;
@@ -118,12 +112,12 @@
public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
{
Chart chart = JacksonUtils.fromJson( input, Chart.class );
-
+
mergeChart( chart );
-
+
chartService.addChart( chart );
-
- ContextUtils.createdResponse( response, "Chart created", RESOURCE_PATH + "/" + chart.getUid() );
+
+ ContextUtils.createdResponse( response, "Chart created", ChartSchemaDescriptor.API_ENDPOINT + "/" + chart.getUid() );
}
@Override
@@ -132,19 +126,19 @@
public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
{
Chart chart = chartService.getChart( uid );
-
+
if ( chart == null )
{
ContextUtils.notFoundResponse( response, "Chart does not exist: " + uid );
return;
}
-
+
Chart newChart = JacksonUtils.fromJson( input, Chart.class );
-
+
mergeChart( newChart );
-
+
chart.mergeWith( newChart );
-
+
chartService.updateChart( chart );
}
@@ -154,22 +148,22 @@
public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
{
Chart chart = chartService.getChart( uid );
-
+
if ( chart == null )
{
ContextUtils.notFoundResponse( response, "Chart does not exist: " + uid );
return;
}
-
+
chartService.deleteChart( chart );
}
-
+
//--------------------------------------------------------------------------
// Get data
//--------------------------------------------------------------------------
@RequestMapping( value = { "/{uid}/data", "/{uid}/data.png" }, method = RequestMethod.GET )
- public void getChart(
+ public void getChart(
@PathVariable( "uid" ) String uid,
@RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = DATE_PATTERN ) Date date,
@RequestParam( value = "ou", required = false ) String ou,
@@ -184,9 +178,9 @@
ContextUtils.notFoundResponse( response, "Chart does not exist: " + uid );
return;
}
-
+
OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit( ou ) : null;
-
+
JFreeChart jFreeChart = chartService.getJFreeChart( chart, date, unit, i18nManager.getI18nFormat() );
String filename = CodecUtils.filenameEncode( chart.getName() ) + ".png";
@@ -197,7 +191,7 @@
}
@RequestMapping( value = { "/data", "/data.png" }, method = RequestMethod.GET )
- public void getChart(
+ public void getChart(
@RequestParam( value = "in" ) String indicatorUid,
@RequestParam( value = "ou" ) String organisationUnitUid,
@RequestParam( value = "periods", required = false ) boolean periods,
@@ -209,7 +203,7 @@
Indicator indicator = indicatorService.getIndicator( indicatorUid );
OrganisationUnit unit = organisationUnitService.getOrganisationUnit( organisationUnitUid );
- JFreeChart chart = null;
+ JFreeChart chart;
if ( periods )
{
@@ -236,41 +230,41 @@
HttpServletResponse response ) throws IOException
{
DataElement dataElement = dataElementService.getDataElement( de );
-
+
if ( dataElement == null )
{
ContextUtils.conflictResponse( response, "Data element does not exist: " + de );
return;
}
-
+
DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo( co );
-
+
if ( categoryOptionCombo == null )
{
ContextUtils.conflictResponse( response, "Category option combo does not exist: " + co );
return;
}
-
+
Period period = PeriodType.getPeriodFromIsoString( pe );
-
+
if ( period == null )
{
ContextUtils.conflictResponse( response, "Period does not exist: " + pe );
return;
}
-
+
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( ou );
-
+
if ( organisationUnit == null )
{
ContextUtils.conflictResponse( response, "Organisation unit does not exist: " + ou );
return;
- }
+ }
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, "chart.png", false );
JFreeChart chart = chartService.getJFreeChartHistory( dataElement, categoryOptionCombo, period, organisationUnit, 13, i18nManager.getI18nFormat() );
-
+
ChartUtilities.writeChartAsPNG( response.getOutputStream(), chart, width, height );
}
@@ -282,16 +276,16 @@
public void postProcessEntity( Chart chart ) throws Exception
{
chart.populateAnalyticalProperties();
-
+
for ( OrganisationUnit organisationUnit : chart.getOrganisationUnits() )
{
chart.getParentGraphMap().put( organisationUnit.getUid(), organisationUnit.getParentGraph() );
}
-
+
if ( chart.getPeriods() != null && !chart.getPeriods().isEmpty() )
{
I18nFormat format = i18nManager.getI18nFormat();
-
+
for ( Period period : chart.getPeriods() )
{
period.setName( format.formatPeriod( period ) );
@@ -306,19 +300,19 @@
private void mergeChart( Chart chart )
{
dimensionService.mergeAnalyticalObject( chart );
-
+
chart.getFilterDimensions().clear();
-
+
if ( chart.getColumns() != null )
{
chart.setSeries( toDimension( chart.getColumns().get( 0 ).getDimension() ) );
}
-
+
if ( chart.getRows() != null )
{
chart.setCategory( toDimension( chart.getRows().get( 0 ).getDimension() ) );
}
-
+
chart.getFilterDimensions().addAll( getUniqueDimensions( chart.getFilters() ) );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConceptController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConceptController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConceptController.java 2014-05-27 12:49:13 +0000
@@ -29,6 +29,7 @@
*/
import org.hisp.dhis.concept.Concept;
+import org.hisp.dhis.schema.descriptors.ConceptSchemaDescriptor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -36,9 +37,8 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = ConceptController.RESOURCE_PATH )
+@RequestMapping( value = ConceptSchemaDescriptor.API_ENDPOINT )
public class ConceptController
extends AbstractCrudController<Concept>
{
- public static final String RESOURCE_PATH = "/concepts";
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConstantController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConstantController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConstantController.java 2014-05-27 12:49:13 +0000
@@ -29,6 +29,7 @@
*/
import org.hisp.dhis.constant.Constant;
+import org.hisp.dhis.schema.descriptors.ConstantSchemaDescriptor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -36,9 +37,8 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = ConstantController.RESOURCE_PATH )
+@RequestMapping( value = ConstantSchemaDescriptor.API_ENDPOINT )
public class ConstantController
extends AbstractCrudController<Constant>
{
- public static final String RESOURCE_PATH = "/constants";
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java 2014-05-27 12:49:13 +0000
@@ -28,21 +28,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.InputStream;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.hisp.dhis.webapi.utils.ContextUtils;
-import org.hisp.dhis.webapi.utils.WebUtils;
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.dashboard.Dashboard;
import org.hisp.dhis.dashboard.DashboardItem;
import org.hisp.dhis.dashboard.DashboardSearchResult;
import org.hisp.dhis.dashboard.DashboardService;
import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.schema.descriptors.DashboardSchemaDescriptor;
+import org.hisp.dhis.webapi.utils.ContextUtils;
+import org.hisp.dhis.webapi.utils.WebUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
@@ -53,62 +47,66 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Set;
+
import static org.hisp.dhis.dashboard.Dashboard.MAX_ITEMS;
/**
* @author Lars Helge Overland
*/
@Controller
-@RequestMapping( value = DashboardController.RESOURCE_PATH )
+@RequestMapping( value = DashboardSchemaDescriptor.API_ENDPOINT )
public class DashboardController
extends AbstractCrudController<Dashboard>
{
- public static final String RESOURCE_PATH = "/dashboards";
-
@Autowired
private DashboardService dashboardService;
-
+
@RequestMapping( value = "/q/{query}", method = RequestMethod.GET )
- public String search( @PathVariable String query, @RequestParam(required=false) Set<String> max,
+ public String search( @PathVariable String query, @RequestParam( required = false ) Set<String> max,
Model model, HttpServletResponse response ) throws Exception
{
DashboardSearchResult result = dashboardService.search( query, max );
-
+
model.addAttribute( "model", result );
-
+
return "dashboardSearchResult";
}
-
+
@Override
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
{
Dashboard dashboard = JacksonUtils.fromJson( input, Dashboard.class );
-
+
dashboardService.mergeDashboard( dashboard );
-
+
dashboardService.saveDashboard( dashboard );
-
- ContextUtils.createdResponse( response, "Dashboard created", RESOURCE_PATH + "/" + dashboard.getUid() );
+
+ ContextUtils.createdResponse( response, "Dashboard created", DashboardSchemaDescriptor.API_ENDPOINT + "/" + dashboard.getUid() );
}
-
+
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
@ResponseStatus( value = HttpStatus.NO_CONTENT )
public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
{
Dashboard dashboard = dashboardService.getDashboard( uid );
-
+
if ( dashboard == null )
{
ContextUtils.notFoundResponse( response, "Dashboard does not exist: " + uid );
return;
}
-
+
Dashboard newDashboard = JacksonUtils.fromJson( input, Dashboard.class );
dashboard.setName( newDashboard.getName() ); // TODO Name only for now
-
+
dashboardService.updateDashboard( dashboard );
}
@@ -124,14 +122,14 @@
ContextUtils.notFoundResponse( response, "Dashboard does not exist: " + uid );
return;
}
-
+
dashboardService.deleteDashboard( dashboard );
-
+
ContextUtils.okResponse( response, "Dashboard deleted" );
}
-
+
@RequestMapping( value = "/{uid}/items", method = RequestMethod.POST, consumes = "application/json" )
- public void postJsonItem( HttpServletResponse response, HttpServletRequest request,
+ public void postJsonItem( HttpServletResponse response, HttpServletRequest request,
InputStream input, @PathVariable String uid ) throws Exception
{
Dashboard dashboard = dashboardService.getDashboard( uid );
@@ -141,24 +139,24 @@
ContextUtils.notFoundResponse( response, "Dashboard does not exist: " + uid );
return;
}
-
+
DashboardItem item = JacksonUtils.fromJson( input, DashboardItem.class );
-
+
dashboardService.mergeDashboardItem( item );
-
+
dashboard.getItems().add( 0, item );
-
+
dashboardService.updateDashboard( dashboard );
-
+
ContextUtils.createdResponse( response, "Dashboard item created", item.getUid() );
}
-
+
@RequestMapping( value = "/{dashboardUid}/items/content", method = RequestMethod.POST )
- public void postJsonItemContent( HttpServletResponse response, HttpServletRequest request,
+ public void postJsonItemContent( HttpServletResponse response, HttpServletRequest request,
@PathVariable String dashboardUid, @RequestParam String type, @RequestParam( "id" ) String contentUid ) throws Exception
{
boolean result = dashboardService.addItemContent( dashboardUid, type, contentUid );
-
+
if ( !result )
{
ContextUtils.conflictResponse( response, "Max number of dashboard items reached: " + MAX_ITEMS );
@@ -168,7 +166,7 @@
ContextUtils.okResponse( response, "Dashboard item added" );
}
}
-
+
@RequestMapping( value = "/{dashboardUid}/items/{itemUid}/position/{position}", method = RequestMethod.POST )
public void moveItem( HttpServletResponse response, HttpServletRequest request,
@PathVariable String dashboardUid, @PathVariable String itemUid, @PathVariable int position ) throws Exception
@@ -180,15 +178,15 @@
ContextUtils.notFoundResponse( response, "Dashboard does not exist: " + dashboardUid );
return;
}
-
+
if ( dashboard.moveItem( itemUid, position ) )
{
dashboardService.updateDashboard( dashboard );
-
+
ContextUtils.okResponse( response, "Dashboard item moved" );
}
}
-
+
@RequestMapping( value = "/{dashboardUid}/items/{itemUid}", method = RequestMethod.DELETE )
public void deleteItem( HttpServletResponse response, HttpServletRequest request,
@PathVariable String dashboardUid, @PathVariable String itemUid )
@@ -200,13 +198,13 @@
ContextUtils.notFoundResponse( response, "Dashboard does not exist: " + dashboardUid );
return;
}
-
+
if ( dashboard.removeItem( itemUid ) )
{
dashboardService.updateDashboard( dashboard );
-
+
ContextUtils.okResponse( response, "Dashboard item removed" );
- }
+ }
}
@RequestMapping( value = "/{dashboardUid}/items/{itemUid}/content/{contentUid}", method = RequestMethod.DELETE )
@@ -220,7 +218,7 @@
ContextUtils.notFoundResponse( response, "Dashboard does not exist: " + dashboardUid );
return;
}
-
+
DashboardItem item = dashboard.getItemByUid( itemUid );
if ( item == null )
@@ -228,18 +226,18 @@
ContextUtils.notFoundResponse( response, "Dashboard item does not exist: " + itemUid );
return;
}
-
+
if ( item.removeItemContent( contentUid ) )
{
if ( item.getContentCount() == 0 )
{
dashboard.removeItem( item.getUid() ); // Remove if empty
}
-
- dashboardService.updateDashboard( dashboard );
-
+
+ dashboardService.updateDashboard( dashboard );
+
ContextUtils.okResponse( response, "Dashboard item content removed" );
- }
+ }
}
// -------------------------------------------------------------------------
@@ -252,9 +250,9 @@
for ( DashboardItem item : entity.getItems() )
{
if ( item != null )
- {
+ {
item.setHref( null ); // Null item link, not relevant
-
+
if ( item.getEmbeddedItem() != null )
{
WebUtils.generateLinks( item.getEmbeddedItem() );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalLevelController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalLevelController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalLevelController.java 2014-05-27 12:49:13 +0000
@@ -29,13 +29,13 @@
*/
import org.hisp.dhis.dataapproval.DataApprovalLevel;
+import org.hisp.dhis.schema.descriptors.DataApprovalLevelSchemaDescriptor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
-@RequestMapping( value = DataApprovalLevelController.RESOURCE_PATH )
+@RequestMapping( value = DataApprovalLevelSchemaDescriptor.API_ENDPOINT )
public class DataApprovalLevelController
extends AbstractCrudController<DataApprovalLevel>
{
- public static final String RESOURCE_PATH = "/dataApprovalLevels";
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataDictionaryController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataDictionaryController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataDictionaryController.java 2014-05-27 12:49:13 +0000
@@ -29,6 +29,7 @@
*/
import org.hisp.dhis.datadictionary.DataDictionary;
+import org.hisp.dhis.schema.descriptors.DataDictionarySchemaDescriptor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -36,9 +37,8 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = DataDictionaryController.RESOURCE_PATH )
+@RequestMapping( value = DataDictionarySchemaDescriptor.API_ENDPOINT )
public class DataDictionaryController
extends AbstractCrudController<DataDictionary>
{
- public static final String RESOURCE_PATH = "/dataDictionaries";
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataSetController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataSetController.java 2014-05-27 12:49:13 +0000
@@ -28,27 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import org.hisp.dhis.webapi.utils.ContextUtils;
-import org.hisp.dhis.webapi.utils.FormUtils;
-import org.hisp.dhis.webapi.view.ClassPathUriResolver;
-import org.hisp.dhis.webapi.webdomain.form.Form;
import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.dataentryform.DataEntryForm;
import org.hisp.dhis.dataentryform.DataEntryFormService;
@@ -65,6 +44,11 @@
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.schema.descriptors.DataSetSchemaDescriptor;
+import org.hisp.dhis.webapi.utils.ContextUtils;
+import org.hisp.dhis.webapi.utils.FormUtils;
+import org.hisp.dhis.webapi.view.ClassPathUriResolver;
+import org.hisp.dhis.webapi.webdomain.form.Form;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.MediaType;
@@ -76,15 +60,30 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = DataSetController.RESOURCE_PATH )
+@RequestMapping( value = DataSetSchemaDescriptor.API_ENDPOINT )
public class DataSetController
extends AbstractCrudController<DataSet>
{
- public static final String RESOURCE_PATH = "/dataSets";
public static final String DSD_TRANSFORM = "/templates/metadata2dsd.xsl";
// -------------------------------------------------------------------------
@@ -102,10 +101,10 @@
@Autowired
private DataValueService dataValueService;
-
+
@Autowired
private DataValueSetService dataValueSetService;
-
+
@Autowired
private PeriodService periodService;
@@ -195,7 +194,7 @@
}
Period pe = periodService.getPeriod( period );
-
+
response.setContentType( MediaType.APPLICATION_XML_VALUE );
dataValueSetService.writeDataValueSetTemplate( response.getOutputStream(), dataSet, pe, orgUnits, comment, orgUnitIdScheme, dataElementIdScheme );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DocumentController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DocumentController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DocumentController.java 2014-05-27 12:49:13 +0000
@@ -29,12 +29,13 @@
*/
import org.apache.commons.io.IOUtils;
-import org.hisp.dhis.webapi.utils.ContextUtils;
-import org.hisp.dhis.webapi.utils.ContextUtils.CacheStrategy;
import org.hisp.dhis.document.Document;
import org.hisp.dhis.document.DocumentService;
import org.hisp.dhis.external.location.LocationManager;
import org.hisp.dhis.external.location.LocationManagerException;
+import org.hisp.dhis.schema.descriptors.DocumentSchemaDescriptor;
+import org.hisp.dhis.webapi.utils.ContextUtils;
+import org.hisp.dhis.webapi.utils.ContextUtils.CacheStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
@@ -49,12 +50,10 @@
* @author Lars Helge Overland
*/
@Controller
-@RequestMapping(value = DocumentController.RESOURCE_PATH)
+@RequestMapping( value = DocumentSchemaDescriptor.API_ENDPOINT )
public class DocumentController
extends AbstractCrudController<Document>
{
- public static final String RESOURCE_PATH = "/documents";
-
@Autowired
private DocumentService documentService;
@@ -64,8 +63,8 @@
@Autowired
private ContextUtils contextUtils;
- @RequestMapping(value = "/{uid}/data", method = RequestMethod.GET)
- public void getDocumentContent( @PathVariable("uid") String uid, HttpServletResponse response ) throws Exception
+ @RequestMapping( value = "/{uid}/data", method = RequestMethod.GET )
+ public void getDocumentContent( @PathVariable( "uid" ) String uid, HttpServletResponse response ) throws Exception
{
Document document = documentService.getDocument( uid );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryComboController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryComboController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryComboController.java 2014-05-27 12:49:13 +0000
@@ -28,8 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
+import org.hisp.dhis.schema.descriptors.CategoryComboSchemaDescriptor;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -37,7 +38,7 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/categoryCombos" )
+@RequestMapping( value = CategoryComboSchemaDescriptor.API_ENDPOINT )
public class CategoryComboController
extends AbstractCrudController<DataElementCategoryCombo>
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryController.java 2014-05-27 12:49:13 +0000
@@ -28,8 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.dataelement.DataElementCategory;
+import org.hisp.dhis.schema.descriptors.CategorySchemaDescriptor;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.dataelement.DataElementCategory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -37,7 +38,7 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/categories" )
+@RequestMapping( value = CategorySchemaDescriptor.API_ENDPOINT )
public class CategoryController
extends AbstractCrudController<DataElementCategory>
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionComboController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionComboController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionComboController.java 2014-05-27 12:49:13 +0000
@@ -28,11 +28,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.schema.descriptors.CategoryOptionComboSchemaDescriptor;
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.comparator.IdentifiableObjectNameComparator;
-import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -45,7 +46,7 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/categoryOptionCombos" )
+@RequestMapping( value = CategoryOptionComboSchemaDescriptor.API_ENDPOINT )
public class CategoryOptionComboController
extends AbstractCrudController<DataElementCategoryOptionCombo>
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionController.java 2014-05-27 12:49:13 +0000
@@ -28,8 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.dataelement.DataElementCategoryOption;
+import org.hisp.dhis.schema.descriptors.CategoryOptionSchemaDescriptor;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -37,7 +38,7 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/categoryOptions" )
+@RequestMapping( value = CategoryOptionSchemaDescriptor.API_ENDPOINT )
public class CategoryOptionController
extends AbstractCrudController<DataElementCategoryOption>
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionGroupController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionGroupController.java 2014-05-27 12:49:13 +0000
@@ -28,8 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
+import org.hisp.dhis.schema.descriptors.CategoryOptionGroupSchemaDescriptor;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -37,7 +38,7 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/categoryOptionGroups" )
+@RequestMapping( value = CategoryOptionGroupSchemaDescriptor.API_ENDPOINT )
public class CategoryOptionGroupController
extends AbstractCrudController<CategoryOptionGroup>
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionGroupSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionGroupSetController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionGroupSetController.java 2014-05-27 12:49:13 +0000
@@ -28,8 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
+import org.hisp.dhis.schema.descriptors.CategoryOptionGroupSetSchemaDescriptor;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -37,7 +38,7 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = "/categoryOptionGroupSets" )
+@RequestMapping( value = CategoryOptionGroupSetSchemaDescriptor.API_ENDPOINT )
public class CategoryOptionGroupSetController
extends AbstractCrudController<CategoryOptionGroupSet>
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementController.java 2014-05-27 12:49:13 +0000
@@ -28,33 +28,31 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.webapi.controller.WebMetaData;
-import org.hisp.dhis.webapi.controller.WebOptions;
+import com.google.common.collect.Lists;
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.schema.descriptors.DataElementSchemaDescriptor;
+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.web.bind.annotation.RequestMapping;
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping(value = DataElementController.RESOURCE_PATH)
+@RequestMapping( value = DataElementSchemaDescriptor.API_ENDPOINT )
public class DataElementController
extends AbstractCrudController<DataElement>
{
- public static final String RESOURCE_PATH = "/dataElements";
-
@Autowired
private DataElementService dataElementService;
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupController.java 2014-05-27 12:49:13 +0000
@@ -29,11 +29,6 @@
*/
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.webapi.utils.ContextUtils;
-import org.hisp.dhis.webapi.utils.WebUtils;
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.PagerUtils;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
@@ -41,6 +36,12 @@
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataelement.DataElementOperand;
+import org.hisp.dhis.schema.descriptors.DataElementGroupSchemaDescriptor;
+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.webapi.utils.ContextUtils;
+import org.hisp.dhis.webapi.utils.WebUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@@ -61,17 +62,15 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping(value = DataElementGroupController.RESOURCE_PATH)
+@RequestMapping( value = DataElementGroupSchemaDescriptor.API_ENDPOINT )
public class DataElementGroupController
extends AbstractCrudController<DataElementGroup>
{
- public static final String RESOURCE_PATH = "/dataElementGroups";
-
@Autowired
private DataElementCategoryService dataElementCategoryService;
- @RequestMapping(value = "/{uid}/members", method = RequestMethod.GET)
- public String getMembers( @PathVariable("uid") String uid, @RequestParam Map<String, String> parameters,
+ @RequestMapping( value = "/{uid}/members", method = RequestMethod.GET )
+ public String getMembers( @PathVariable( "uid" ) String uid, @RequestParam Map<String, String> parameters,
Model model, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
WebOptions options = new WebOptions( parameters );
@@ -107,8 +106,8 @@
return StringUtils.uncapitalize( getEntitySimpleName() );
}
- @RequestMapping(value = "/{uid}/members/query/{q}", method = RequestMethod.GET)
- public String getMembersByQuery( @PathVariable("uid") String uid, @PathVariable("q") String q,
+ @RequestMapping( value = "/{uid}/members/query/{q}", method = RequestMethod.GET )
+ public String getMembersByQuery( @PathVariable( "uid" ) String uid, @PathVariable( "q" ) String q,
@RequestParam Map<String, String> parameters, Model model, HttpServletRequest request,
HttpServletResponse response ) throws Exception
{
@@ -154,8 +153,8 @@
return StringUtils.uncapitalize( getEntitySimpleName() );
}
- @RequestMapping(value = "/{uid}/operands", method = RequestMethod.GET)
- public String getOperands( @PathVariable("uid") String uid, @RequestParam Map<String, String> parameters,
+ @RequestMapping( value = "/{uid}/operands", method = RequestMethod.GET )
+ public String getOperands( @PathVariable( "uid" ) String uid, @RequestParam Map<String, String> parameters,
Model model, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
WebOptions options = new WebOptions( parameters );
@@ -169,10 +168,10 @@
WebMetaData metaData = new WebMetaData();
List<DataElementOperand> dataElementOperands = Lists.newArrayList( dataElementCategoryService.getOperands( dataElementGroup.getMembers() ) );
-
- Collections.sort( dataElementOperands, IdentifiableObjectNameComparator.INSTANCE );
-
- Collections.sort( dataElementOperands, IdentifiableObjectNameComparator.INSTANCE );
+
+ Collections.sort( dataElementOperands, IdentifiableObjectNameComparator.INSTANCE );
+
+ Collections.sort( dataElementOperands, IdentifiableObjectNameComparator.INSTANCE );
metaData.setDataElementOperands( dataElementOperands );
@@ -196,8 +195,8 @@
return StringUtils.uncapitalize( getEntitySimpleName() );
}
- @RequestMapping(value = "/{uid}/operands/query/{q}", method = RequestMethod.GET)
- public String getOperandsByQuery( @PathVariable("uid") String uid, @PathVariable("q") String q,
+ @RequestMapping( value = "/{uid}/operands/query/{q}", method = RequestMethod.GET )
+ public String getOperandsByQuery( @PathVariable( "uid" ) String uid, @PathVariable( "q" ) String q,
@RequestParam Map<String, String> parameters, Model model, HttpServletRequest request,
HttpServletResponse response ) throws Exception
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupSetController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupSetController.java 2014-05-27 12:49:13 +0000
@@ -28,8 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.dataelement.DataElementGroupSet;
+import org.hisp.dhis.schema.descriptors.DataElementGroupSetSchemaDescriptor;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.dataelement.DataElementGroupSet;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -37,9 +38,8 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = DataElementGroupSetController.RESOURCE_PATH )
+@RequestMapping( value = DataElementGroupSetSchemaDescriptor.API_ENDPOINT )
public class DataElementGroupSetController
extends AbstractCrudController<DataElementGroupSet>
{
- public static final String RESOURCE_PATH = "/dataElementGroupSets";
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java 2014-05-27 12:49:13 +0000
@@ -28,15 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.common.DimensionalObjectUtils.getDimensions;
-
-import java.io.InputStream;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.webapi.utils.ContextUtils;
import org.hisp.dhis.common.DimensionService;
import org.hisp.dhis.dxf2.utils.JacksonUtils;
import org.hisp.dhis.eventreport.EventReport;
@@ -47,6 +38,9 @@
import org.hisp.dhis.period.Period;
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.program.ProgramStageService;
+import org.hisp.dhis.schema.descriptors.EventReportSchemaDescriptor;
+import org.hisp.dhis.webapi.controller.AbstractCrudController;
+import org.hisp.dhis.webapi.utils.ContextUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
@@ -55,25 +49,29 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+
+import static org.hisp.dhis.common.DimensionalObjectUtils.getDimensions;
+
/**
* @author Lars Helge Overland
*/
@Controller
-@RequestMapping( value = EventReportController.RESOURCE_PATH )
+@RequestMapping( value = EventReportSchemaDescriptor.API_ENDPOINT )
public class EventReportController
extends AbstractCrudController<EventReport>
{
- public static final String RESOURCE_PATH = "/eventReports";
-
@Autowired
private EventReportService eventReportService;
@Autowired
private DimensionService dimensionService;
-
+
@Autowired
private ProgramService programService;
-
+
@Autowired
private ProgramStageService programStageService;
@@ -89,12 +87,12 @@
public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
{
EventReport report = JacksonUtils.fromJson( input, EventReport.class );
-
+
mergeEventReport( report );
-
+
eventReportService.saveEventReport( report );
-
- ContextUtils.createdResponse( response, "Event report created", RESOURCE_PATH + "/" + report.getUid() );
+
+ ContextUtils.createdResponse( response, "Event report created", EventReportSchemaDescriptor.API_ENDPOINT + "/" + report.getUid() );
}
@Override
@@ -111,11 +109,11 @@
}
EventReport newReport = JacksonUtils.fromJson( input, EventReport.class );
-
+
mergeEventReport( newReport );
-
+
report.mergeWith( newReport );
-
+
eventReportService.updateEventReport( report );
}
@@ -133,14 +131,14 @@
}
eventReportService.deleteEventReport( report );
- }
-
+ }
+
//--------------------------------------------------------------------------
// Hooks
//--------------------------------------------------------------------------
@Override
- protected void postProcessEntity( EventReport report )
+ protected void postProcessEntity( EventReport report )
throws Exception
{
report.populateAnalyticalProperties();
@@ -160,7 +158,7 @@
}
}
}
-
+
//--------------------------------------------------------------------------
// Supportive methods
//--------------------------------------------------------------------------
@@ -168,20 +166,20 @@
private void mergeEventReport( EventReport report )
{
dimensionService.mergeAnalyticalObject( report );
-
+
report.getColumnDimensions().clear();
report.getRowDimensions().clear();
report.getFilterDimensions().clear();
-
+
report.getColumnDimensions().addAll( getDimensions( report.getColumns() ) );
report.getRowDimensions().addAll( getDimensions( report.getRows() ) );
report.getFilterDimensions().addAll( getDimensions( report.getFilters() ) );
-
+
if ( report.getProgram() != null )
{
report.setProgram( programService.getProgram( report.getProgram().getUid() ) );
}
-
+
if ( report.getProgramStage() != null )
{
report.setProgramStage( programStageService.getProgramStage( report.getProgramStage().getUid() ) );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/indicator/IndicatorGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/indicator/IndicatorGroupController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/indicator/IndicatorGroupController.java 2014-05-27 12:49:13 +0000
@@ -36,6 +36,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.hisp.dhis.schema.descriptors.IndicatorGroupSchemaDescriptor;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
import org.hisp.dhis.webapi.controller.WebMetaData;
import org.hisp.dhis.webapi.controller.WebOptions;
@@ -58,12 +59,10 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping(value = IndicatorGroupController.RESOURCE_PATH)
+@RequestMapping( value = IndicatorGroupSchemaDescriptor.API_ENDPOINT )
public class IndicatorGroupController
extends AbstractCrudController<IndicatorGroup>
{
- public static final String RESOURCE_PATH = "/indicatorGroups";
-
@RequestMapping( value = "/{uid}/members", method = RequestMethod.GET )
public String getMembers( @PathVariable( "uid" ) String uid, @RequestParam Map<String, String> parameters,
Model model, HttpServletRequest request, HttpServletResponse response ) throws Exception
@@ -80,7 +79,7 @@
WebMetaData metaData = new WebMetaData();
List<Indicator> indicators = new ArrayList<Indicator>( indicatorGroup.getMembers() );
Collections.sort( indicators, IdentifiableObjectNameComparator.INSTANCE );
-
+
if ( options.hasPaging() )
{
Pager pager = new Pager( options.getPage(), indicators.size(), options.getPageSize() );
@@ -101,8 +100,8 @@
return StringUtils.uncapitalize( getEntitySimpleName() );
}
- @RequestMapping(value = "/{uid}/members/query/{q}", method = RequestMethod.GET)
- public String getMembersByQuery( @PathVariable("uid") String uid, @PathVariable("q") String q,
+ @RequestMapping( value = "/{uid}/members/query/{q}", method = RequestMethod.GET )
+ public String getMembersByQuery( @PathVariable( "uid" ) String uid, @PathVariable( "q" ) String q,
@RequestParam Map<String, String> parameters, Model model, HttpServletRequest request,
HttpServletResponse response ) throws Exception
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/indicator/IndicatorGroupSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/indicator/IndicatorGroupSetController.java 2014-05-22 12:40:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/indicator/IndicatorGroupSetController.java 2014-05-27 12:49:13 +0000
@@ -28,8 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.indicator.IndicatorGroupSet;
+import org.hisp.dhis.schema.descriptors.IndicatorGroupSetSchemaDescriptor;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.indicator.IndicatorGroupSet;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -37,9 +38,8 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Controller
-@RequestMapping( value = IndicatorGroupSetController.RESOURCE_PATH )
+@RequestMapping( value = IndicatorGroupSetSchemaDescriptor.API_ENDPOINT )
public class IndicatorGroupSetController
extends AbstractCrudController<IndicatorGroupSet>
{
- public static final String RESOURCE_PATH = "/indicatorGroupSets";
}