コード例 #1
0
ファイル: Dependency.java プロジェクト: saumishr/wings
 public boolean checkDependency(KBAPI api, KBObject obj) {
   for (String propId : propertyIdChain) {
     KBObject prop = api.getProperty(propId);
     obj = api.getPropertyValue(obj, prop);
     if (obj == null) break;
   }
   if (obj == null) return false;
   if (!obj.isLiteral()) {
     if (this.operator == Operator.EQUAL && obj.getID().equals(this.desiredValue)) return true;
   } else {
     if (this.operator == Operator.EQUAL && obj.getValue().equals(this.desiredValue)) return true;
     if (this.operator == Operator.GREATER_THAN
         && Double.parseDouble(obj.getValue().toString())
             > Double.parseDouble(this.desiredValue.toString())) return true;
     if (this.operator == Operator.LESS_THAN
         && Double.parseDouble(obj.getValue().toString())
             < Double.parseDouble(this.desiredValue.toString())) return true;
   }
   return false;
 }
コード例 #2
0
ファイル: TemplateCreationKB.java プロジェクト: saro21/wings
  @Override
  public void copyFrom(TemplateCreationAPI tc) {
    TemplateCreationKB tckb = (TemplateCreationKB) tc;

    this.writerkb.copyFrom(tckb.writerkb);

    KBUtils.renameTripleNamespace(this.writerkb, tckb.wflowns, this.wflowns);
    KBUtils.renameAllTriplesWith(this.writerkb, tckb.onturl, this.onturl, false);
    KBUtils.renameAllTriplesWith(this.writerkb, tckb.liburl, this.liburl, false);

    for (String tplid : tckb.getTemplateList()) {
      // Load and save the template in the latest format
      TemplateKB tpl = (TemplateKB) tckb.getTemplate(tplid);
      tpl.save();

      String ntplid = tplid.replace(tckb.wdirurl, this.wdirurl);
      String tplurl = tplid.replaceAll("#.*$", "");
      String ntplurl = tplurl.replace(tckb.wdirurl, this.wdirurl);
      try {
        KBAPI ntplkb = this.ontologyFactory.getKB(ntplurl, OntSpec.PLAIN);
        ntplkb.copyFrom(tpl.getKBCopy(true));
        KBUtils.renameTripleNamespace(ntplkb, tckb.wflowns, this.wflowns);
        KBUtils.renameTripleNamespace(ntplkb, tckb.dcdomns, this.dcdomns);
        KBUtils.renameTripleNamespace(ntplkb, tckb.dclibns, this.dclibns);
        KBUtils.renameTripleNamespace(ntplkb, tckb.pcdomns, this.pcdomns);

        KBUtils.renameTripleNamespace(ntplkb, tplurl + "#", ntplurl + "#");
        KBUtils.renameAllTriplesWith(ntplkb, tplurl, ntplurl, false);
        KBUtils.renameAllTriplesWith(ntplkb, tckb.onturl, this.onturl, false);
        KBUtils.renameAllTriplesWith(ntplkb, tckb.liburl, this.liburl, false);
        ntplkb.save();
      } catch (Exception e) {
        e.printStackTrace();
      }
      KBUtils.renameAllTriplesWith(this.writerkb, tplid, ntplid, false);
    }

    writerkb.save();

    this.initializeAPI(true);
  }