public void visit(OWLDataAllValuesFrom object) {
      // if the filler is the negation of a supported range then we will leave the expression as if
      // it was in the head,
      // because when we overapproximate we are only going to look at the property so there's no
      // point in decomposing it further
      // if the filler is positive, however, we will decompose it a bit
      LiteralDataRange literalRange = m_dataRangeConverter.convertDataRange(object.getFiller());
      if (object.getProperty().isOWLTopDataProperty()) {
        if (literalRange.isAlwaysFalse()) return; // bottom
      }

      Variable y = nextY();
      m_bodyAtoms.add(getRoleAtom(object.getProperty(), X, y));
      if (literalRange.isNegatedInternalDatatype()) {
        InternalDatatype negatedRange = (InternalDatatype) literalRange.getNegation();
        if (!negatedRange.isAlwaysTrue()) m_bodyAtoms.add(Atom.create(negatedRange, y));
      } else {
        if (!literalRange.isAlwaysFalse()) {
          if (object.getFiller() instanceof OWLDataOneOf) {
            for (OWLLiteral lit : ((OWLDataOneOf) object.getFiller()).getValues())
              m_headAtoms.add(
                  Atom.create(Equality.INSTANCE, y, (Constant) lit.accept(m_dataRangeConverter)));
          } else m_headAtoms.add(Atom.create((DLPredicate) literalRange, y));
        }
      }
    }
 protected boolean isNonNegativeIntegerLax(IRI mainNode, OWLRDFVocabulary predicate) {
   OWLLiteral literal = consumer.getLiteralObject(mainNode, predicate, false);
   if (literal == null) {
     return false;
   }
   return OWL2Datatype.XSD_INTEGER.isInLexicalSpace(literal.getLiteral().trim());
 }
Esempio n. 3
0
  public static boolean isDeprecated(OWLModelManager p4Manager, OWLObject o) {
    if (!(o instanceof OWLEntity)) {
      return false;
    }
    for (OWLOntology ontology : p4Manager.getActiveOntologies()) {
      for (OWLAnnotationAssertionAxiom assertion :
          ontology.getAnnotationAssertionAxioms(((OWLEntity) o).getIRI())) {

        if (!assertion.getProperty().isDeprecated()) {
          continue;
        }
        if (!(assertion.getValue() instanceof OWLLiteral)) {
          continue;
        }
        OWLLiteral value = (OWLLiteral) assertion.getValue();
        if (!value.isBoolean()) {
          continue;
        }
        if (value.parseBoolean()) {
          return true;
        }
      }
    }
    return false;
  }
Esempio n. 4
0
 @Override
 public void visit(OWLLiteral node) {
   write("\"");
   write(node.getLiteral());
   write("\"\\^\\^");
   write(node.getDatatype().getIRI());
 }
 public static String getLabel(OWLOntology o, OWLEntity owlEntity) {
   for (OWLAnnotation annotation : owlEntity.getAnnotations(o)) {
     if (annotation.getProperty().isLabel()) {
       OWLLiteral value = (OWLLiteral) annotation.getValue();
       return value.getLiteral();
     }
   }
   return owlEntity.getIRI().toString();
 }
 @Override
 protected int compareObjectOfSameType(OWLObject object) {
   OWLLiteral other = (OWLLiteral) object;
   int diff = getLiteral().compareTo(other.getLiteral());
   if (diff != 0) {
     return diff;
   }
   return datatype.compareTo(other.getDatatype());
 }
 protected boolean isNonNegativeIntegerStrict(IRI mainNode, OWLRDFVocabulary predicate) {
   OWLLiteral literal = consumer.getLiteralObject(mainNode, predicate, false);
   if (literal == null) {
     return false;
   }
   OWLDatatype datatype = literal.getDatatype();
   OWL2Datatype nni = OWL2Datatype.XSD_NON_NEGATIVE_INTEGER;
   return datatype.getIRI().equals(nni.getIRI()) && nni.isInLexicalSpace(literal.getLiteral());
 }
 private String getAnnotationValueByUri(OWLOntology o, OWLEntity owlEntity, String uri) {
   for (OWLAnnotation annotation : owlEntity.getAnnotations(o)) {
     if (annotation.getProperty().getIRI().toString().equals(uri)) {
       OWLLiteral value = (OWLLiteral) annotation.getValue();
       return value.getLiteral();
     }
   }
   return null;
 }
 @Override
 public void visit(OWLLiteral node) {
   node.getDatatype().accept(this);
   OWLDatatype dt = (OWLDatatype) obj;
   if (node.hasLang()) {
     obj = dataFactory.getOWLLiteral(node.getLiteral(), node.getLang());
   } else {
     obj = dataFactory.getOWLLiteral(node.getLiteral(), dt);
   }
 }
