=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2014-12-22 13:52:51 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2014-12-29 13:13:12 +0000 @@ -39,7 +39,9 @@ import org.hisp.dhis.acl.Access; import org.hisp.dhis.acl.AccessStringHelper; import org.hisp.dhis.common.annotation.Description; +import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.DimensionalView; +import org.hisp.dhis.common.view.ExportView; import org.hisp.dhis.common.view.SharingBasicView; import org.hisp.dhis.common.view.SharingDetailedView; import org.hisp.dhis.common.view.SharingExportView; @@ -107,7 +109,7 @@ /** * Access string for public access. */ - protected String publicAccess = AccessStringHelper.DEFAULT; + protected String publicAccess; /** * Owner of this object. @@ -280,7 +282,7 @@ @Override @JsonProperty - @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class } ) + @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class, ExportView.class, DetailedView.class } ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) @PropertyRange( min = 8, max = 8 ) public String getPublicAccess() @@ -295,7 +297,7 @@ @Override @JsonProperty - @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class } ) + @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class, ExportView.class, DetailedView.class } ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public boolean getExternalAccess() { @@ -309,7 +311,7 @@ @Override @JsonProperty - @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class } ) + @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class, ExportView.class, DetailedView.class } ) @JsonSerialize( as = BaseIdentifiableObject.class ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public User getUser() @@ -324,7 +326,7 @@ @Override @JsonProperty - @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class } ) + @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class, ExportView.class, DetailedView.class } ) @JacksonXmlElementWrapper( localName = "userGroupAccesses", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "userGroupAccess", namespace = DxfNamespaces.DXF_2_0 ) public Set getUserGroupAccesses() @@ -450,6 +452,23 @@ } /** + * Clear out all sharing properties. + * + * @param clearUser Clear out user property + */ + public void clearSharing( boolean clearUser ) + { + if ( clearUser ) + { + user = null; + } + + publicAccess = AccessStringHelper.DEFAULT; + externalAccess = false; + userGroupAccesses.clear(); + } + + /** * Get a map of uids to internal identifiers * * @param objects the IdentifiableObjects to put in the map @@ -527,11 +546,27 @@ { Validate.notNull( other ); - this.uid = other.getUid() == null ? this.uid : other.getUid(); - this.name = other.getName() == null ? this.name : other.getName(); - this.code = other.getCode() == null ? this.code : other.getCode(); - this.lastUpdated = other.getLastUpdated() == null ? this.lastUpdated : other.getLastUpdated(); - this.created = other.getCreated() == null ? this.created : other.getCreated(); - this.user = other.getUser() == null ? this.user : other.getUser(); + uid = other.getUid() == null ? uid : other.getUid(); + name = other.getName() == null ? name : other.getName(); + code = other.getCode() == null ? code : other.getCode(); + lastUpdated = other.getLastUpdated() == null ? lastUpdated : other.getLastUpdated(); + created = other.getCreated() == null ? created : other.getCreated(); + + // TODO leave this in? we might have sub-classes that have user which is not sharing related + user = other.getUser() == null ? user : other.getUser(); + } + + @Override + public void mergeSharingWith( IdentifiableObject other ) + { + Validate.notNull( other ); + + // sharing + user = other.getUser() == null ? user : other.getUser(); + publicAccess = other.getPublicAccess() == null ? publicAccess : other.getPublicAccess(); + externalAccess = other.getExternalAccess(); + + userGroupAccesses.clear(); + userGroupAccesses.addAll( other.getUserGroupAccesses() ); } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Mergeable.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Mergeable.java 2014-03-18 08:10:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Mergeable.java 2014-12-29 13:13:12 +0000 @@ -37,4 +37,6 @@ public interface Mergeable { void mergeWith( T other ); + + void mergeSharingWith( T other ); } === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java 2014-12-07 13:56:05 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportOptions.java 2014-12-29 13:13:12 +0000 @@ -59,6 +59,8 @@ private boolean skipExistingCheck; + private boolean sharing; + //-------------------------------------------------------------------------- // Constructors //-------------------------------------------------------------------------- @@ -197,6 +199,16 @@ this.skipExistingCheck = skipExistingCheck; } + public boolean isSharing() + { + return sharing; + } + + public void setSharing( boolean sharing ) + { + this.sharing = sharing; + } + @Override public String toString() { === modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java' --- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2014-12-12 17:48:12 +0000 +++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2014-12-29 13:13:12 +0000 @@ -56,14 +56,12 @@ import org.hisp.dhis.interpretation.Interpretation; import org.hisp.dhis.user.CurrentUserService; import org.hisp.dhis.user.User; -import org.hisp.dhis.user.UserGroupAccess; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Required; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; -import java.util.HashSet; import java.util.List; /** @@ -304,8 +302,8 @@ if ( IdentifiableObject.class.isAssignableFrom( object.getClass() ) ) { BaseIdentifiableObject identifiableObject = (BaseIdentifiableObject) object; - identifiableObject.setPublicAccess( AccessStringHelper.newInstance().build() ); - identifiableObject.setUserGroupAccesses( new HashSet() ); + identifiableObject.setPublicAccess( AccessStringHelper.DEFAULT ); + identifiableObject.getUserGroupAccesses().clear(); if ( identifiableObject.getUser() == null ) {