Search in sources :

Example 1 with TypeHasPrivateParents

use of net.geoprism.registry.geoobjecttype.TypeHasPrivateParents in project geoprism-registry by terraframe.

the class GeoObjectTypeMetadata method apply.

@Override
public void apply() {
    if (!this.isNew() && this.isModified(GeoObjectTypeMetadata.ISPRIVATE)) {
        final ServerGeoObjectType type = this.getServerType();
        // They aren't allowed to set this to private in certain scenarios
        if (this.getIsPrivate()) {
            if (this.hasPublicChildren()) {
                PrivateTypeHasPublicChildren ex = new PrivateTypeHasPublicChildren();
                ex.setTypeLabel(this.getServerType().getLabel().getValue());
                throw ex;
            }
            if (this.isReferencedInPublicListTypes()) {
                PrivateTypeIsReferencedInPublicMasterLists ex = new PrivateTypeIsReferencedInPublicMasterLists();
                ex.setTypeLabel(this.getServerType().getLabel().getValue());
                throw ex;
            }
        } else {
            if (this.hasPrivateParents()) {
                TypeHasPrivateParents ex = new TypeHasPrivateParents();
                ex.setTypeLabel(this.getServerType().getLabel().getValue());
                throw ex;
            }
        }
        // Set the isPrivate field for all children
        if (this.isModified(GeoObjectTypeMetadata.ISPRIVATE) && type.getIsAbstract()) {
            List<ServerGeoObjectType> subtypes = type.getSubtypes();
            for (ServerGeoObjectType subtype : subtypes) {
                GeoObjectTypeMetadata submetadata = subtype.getMetadata();
                submetadata.appLock();
                submetadata.setIsPrivate(this.getIsPrivate());
                submetadata.apply();
            }
        }
    }
    super.apply();
}
Also used : PrivateTypeIsReferencedInPublicMasterLists(net.geoprism.registry.geoobjecttype.PrivateTypeIsReferencedInPublicMasterLists) PrivateTypeHasPublicChildren(net.geoprism.registry.geoobjecttype.PrivateTypeHasPublicChildren) TypeHasPrivateParents(net.geoprism.registry.geoobjecttype.TypeHasPrivateParents)

Aggregations

PrivateTypeHasPublicChildren (net.geoprism.registry.geoobjecttype.PrivateTypeHasPublicChildren)1 PrivateTypeIsReferencedInPublicMasterLists (net.geoprism.registry.geoobjecttype.PrivateTypeIsReferencedInPublicMasterLists)1 TypeHasPrivateParents (net.geoprism.registry.geoobjecttype.TypeHasPrivateParents)1