Package lupos.datastructures.items

Examples of lupos.datastructures.items.Triple


      }
    }
   
    long timestamp = System.currentTimeMillis() / 1000;
    Literal obj = Literals.createTyped(timestamp+"", Literals.XSD.LONG);
    Triple timestampTriple = new Triple(triples.get(0).getSubject(), this.TIMESTAMP_LITERAL, obj);
   
    List<Triple> triples2 = new ArrayList<Triple>(triples);
    triples2.add(timestampTriple);
    return triples2;
  }
View Full Code Here


        // String from_user = jsonObj.getString("from_user");
        String text = jsonObj.getString("text");

        Literal subject = LiteralFactory.createAnonymousLiteral("<"+id+">");

        triples.add(new Triple(subject, Literals.RDF.TYPE, this.TWEET_TYPE_OBJECT));
        triples.add(new Triple(subject, this.TEXT_PREDICATE, LiteralFactory.createStringLiteral("\""+Utils.escape(text)+"\"")));
        triples.add(new Triple(subject, this.ID_PREDICATE, LiteralFactory.createTypedLiteral("\""+id+"\"", Literals.XSD.LONG)));
       
        result.add(triples);
      }     
      return result;     
    } catch (Exception e) {
View Full Code Here

      // -deserialize the triples and make subjects unique
      // -das type-Tripel wird als letztes eingespeist
      Literal subject = LiteralFactory.createAnonymousLiteral("_:broker"+this.running_number);
      this.running_number++;
      System.out.println(subject);
      Triple typeTriple = null;
      for(SerializedTriple st : stl) {
        Triple t = st.getTriple();       
        Triple nt = new Triple(subject, t.getPredicate(), t.getObject());
        //System.out.println("B:" + nt);
       
        if(nt.getPredicate().compareToNotNecessarilySPARQLSpecificationConform(Literals.RDF.TYPE) == 0) {
          typeTriple = nt;
        } else {
          consumeForAllStreams(nt);
        }
      }
View Full Code Here

      List<SerializedTriple> stl = (List<SerializedTriple>)msg;
           
      // -deserialize the triples and make subjects unique
      // -das type-Tripel wird als letztes eingespeist
      Literal subject = LiteralFactory.createAnonymousLiteral("_:subj"+UUID.randomUUID());
      Triple typeTriple = null;
      for(SerializedTriple st : stl) {
        Triple t = st.getTriple();       
        Triple nt = new Triple(subject, t.getPredicate(), t.getObject());
       
        // if this triplet contains the event type, then
        // it might be added as a new BProducer
        // and is forwarded to appropriate sub brokers
        if (t.getPredicate().getName().equals("<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>")){
          // first check, if this message came from a producer
          // which means that its connection info is not null
          if (service.getConnectionInfo() != null){
            // add a new BProducer, which only does show effect if
            // this specific BProducer did not already exist
            this.bModel.addBProducer(new BProducer(t.getObject().getName(), service.getConnectionInfo()));
           
            // now just forward this message
            if (this.forwardingTable != null){
              List<TcpConnectInfo> forwardAdresses = this.forwardingTable.get(t.getObject().getName());
              if (forwardAdresses != null){
                for (TcpConnectInfo con : forwardAdresses){
                  if (!service.getConnectionInfo().equals(con)){
                    try {
                      this.connectionTable.get(con).sendMessage(msg);
                      System.out.println("Forwarded message of type "+t.getObject().getName()+" to "+con.getHost()+":"+con.getPort());
                    } catch (IOException e) {
                      e.printStackTrace();
                    }
                  }
                }
              }
            }
          }
        }
       
        //System.out.println("B:" + nt);
       
        if(nt.getPredicate().compareToNotNecessarilySPARQLSpecificationConform(Literals.RDF.TYPE) == 0) {
          typeTriple = nt;
        } else {
          consumeForAllStreams(nt);
        }
      }
View Full Code Here

    try {     
      Literal s = LazyLiteral.getLiteral(this.subjectStr);
      Literal p = LazyLiteral.getLiteral(this.predicateStr);
      Literal o = LazyLiteral.getLiteral(this.objectStr);
      return new Triple(s, p, o);
   
    } catch(Exception ex) {
      System.err.println(ex);
      ex.printStackTrace();
    }
View Full Code Here

  }
 
  @Override
  public List<List<Triple>> produce() {
    List<Triple> triples = new ArrayList<Triple>();
    triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Literals.RDF.TYPE, EmptyProducer.TYPE));
    return ProducerBase.fold(triples);
  }
