Search in sources :

Example 1 with Actor

use of com.runwaysdk.system.Actor in project geoprism-registry by terraframe.

the class Organization method getRootOrganization.

/**
 * If the given actor OID is a role that represents an {@link Organization},
 * then return the corresponding {@link Organization} or NULL otherwise.
 *
 * Precondition: Assumes that the actor id, if it is associated with an
 * organization, is the root organization role and not a sub-role of the root
 * organization.
 *
 * @param actorOid
 *          OID of an actor.
 *
 * @return the corresponding {@link Organization} or NULL otherwise.
 */
public static Organization getRootOrganization(String actorOid) {
    Actor actor = null;
    try {
        actor = Actor.get(actorOid);
    } catch (com.runwaysdk.dataaccess.cache.DataNotFoundException e) {
        return null;
    }
    // If the actor is not a role, then it does not represent an organization
    if (!(actor instanceof Roles)) {
        return null;
    }
    Roles role = (Roles) actor;
    String roleName = role.getRoleName();
    // not a role that pertains to an organization.
    if (roleName.indexOf(RegistryRole.Type.REGISTRY_ROOT_ORG_ROLE) <= -1) {
        return null;
    }
    String organizationCode = roleName.substring(RegistryRole.Type.REGISTRY_ROOT_ORG_ROLE.length() + 1, roleName.length());
    try {
        return Organization.getByCode(organizationCode);
    } catch (com.runwaysdk.dataaccess.cache.DataNotFoundException e) {
        return null;
    }
}
Also used : Actor(com.runwaysdk.system.Actor) SingleActor(com.runwaysdk.system.SingleActor) Roles(com.runwaysdk.system.Roles)

Example 2 with Actor

use of com.runwaysdk.system.Actor in project geoprism-registry by terraframe.

the class ServerGeoObjectType method deleteInTransaction.

@Transaction
private void deleteInTransaction() {
    List<ServerHierarchyType> hierarchies = this.getHierarchies(true);
    if (hierarchies.size() > 0) {
        StringBuilder codes = hierarchies.stream().collect(StringBuilder::new, (x, y) -> x.append(y.getCode()), (a, b) -> a.append(",").append(b));
        throw new TypeInUseException("Cannot delete a GeoObjectType used in the hierarchies: " + codes);
    }
    // for (String hierarchy : hierarchies)
    // {
    // OIterator<com.runwaysdk.business.ontology.Term> it =
    // this.universal.getDirectDescendants(hierarchy);
    // 
    // try
    // {
    // if (it.hasNext())
    // {
    // }
    // }
    // finally
    // {
    // it.close();
    // }
    // }
    /*
     * Delete all subtypes
     */
    List<ServerGeoObjectType> subtypes = this.getSubtypes();
    for (ServerGeoObjectType subtype : subtypes) {
        subtype.deleteInTransaction();
    }
    /*
     * Delete all inherited hierarchies
     */
    List<? extends InheritedHierarchyAnnotation> annotations = InheritedHierarchyAnnotation.getByUniversal(getUniversal());
    for (InheritedHierarchyAnnotation annotation : annotations) {
        annotation.delete();
    }
    GeoVertexType.remove(this.universal.getUniversalId());
    /*
     * Delete all Attribute references
     */
    // AttributeHierarchy.deleteByUniversal(this.universal);
    this.getMetadata().delete();
    // This deletes the {@link MdBusiness} as well
    this.universal.delete(false);
    // Delete the term root
    Classifier classRootTerm = TermConverter.buildIfNotExistdMdBusinessClassifier(this.mdBusiness);
    classRootTerm.delete();
    // roles specified on the super type.
    if (this.getSuperType() == null) {
        Actor ownerActor = this.universal.getOwner();
        if (ownerActor instanceof Roles) {
            Roles ownerRole = (Roles) ownerActor;
            String roleName = ownerRole.getRoleName();
            if (RegistryRole.Type.isOrgRole(roleName)) {
                String organizationCode = RegistryRole.Type.parseOrgCode(roleName);
                String geoObjectTypeCode = this.type.getCode();
                String rmRoleName = RegistryRole.Type.getRM_RoleName(organizationCode, geoObjectTypeCode);
                Roles role = Roles.findRoleByName(rmRoleName);
                role.delete();
                String rcRoleName = RegistryRole.Type.getRC_RoleName(organizationCode, geoObjectTypeCode);
                role = Roles.findRoleByName(rcRoleName);
                role.delete();
                String acRoleName = RegistryRole.Type.getAC_RoleName(organizationCode, geoObjectTypeCode);
                role = Roles.findRoleByName(acRoleName);
                role.delete();
            }
        }
    }
    ListType.markAllAsInvalid(null, this);
    new SearchService().clear(this.getCode());
    new ChangeRequestService().markAllAsInvalid(this);
    // Delete the transition and transition events
    TransitionEvent.removeAll(this);
    Transition.removeAll(this);
}
Also used : InheritedHierarchyAnnotation(net.geoprism.registry.InheritedHierarchyAnnotation) Roles(com.runwaysdk.system.Roles) Classifier(net.geoprism.ontology.Classifier) TypeInUseException(net.geoprism.registry.TypeInUseException) ChangeRequestService(net.geoprism.registry.service.ChangeRequestService) Actor(com.runwaysdk.system.Actor) SearchService(net.geoprism.registry.service.SearchService) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 3 with Actor

use of com.runwaysdk.system.Actor in project geoprism-registry by terraframe.

the class ServerGeoObjectType method getOrganization.

/**
 * @return The organization associated with this GeoObjectType.
 */
public Organization getOrganization() {
    Actor owner = this.universal.getOwner();
    if (!(owner instanceof Roles)) {
        // If we get here, then the GeoObjectType was not created
        return null;
    // correctly.
    } else {
        Roles uniRole = (Roles) owner;
        String myOrgCode = RegistryRole.Type.parseOrgCode(uniRole.getRoleName());
        return Organization.getByCode(myOrgCode);
    }
}
Also used : Actor(com.runwaysdk.system.Actor) Roles(com.runwaysdk.system.Roles)

Aggregations

Actor (com.runwaysdk.system.Actor)3 Roles (com.runwaysdk.system.Roles)3 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 SingleActor (com.runwaysdk.system.SingleActor)1 Classifier (net.geoprism.ontology.Classifier)1 InheritedHierarchyAnnotation (net.geoprism.registry.InheritedHierarchyAnnotation)1 TypeInUseException (net.geoprism.registry.TypeInUseException)1 ChangeRequestService (net.geoprism.registry.service.ChangeRequestService)1 SearchService (net.geoprism.registry.service.SearchService)1