Esempio n. 10
0
  /** Adds Data Properties to the list. */
  public void addDataPropertiesByPredicateType(String predicateURI, OWLNamedIndividual ind) {
    OWLDataProperty dataProp =
        PROVGraph.manager.getOWLDataFactory().getOWLDataProperty(IRI.create(predicateURI));
    Set<OWLLiteral> literals = PROVGraph.reasoner.getDataPropertyValues(ind, dataProp);

    for (OWLLiteral literal : literals) {
      DPconnectionValues.add(literal.getLiteral());
      DPconnections.add(predicateURI);
    }
  }
 /**
  * Translates and consumes the cardinality triple.
  *
  * @param mainNode The main node of the restriction.
  * @return The cardinality of the restriction.
  */
 private int translateCardinality(IRI mainNode) {
   OWLLiteral cardiObject = getLiteralObject(mainNode, getCardinalityTriplePredicate(), true);
   if (cardiObject == null) {
     cardiObject = getLiteralObject(mainNode, getQualifiedCardinalityTriplePredicate(), true);
   }
   if (cardiObject == null) {
     return -1;
   }
   return Integer.parseInt(cardiObject.getLiteral());
 }
 protected int translateInteger(IRI mainNode, OWLRDFVocabulary predicate) {
   OWLLiteral literal = consumer.getLiteralObject(mainNode, predicate, true);
   if (literal == null) {
     return 0;
   }
   try {
     return Integer.parseInt(literal.getLiteral().trim());
   } catch (NumberFormatException e) {
     return 0;
   }
 }
Esempio n. 13
0
 public boolean equals(Object obj) {
   if (super.equals(obj)) {
     if (!(obj instanceof OWLLiteral)) {
       return false;
     }
     OWLLiteral other = (OWLLiteral) obj;
     return literal.equals(other.getLiteral())
         && datatype.equals(other.getDatatype())
         && lang.equals(other.getLang());
   }
   return false;
 }
 protected ArrayList<PossibleValueType> getAnnotationValuesByUri(
     OWLOntology o, OWLEntity owlEntity, String uri) {
   ArrayList<PossibleValueType> possibleValueTypes = new ArrayList<PossibleValueType>();
   for (OWLAnnotation annotation : owlEntity.getAnnotations(o)) {
     if (annotation.getProperty().getIRI().toString().equals(uri)) {
       OWLLiteral value = (OWLLiteral) annotation.getValue();
       String[] possibleValues = value.getLiteral().split(",");
       for (String possibleValue : possibleValues) {
         String[] parsedValue = possibleValue.split(":");
         checkArgument(
             parsedValue.length == 2, "Possible values must be in the format mapping:value");
         possibleValueTypes.add(new PossibleValueType(parsedValue[0], parsedValue[1]));
       }
     }
   }
   return possibleValueTypes;
 }
