コード例 #1
0
 @Override
 public void setProperty(String name, Object value, Authorizations authorizations) {
   if (OntologyProperties.DISPLAY_NAME.getPropertyName().equals(name)) {
     this.displayName = (String) value;
   } else if (OntologyProperties.TITLE_FORMULA.getPropertyName().equals(name)) {
     this.titleFormula = (String) value;
   } else if (OntologyProperties.SUBTITLE_FORMULA.getPropertyName().equals(name)) {
     this.subtitleFormula = (String) value;
   } else if (OntologyProperties.TIME_FORMULA.getPropertyName().equals(name)) {
     this.timeFormula = (String) value;
   } else if (OntologyProperties.USER_VISIBLE.getPropertyName().equals(name)) {
     this.userVisible = (Boolean) value;
   }
 }
コード例 #2
0
  @Handle
  public void handle(
      @Required(name = "concept") String conceptIRI,
      @Required(name = "displayName") String displayName,
      @Required(name = "color") String color,
      @Required(name = "displayType") String displayType,
      @Required(name = "titleFormula") String titleFormula,
      @Required(name = "subtitleFormula") String subtitleFormula,
      @Required(name = "timeFormula") String timeFormula,
      @Required(name = "addRelatedConceptWhiteList[]") String[] addRelatedConceptWhiteListArg,
      @Required(name = "intents[]") String[] intents,
      @Optional(name = "searchable", defaultValue = "true") boolean searchable,
      @Optional(name = "addable", defaultValue = "true") boolean addable,
      @Optional(name = "userVisible", defaultValue = "true") boolean userVisible,
      User user,
      Authorizations authorizations,
      VisalloResponse response)
      throws Exception {
    HashSet<String> addRelatedConceptWhiteList =
        new HashSet<>(Arrays.asList(addRelatedConceptWhiteListArg));

    Concept concept = ontologyRepository.getConceptByIRI(conceptIRI);
    if (concept == null) {
      response.respondWithNotFound("concept " + conceptIRI + " not found");
      return;
    }

    if (displayName.length() != 0) {
      concept.setProperty(
          OntologyProperties.DISPLAY_NAME.getPropertyName(), displayName, authorizations);
    }

    if (color.length() != 0) {
      concept.setProperty(OntologyProperties.COLOR.getPropertyName(), color, authorizations);
    }

    JSONArray whiteList = new JSONArray();
    for (String whitelistIri : addRelatedConceptWhiteList) {
      whiteList.put(whitelistIri);
    }
    concept.setProperty(
        OntologyProperties.ADD_RELATED_CONCEPT_WHITE_LIST.getPropertyName(),
        whiteList.toString(),
        authorizations);

    concept.setProperty(
        OntologyProperties.DISPLAY_TYPE.getPropertyName(), displayType, authorizations);
    concept.setProperty(
        OntologyProperties.SEARCHABLE.getPropertyName(), searchable, authorizations);
    concept.setProperty(OntologyProperties.ADDABLE.getPropertyName(), addable, authorizations);
    concept.setProperty(
        OntologyProperties.USER_VISIBLE.getPropertyName(), userVisible, authorizations);

    if (titleFormula.length() != 0) {
      concept.setProperty(
          OntologyProperties.TITLE_FORMULA.getPropertyName(), titleFormula, authorizations);
    } else {
      concept.removeProperty(OntologyProperties.TITLE_FORMULA.getPropertyName(), authorizations);
    }

    if (subtitleFormula.length() != 0) {
      concept.setProperty(
          OntologyProperties.SUBTITLE_FORMULA.getPropertyName(), subtitleFormula, authorizations);
    } else {
      concept.removeProperty(OntologyProperties.SUBTITLE_FORMULA.getPropertyName(), authorizations);
    }

    if (timeFormula.length() != 0) {
      concept.setProperty(
          OntologyProperties.TIME_FORMULA.getPropertyName(), timeFormula, authorizations);
    } else {
      concept.removeProperty(OntologyProperties.TIME_FORMULA.getPropertyName(), authorizations);
    }

    concept.updateIntents(StringArrayUtil.removeNullOrEmptyElements(intents), authorizations);

    ontologyRepository.clearCache();

    response.respondWithSuccessJson();
  }