Skip to content

Commit

Permalink
Merge pull request #324 from dhis2/automatic-is-shareable-225
Browse files Browse the repository at this point in the history
auto-set shareable flag on schema based on persisted properties: user…
  • Loading branch information
mortenoh committed Nov 21, 2016
2 parents f25b5f8 + 502b7ea commit 0a8fe47
Show file tree
Hide file tree
Showing 45 changed files with 3 additions and 46 deletions.
Expand Up @@ -111,7 +111,7 @@ public class Schema implements Ordered, Klass
/**
* Is sharing supported for instances of this class.
*/
private boolean shareable;
private Boolean shareable;

/**
* Points to relative Web-API endpoint (if exposed).
Expand Down Expand Up @@ -288,7 +288,8 @@ public void setDisplayName( String displayName )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public boolean isShareable()
{
return shareable;
return shareable != null ? shareable :
(havePersistedProperty( "user" ) && havePersistedProperty( "userGroupAccesses" ) && havePersistedProperty( "publicAccess" ));
}

public void setShareable( boolean shareable )
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( DataElementCategoryCombo.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1180 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_CATEGORY_COMBO_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( DataElementCategoryOptionCombo.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( false );
schema.setOrder( 1190 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE,
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( CategoryOptionGroup.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1150 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_CATEGORY_OPTION_GROUP_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( CategoryOptionGroupSet.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1160 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_CATEGORY_OPTION_GROUP_SET_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( DataElementCategoryOption.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1140 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_CATEGORY_OPTION_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( DataElementCategory.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1170 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_CATEGORY_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( Chart.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 2000 );
schema.setImplicitPrivateAuthority( true );

Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( Constant.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1030 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE, Lists.newArrayList( "F_CONSTANT_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( DashboardItem.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( false );
schema.setOrder( 3500 );
schema.setDefaultPrivate( true );
schema.setImplicitPrivateAuthority( true );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( Dashboard.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 3501 );
schema.setDefaultPrivate( true );
schema.setImplicitPrivateAuthority( true );
Expand Down
Expand Up @@ -48,7 +48,6 @@ public Schema getSchema()
{
Schema schema = new Schema( DataApprovalLevel.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1370 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_SYSTEM_SETTING" ) ) );
Expand Down
Expand Up @@ -48,7 +48,6 @@ public Schema getSchema()
{
Schema schema = new Schema( DataApprovalWorkflow.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( false );
schema.setOrder( 1380 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_SYSTEM_SETTING" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( DataElementGroup.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1210 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_DATAELEMENTGROUP_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( DataElementGroupSet.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1220 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_DATAELEMENTGROUPSET_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( DataElement.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1200 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_DATAELEMENT_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -48,7 +48,6 @@ public Schema getSchema()
{
Schema schema = new Schema( DataEntryForm.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( false );
schema.setOrder( 1300 );

return schema;
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( Document.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 2000 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_DOCUMENT_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -49,7 +49,6 @@ public Schema getSchema()
{
Schema schema = new Schema( EventChart.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1540 );
schema.setImplicitPrivateAuthority( true );

Expand Down
Expand Up @@ -48,7 +48,6 @@ public Schema getSchema()
{
Schema schema = new Schema( EventReport.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1540 );
schema.setImplicitPrivateAuthority( true );

Expand Down
Expand Up @@ -49,7 +49,6 @@ public Schema getSchema()
{
Schema schema = new Schema( FileResource.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( false );
schema.setMetadata( false );
schema.setOrder( 1250 );
return schema;
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( IndicatorGroup.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1260 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_INDICATORGROUP_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( IndicatorGroupSet.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1270 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_INDICATORGROUPSET_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( Indicator.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1250 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_INDICATOR_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -49,7 +49,6 @@ public Schema getSchema()
Schema schema = new Schema( InterpretationComment.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setMetadata( false );
schema.setShareable( false );
schema.setOrder( 1441 );

return schema;
Expand Down
Expand Up @@ -49,7 +49,6 @@ public Schema getSchema()
Schema schema = new Schema( Interpretation.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setMetadata( false );
schema.setShareable( true );
schema.setOrder( 1440 );

return schema;
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( LegendSet.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1080 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_LEGEND_SET_PUBLIC_ADD", "F_GIS_ADMIN" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( Map.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 2000 );
schema.setImplicitPrivateAuthority( true );

Expand Down
Expand Up @@ -55,7 +55,6 @@ public Schema getSchema()
{
Schema schema = new Schema( OptionGroup.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1051 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_OPTIONGROUP_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -55,7 +55,6 @@ public Schema getSchema()
{
Schema schema = new Schema( OptionGroupSet.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1051 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_OPTIONGROUPSET_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( Option.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( false );
schema.setOrder( 1040 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_OPTIONSET_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( OptionSet.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1050 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_OPTIONSET_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( OrganisationUnitGroup.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1120 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_ORGUNITGROUP_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( OrganisationUnitGroupSet.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1130 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_ORGUNITGROUPSET_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -52,7 +52,6 @@ public Schema getSchema()
Schema schema = new Schema( ProgramIndicator.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setOrder( 1560 );
schema.setShareable( true );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_PROGRAM_INDICATOR_PUBLIC_ADD" ) ) );
schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PRIVATE, Lists.newArrayList( "F_PROGRAM_INDICATOR_PRIVATE_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( Program.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1520 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_PROGRAM_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( Report.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 2000 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_REPORT_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( ReportTable.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 2000 );
schema.setImplicitPrivateAuthority( true );

Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( SqlView.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1010 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_SQLVIEW_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( TrackedEntityAttribute.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1490 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_TRACKED_ENTITY_ATTRIBUTE_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -49,7 +49,6 @@ public Schema getSchema()
Schema schema = new Schema( TrackedEntityDataElementDimension.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setMetadata( false );
schema.setShareable( false );
schema.setOrder( 1490 );

return schema;
Expand Down
Expand Up @@ -49,7 +49,6 @@ public Schema getSchema()
Schema schema = new Schema( TrackedEntityProgramIndicatorDimension.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setMetadata( false );
schema.setShareable( false );
schema.setOrder( 1490 );

return schema;
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( UserGroup.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 102 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_USERGROUP_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( UserAuthorityGroup.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 100 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE_PUBLIC, Lists.newArrayList( "F_USERROLE_PUBLIC_ADD" ) ) );
Expand Down
Expand Up @@ -51,7 +51,6 @@ public Schema getSchema()
{
Schema schema = new Schema( ValidationRuleGroup.class, SINGULAR, PLURAL );
schema.setRelativeApiEndpoint( API_ENDPOINT );
schema.setShareable( true );
schema.setOrder( 1400 );

schema.getAuthorities().add( new Authority( AuthorityType.CREATE, Lists.newArrayList( "F_VALIDATIONRULEGROUP_PUBLIC_ADD" ) ) );
Expand Down

0 comments on commit 0a8fe47

Please sign in to comment.