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();
}
Aggregations