Beispiel #1
0
 private OWLObjectPropertyCondition getStopExpansionCondition() {
   Set<OWLObjectProperty> stopExpansionProps = new HashSet<OWLObjectProperty>();
   stopExpansionProps.add(OWL.objectProperty(DEFAULT_STOP_EXPANSION_CONDITION_IRI1));
   stopExpansionProps.add(OWL.objectProperty(DEFAULT_STOP_EXPANSION_CONDITION_IRI2));
   stopExpansionProps.add(OWL.objectProperty(DEFAULT_STOP_EXPANSION_CONDITION_IRI3));
   stopExpansionProps.add(OWL.objectProperty(DEFAULT_STOP_EXPANSION_CONDITION_IRI4));
   return new OWLObjectPropertyCondition(stopExpansionProps);
 }
 /**
  * Finds all individuals where more than one type is asserted, which is disallowed by Cirm team
  * convention. Except: Protected is allowed as second class, but will still be returned from this
  * method.
  *
  * @return
  */
 public List<Pair<OWLNamedIndividual, Set<OWLClassExpression>>>
     getIndividualsWithMoreThanOneTypeAsserted() {
   List<Pair<OWLNamedIndividual, Set<OWLClassExpression>>> errors =
       new LinkedList<Pair<OWLNamedIndividual, Set<OWLClassExpression>>>();
   if (DBG)
     System.out.println("Start CirmOntologyValidator::getIndividualsWithMoreThanOneTypeAsserted");
   Set<OWLOntology> owlOntologies = OWL.ontologies();
   for (OWLOntology owlOntology : owlOntologies) {
     if (DBG) System.out.println("Getting individuals in signature of Ontology " + owlOntology);
     Set<OWLNamedIndividual> s = owlOntology.getIndividualsInSignature(false);
     if (DBG) System.out.println("...done.");
     for (OWLNamedIndividual owlNamedIndividual : s) {
       Set<OWLClassExpression> types = owlNamedIndividual.getTypes(owlOntologies);
       if (types.size() > 1) {
         Pair<OWLNamedIndividual, Set<OWLClassExpression>> error =
             new Pair<OWLNamedIndividual, Set<OWLClassExpression>>(owlNamedIndividual, types);
         errors.add(error);
         if (DBG) {
           System.out.println("Found " + types.size() + " types for " + owlNamedIndividual);
           for (OWLClassExpression owlClassExpression : types) {
             System.out.println(owlClassExpression);
           }
         }
       }
     } // for (OWLNamedIndividual
   } // for (OWLOntology
   if (DBG) System.out.println("Total Individuals not passing validation: " + errors.size());
   return errors;
 }
Beispiel #3
0
 private Json getAccessPolicies(Json groups) {
   if (!groups.isArray())
     throw new IllegalArgumentException("Expected Array of cirmusergroups. e.g. legacy:311..");
   Json cirmUserGroupsWithAccessPolicies = Json.array();
   for (Json iri : groups.asJsonList()) {
     OWLIndividual group = dataFactory().getOWLNamedIndividual(fullIri(iri.asString()));
     // Here we need to make sure that the serialization stops at e.g.
     // individuals that are the objects of an AccessPolicy!
     Json groupWithAccessPolicies = OWL.toJSON(group, stopExpansionCondition);
     cirmUserGroupsWithAccessPolicies.add(groupWithAccessPolicies);
   }
   // Array of cirm groups with all access policy information serialized.
   return cirmUserGroupsWithAccessPolicies; // userdata.set("cirmusergroups",
                                            // cirmUserGroupsWithAccessPolicies);
 }
Beispiel #4
0
  @Override
  public String resolve(String variableName, Json sr, Properties properties) {
    String activityLegacyCode;

    OWLLiteral variableLegacyCode =
        OWL.dataProperty(
            MessageManager.findIndividualFromVariable(variableName), "legacy:hasLegacyCode");
    if (variableLegacyCode != null && variableLegacyCode.getLiteral().length() > 0)
      activityLegacyCode =
          variableLegacyCode
              .getLiteral(); // look for a specific activity as defined with the variable
    else activityLegacyCode = properties.getProperty("LEGACY_CODE");
    Json activity = SRJsonActivityUtil.getMostRecentActivityByLegacyCode(sr, activityLegacyCode);
    if (activity == null || activity.isNull()) {
      System.out.println(
          "Messaging - ActivityResolver: unable to find activity "
              + properties.getProperty("LEGACY_CODE")
              + " in SR "
              + sr);
      return null;
    }
    String result = null;
    if (VAR_SR_ACTIVITY_TYPE.equals(variableName))
      result = SRJsonActivityUtil.getActivityTypeLabel(activity);
    else {
      if (variableName.contains("_OUTCOME")) {
        result = SRJsonActivityUtil.getHasOutcomeLabel(activity);
      } else if (variableName.contains("_DETAILS") || variableName.contains("_DTLS$$")) {
        result = SRJsonActivityUtil.getHasDetails(activity);
      } else if (variableName.contains("_DUE_DTE")) {
        result = SRJsonActivityUtil.getHasDueDate(activity, DATE_PATTERN);
      } else if (variableName.equals("$$SR_ACTIVITY_DATE_TIME$$")) {
        result = SRJsonActivityUtil.getHasDateCreated(activity, DATE_PATTERN);
      } else if (variableName.equals("$$SR_ACTIVITY_DUEDATE_SWR$$")) {
        result = SRJsonActivityUtil.getDueDate90Days(activity, DATE_PATTERN);
      } else if (variableName.contains("SR_ACTIVITY_CALLCREATED_D")) {
        result = SRJsonActivityUtil.getIsCreatedByName(activity);
      } else if (variableName.equals("$$SR_ASSIGNED_STAFF$$")) {
        result = SRJsonActivityUtil.getAssignedStaffName(activity);
      } else {
        System.out.println(
            "Messaging - ActivityResolver: unable to resolve variable" + variableName);
      }
      // Just a check if we already know the variable.
      if (VALIDATE_VARS_POST_RESOLUTION && !ActivityVariableValidator.isKnown(variableName))
        System.err.println(
            "ActivityResolver resolved an unknown variable: "
                + variableName
                + " to value "
                + result);
    }
    if (DBG) {
      System.out.println(
          "ActivityResolver: Var "
              + variableName
              + " Result: "
              + result
              + " Act: "
              + activity
              + " Code: "
              + activityLegacyCode);
    }
    return result;
  }
Beispiel #5
0
 public UserService() {
   autoConfigure(Refs.owlJsonCache.resolve().individual(OWL.fullIri("UserService")).resolve());
 }