Example #1
0
 @Override
 public void initResource() {
   applicationEntity = model.createResource(baseuri + this.dto.get_uri());
   parentResource = model.createResource(baseuri + "/" + Utils.getParentURI(this.dto.get_uri()));
   resourceName = dto.getRn();
   resourceId = dto.getRi();
   if (dto.getLbl() != null) {
     for (int i = 0; i < dto.getLbl().length; i++) {
       label = label + "," + dto.getLbl()[i];
     }
   } else {
     label = "";
   }
   ontologyReference = this.dto.getOr();
 }
Example #2
0
  @Override
  public List<Statement> from() {
    initResource();
    // Container type
    Statement stmtType =
        model.createStatement(
            applicationEntity, RDF.type, model.createResource(baseuri + "/m2m/ApplicationEntity"));
    slist.add(stmtType);

    // Ontology Reference Type
    if (dto.getOr() != null) {
      Statement stmtType2 =
          model.createStatement(
              applicationEntity, RDF.type, model.createResource(ontologyReference));
      slist.add(stmtType2);
    }

    // name
    Statement stmtName =
        model.createStatement(
            applicationEntity, model.createProperty(baseuri + "/m2m/resourceName"), resourceName);
    slist.add(stmtName);

    // parent resource
    Statement stmtParentResource =
        model.createStatement(
            applicationEntity,
            model.createProperty(baseuri + "/m2m/hasParentResource"),
            parentResource);
    slist.add(stmtParentResource);

    // parent isResourceOf
    Statement stmtIsAEOf =
        model.createStatement(
            applicationEntity,
            model.createProperty(baseuri + "/m2m/isApplicationEntityOf"),
            parentResource);
    slist.add(stmtIsAEOf);

    // parent resource
    Statement stmtResourceOf =
        model.createStatement(
            applicationEntity,
            model.createProperty(baseuri + "/m2m/isApplicationEntityOf"),
            parentResource);
    slist.add(stmtResourceOf);

    // label
    Statement stmtLabel = model.createStatement(applicationEntity, RDFS.label, label);
    slist.add(stmtLabel);

    // createtime xsd datetime
    SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    Calendar cal1 = Calendar.getInstance();
    try {
      cal1.setTime(sd.parse(StrUtils.makeXsdDateFromOnem2mDate(this.dto.getCt())));
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    Statement stmtCreateTime =
        model.createStatement(
            applicationEntity,
            model.createProperty(baseuri + "/m2m/hasCreateDate"),
            model.createTypedLiteral(cal1));
    slist.add(stmtCreateTime);

    // last modified time
    Calendar cal2 = Calendar.getInstance();
    try {
      cal2.setTime(sd.parse(StrUtils.makeXsdDateFromOnem2mDate(this.dto.getLt())));
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    Statement stmtLastModifiedTime =
        model.createStatement(
            applicationEntity,
            model.createProperty(baseuri + "/m2m/hasLastModifiedDate"),
            model.createTypedLiteral(cal2));
    slist.add(stmtLastModifiedTime);

    // resourceid
    Statement stmtResourceId =
        model.createStatement(
            applicationEntity, model.createProperty(baseuri + "/m2m/hasResourceId"), resourceId);
    slist.add(stmtResourceId);

    // pointofaccess
    if (dto.getPoa().length != 0) {
      for (int i = 0; i < dto.getPoa().length; i++) {
        slist.add(
            model.createStatement(
                applicationEntity,
                model.createProperty(baseuri + "/m2m/hasPointOfAccess"),
                model.createResource(dto.getPoa()[i])));
      }
    }

    // announce attribute
    if (dto.getAa().length != 0) {
      for (int i = 0; i < dto.getAa().length; i++) {
        slist.add(
            model.createStatement(
                applicationEntity,
                model.createProperty(baseuri + "/m2m/hasAnnounceTo"),
                model.createResource(dto.getAa()[i])));
      }
    }
    // announce to
    if (dto.getAt().length != 0) {
      for (int i = 0; i < dto.getAt().length; i++) {
        slist.add(
            model.createStatement(
                applicationEntity,
                model.createProperty(baseuri + "/m2m/hasAnnounceAttribute"),
                model.createResource(dto.getAt()[i])));
      }
    }

    // appname
    Statement appname =
        model.createStatement(
            applicationEntity,
            model.createProperty(baseuri + "/m2m/resourceName"),
            model.createResource(dto.getApn()));
    slist.add(appname);
    // appid
    Statement appid =
        model.createStatement(
            applicationEntity,
            model.createProperty(baseuri + "/m2m/hasAppID"),
            model.createResource(dto.getApi()));
    slist.add(appid);

    // aeid
    Statement aeid =
        model.createStatement(
            applicationEntity,
            model.createProperty(baseuri + "/m2m/hasApplicationEntityID"),
            model.createResource(dto.getApi()));
    slist.add(aeid);

    slist.add(stmtResourceId);
    return slist;
  }