Ejemplo n.º 1
0
  @Override
  public boolean removeDatatype(String dtypeid) {
    KBObject cls = this.kb.getConcept(dtypeid);
    // Remove all files
    ArrayList<KBObject> files = this.kb.getInstancesOfClass(cls, true);
    for (KBObject file : files) {
      this.removeData(file.getID());
    }
    // Remove metadata properties
    ArrayList<KBObject> props = this.kb.getPropertiesOfClass(cls, false);
    for (KBObject prop : props) {
      MetadataProperty mprop = this.getMetadataProperty(prop.getID());
      if (mprop.getDomains().contains(dtypeid)) {
        if (mprop.getDomains().size() > 1) this.removeMetadataPropertyDomain(prop.getID(), dtypeid);
        else this.removeMetadataProperty(prop.getID());
      }
    }
    // Remove all subclasses (recursive call)
    ArrayList<KBObject> subclses = this.kb.getSubClasses(cls, true);
    for (KBObject subcls : subclses) {
      if (!subcls.isNothing()) this.removeDatatype(subcls.getID());
    }
    // Finally remove the class itself
    KBUtils.removeAllTriplesWith(this.ontkb, dtypeid, false);

    if (this.externalCatalog != null) this.externalCatalog.removeDatatype(dtypeid);
    return true;
  }
Ejemplo n.º 2
0
  @Override
  public boolean removeMetadataProperty(String propid) {
    // Remove all domains manually
    // - Due to bug in removing triples with union classes
    MetadataProperty prop = this.getMetadataProperty(propid);
    for (String domid : prop.getDomains())
      this.ontkb.removePropertyDomainDisjunctive(propid, domid);

    // Remove all triples (this skips removing domain union classes)
    KBUtils.removeAllTriplesWith(this.ontkb, propid, true);
    KBUtils.removeAllTriplesWith(this.libkb, propid, true);
    if (this.externalCatalog != null) this.externalCatalog.removeMetadataProperty(propid);
    return true;
  }
Ejemplo n.º 3
0
  @Override
  public boolean renameMetadataProperty(String oldid, String newid) {
    // First remove all domains and then readd them later
    // - Due to bug in renaming triples
    MetadataProperty prop = this.getMetadataProperty(oldid);
    for (String domid : prop.getDomains()) this.ontkb.removePropertyDomainDisjunctive(oldid, domid);

    // Rename all triples (this skips renaming domain union classes)
    KBUtils.renameAllTriplesWith(this.ontkb, oldid, newid, true);
    KBUtils.renameAllTriplesWith(this.libkb, oldid, newid, true);

    for (String domid : prop.getDomains()) this.ontkb.addPropertyDomainDisjunctive(newid, domid);
    if (this.externalCatalog != null) this.externalCatalog.renameMetadataProperty(oldid, newid);
    return true;
  }
Ejemplo n.º 4
0
  private MetadataProperty createMetadataProperty(KBObject property) {
    if (property == null) return null;
    int proptype =
        this.kb.isDatatypeProperty(property) ? MetadataProperty.DATATYPE : MetadataProperty.OBJECT;
    MetadataProperty prop = new MetadataProperty(property.getID(), proptype);

    // Query for domain and range from the non-inference ontkb model (otherwise we get inferenced
    // domains as well)
    ArrayList<KBObject> domains = this.ontkb.getPropertyDomainsDisjunctive(property);
    KBObject range = this.ontkb.getPropertyRange(property);
    for (KBObject domain : domains) prop.addDomain(domain.getID());
    if (range != null) {
      prop.setRange(range.getID());
    }
    return prop;
  }