View Full Code Here

        } else {
          type = LazyLiteral.getLiteral(chosenEvent);
        }
     
        // add triples of the chosen event to triples
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Literals.RDF.TYPE, type));     
     
        /**
         * Gets all components from the predicatePanel and checks the validity.
         */
        for(Component component: predicatePanel.getComponents()){
          if(component instanceof PredObjPanel){
            PredObjPanel pop = (PredObjPanel) component;
           
            Literal s = null;
            Literal k = null;

            // check if predicates in valid format
            try {
              s = this.getLiteral(pop.predTF.getText());
            } catch (ParseException e1) {
              System.err.println("Invalid Predicate!");
            }

            // check if objects in valid format
            try {
              k = this.getLiteral(pop.objTF.getText());
            } catch (ParseException e2) {
              System.err.println("Invalid Object!");
            }

            // checks if one of the predicates or objects was null
            if (s == null || k == null) {
             
              // error
              error = true;
              // open Error-Massage-Window
              JOptionPane.showMessageDialog(timePanel,
                  "Please select valid predicates and objects! "
                      + "\n"
                      + "(In format <predicate> <object>)",
                  "Wrong Predicate/Object",
                  JOptionPane.ERROR_MESSAGE, null);
              break;

            } else {
              // creates new triple from the Literals and adds them to triples
              triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, LazyLiteral.getLiteral(pop.predTF.getText()), LazyLiteral.getLiteral(pop.objTF.getText())));
            }
          }
        }
       
        // returns the triples in the console
View Full Code Here

      } else
        obj = LiteralFactory
            .createLiteral("\"" + lit.getLabel() + "\"");
    } else
      System.err.println("Unknown type of data: " + object.getClass());
    return new Triple(subj, pred, obj);
  }
View Full Code Here

    List<Triple> triples = new ArrayList<Triple>();

    try {
      Literal subj = LiteralFactory.createAnonymousLiteral("_:t"
          + meal.id);
      triples.add(new Triple(subj, Literals.RDF.TYPE, TYPE));

      Literal obj;
      obj = LiteralFactory.createLiteral("\"" + meal.name + "\"");
      triples.add(new Triple(subj, NAME, obj));

      obj = LiteralFactory.createLiteral("\"" + meal.price + "\"");
      triples.add(new Triple(subj, PRICE, obj));
    } catch (Exception e) {
      e.printStackTrace();
    }

    return triples;
View Full Code Here

        final Literal sunsetHourObject = Literals.createTyped(sunsetHourValue, Literals.XSD.DECIMAL);
        final Literal sunsetMinuteObject = Literals.createTyped(sunsetMinuteValue, Literals.XSD.DECIMAL);
       
 
        // Adds triples (subject, predicate, object) to the array list
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Literals.RDF.TYPE, Predicates.TYPE));
       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.PERCENT_ILLUMINATED, percentIlluminatedObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.AGE_OF_MOON, ageOfMoonObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.CURRENT_HOUR, currentHourObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.CURRENT_MINUTE, currentMinuteObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.SUNRISE_HOUR, sunriseHourObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.SUNRISE_MINUTE, sunriseMinuteObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.SUNSET_HOUR, sunsetHourObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.SUNSET_MINUTE, sunsetMinuteObject));
       
        // returns the array list with all the requested information
        return ProducerBase.fold(triples);

    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of lupos.datastructures.items.Triple

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.