Esempio n. 15
0
 public String getContinent() {
   HashMap<String, Integer> map = new HashMap<String, Integer>();
   for (String currentCountry : countries) {
     OWLIndividual individual = handler.getIndividual(currentCountry);
     Set<OWLIndividual> individuals = handler.getObjectRelationIndividuals(individual, "liesIn");
     if (individuals == null) return null;
     Iterator<OWLIndividual> it = individuals.iterator();
     if (individuals.iterator().hasNext()) {
       OWLIndividual continent = it.next();
       Set<OWLLiteral> continents = handler.getDataRelationIndividuals(continent, "name");
       Iterator<OWLLiteral> it2 = continents.iterator();
       if (it2.hasNext()) {
         OWLLiteral continentLiteral = it2.next();
         String continentName = continentLiteral.getLiteral();
         addToList(continentName, map);
       }
     }
   }
   return getMostPopular(map);
 }
 @Override
 public OWLLiteral getOWLLiteral(String lexicalValue, OWLDatatype datatype) {
   OWLLiteral literal = super.getOWLLiteral(lexicalValue, datatype);
   // no caches for booleans, they are singleton in owldatafactory
   if (datatype.isBoolean()) {
     return literal;
   }
   if (literal instanceof OWLLiteralImplFloat) {
     return floatCache.cache(((OWLLiteralImplFloat) literal).parseFloat(), literal);
   }
   if (literal instanceof OWLLiteralImplDouble) {
     return doubleCache.cache(((OWLLiteralImplDouble) literal).parseDouble(), literal);
   }
   if (literal instanceof OWLLiteralImplInteger) {
     return intCache.cache(((OWLLiteralImplInteger) literal).parseInteger(), literal);
   }
   if (datatype.isString()) {
     return stringCache.cache(literal.getLiteral(), literal);
   }
   return litCache.cache(literal);
 }
 public void visit(OWLLiteral node) {
   if (preferredLanguages == null
       || preferredLanguages.isEmpty()) { // if there are no languages just match the first thing
     lastLangMatchIndex = 0;
     candidateValue = node;
   } else {
     final int index = preferredLanguages.indexOf(node.getLang());
     if (index >= 0 && index < lastLangMatchIndex) {
       lastLangMatchIndex = index;
       candidateValue = node;
     }
   }
 }
 private void appendTag(
     Paragraph tagParagraph, OWLLiteral literal, Color foreground, boolean isSelected) {
   Color tagColor = isSelected ? foreground : Color.GRAY;
   Color tagValueColor = isSelected ? foreground : Color.GRAY;
   if (literal.hasLang()) {
     tagParagraph.append("[language: ", tagColor);
     tagParagraph.append(literal.getLang(), tagValueColor);
     tagParagraph.append("]", tagColor);
   } else if (datatypeRendering == RENDER_DATATYPE_INLINE && !literal.isRDFPlainLiteral()) {
     tagParagraph.append("[type: ", tagColor);
     tagParagraph.append(
         editorKit.getOWLModelManager().getRendering(literal.getDatatype()), tagValueColor);
     tagParagraph.append("]", tagColor);
   }
   //        if (ontology != null) {
   //            tagParagraph.append("    ", foreground);
   //            tagParagraph.append("[in: ", tagColor);
   //            String ontologyRendering = editorKit.getOWLModelManager().getRendering(ontology);
   //            tagParagraph.append(ontologyRendering, tagColor);
   //            tagParagraph.append("]", tagColor);
   //        }
 }
 /**
  * Renders an annotation value that is an OWLLiteral.
  *
  * @param page The page that the value will be rendered into.
  * @param literal The literal to be rendered.
  * @param foreground The default foreground.
  * @param background The default background.
  * @param isSelected Whether or not the cell containing the annotation value is selected.
  * @return A list of paragraphs that represent the rendering of the literal.
  */
 private List<Paragraph> renderLiteral(
     Page page, OWLLiteral literal, Color foreground, Color background, boolean isSelected) {
   String rendering = EscapeUtils.unescapeString(literal.getLiteral()).trim();
   List<Paragraph> result = new ArrayList<>();
   if (rendering.length() > 0) {
     List<LinkSpan> linkSpans = extractLinks(rendering);
     Paragraph literalParagraph = new Paragraph(rendering, linkSpans);
     literalParagraph.setForeground(foreground);
     page.add(literalParagraph);
     result.add(literalParagraph);
     Paragraph tagParagraph = literalParagraph; // new Paragraph("");
     tagParagraph.append("    ", foreground);
     page.add(tagParagraph);
     result.add(tagParagraph);
     tagParagraph.setMarginTop(2);
     tagParagraph.setTabCount(2);
     //            appendTag(tagParagraph, literal, foreground, isSelected);
   }
   return result;
 }
Esempio n. 20
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;
  }
 public void visit(OWLDataOneOf node) {
   for (OWLLiteral val : node.getValues()) {
     val.accept(this);
   }
 }
 public void visit(OWLLiteral node) {
   node.getDatatype().accept(this);
 }
 @Override
 public void visit(OWLLiteral node) {
   handleObject(node);
   node.getDatatype().accept(this);
 }