=== 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-10-23 09:02:41 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java 2014-11-18 13:45:13 +0000 @@ -154,6 +154,16 @@ */ private boolean writable; + /** + * Are the values for this property required to be unique? + */ + private boolean unique; + + /** + * Are the values for this property required to be not-null? + */ + private boolean notNull; + public Property() { } @@ -396,6 +406,30 @@ this.writable = writable; } + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public boolean isUnique() + { + return unique; + } + + public void setUnique( boolean unique ) + { + this.unique = unique; + } + + @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public boolean isNotNull() + { + return notNull; + } + + public void setNotNull( boolean notNull ) + { + this.notNull = notNull; + } + public String key() { return isCollection() ? collectionName : name; === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java 2014-10-21 17:05:37 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java 2014-11-18 13:45:13 +0000 @@ -59,7 +59,7 @@ * * @author Morten Olav Hansen */ -public class Jackson2PropertyIntrospectorService +public class Jackson2PropertyIntrospectorService extends AbstractPropertyIntrospectorService { @Autowired @@ -117,6 +117,31 @@ property.setWritable( property.isPersisted() ); } + // This will be replaced later and fetched from hibernate mapping files instead + if ( property.isPersisted() && ("name".equals( fieldName ) || "code".equals( fieldName )) ) + { + IdentifiableObject identifiableObject; + + try + { + identifiableObject = (IdentifiableObject) clazz.newInstance(); + + if ( "name".equals( fieldName ) ) + { + property.setUnique( identifiableObject.haveUniqueNames() ); + property.setNotNull( true ); + } + else if ( "code".equals( fieldName ) ) + { + property.setUnique( identifiableObject.haveUniqueCode() ); + property.setNotNull( true ); + } + } + catch ( InstantiationException | IllegalAccessException ignored ) + { + } + } + if ( method.isAnnotationPresent( Description.class ) ) { Description description = method.getAnnotation( Description.class );