Examples of ModelSet


Examples of org.jmol.modelset.ModelSet

  private BitSet compareFloat(int tokWhat, float[] data, int tokOperator,
                              float comparisonFloat) {
    BitSet bs = new BitSet();
    int atomCount = viewer.getAtomCount();
    ModelSet modelSet = viewer.getModelSet();
    Atom[] atoms = modelSet.atoms;
    float propertyFloat = 0;
    viewer.autoCalculate(tokWhat);
    for (int i = atomCount; --i >= 0;) {
      boolean match = false;
View Full Code Here

Examples of org.jmol.modelset.ModelSet

    int propertyValue = Integer.MAX_VALUE;
    BitSet propertyBitSet = null;
    int bitsetComparator = tokOperator;
    int bitsetBaseValue = comparisonValue;
    int atomCount = viewer.getAtomCount();
    ModelSet modelSet = viewer.getModelSet();
    Atom[] atoms = modelSet.atoms;
    int imax = -1;
    int imin = 0;
    int iModel = -1;
    int[] cellRange = null;
    int nOps = 0;
    BitSet bs;
    // preliminary setup
    switch (tokWhat) {
    case Token.symop:
      switch (bitsetComparator) {
      case Token.opGE:
      case Token.opGT:
        imax = Integer.MAX_VALUE;
        break;
      }
      break;
    case Token.atomindex:
      try {
        switch (tokOperator) {
        case Token.opLT:
          return BitSetUtil.newBitSet(0, comparisonValue);
        case Token.opLE:
          return BitSetUtil.newBitSet(0, comparisonValue + 1);
        case Token.opGE:
          return BitSetUtil.newBitSet(comparisonValue, atomCount);
        case Token.opGT:
          return BitSetUtil.newBitSet(comparisonValue + 1, atomCount);
        case Token.opEQ:
          return (comparisonValue < atomCount ? BitSetUtil.newBitSet(
              comparisonValue, comparisonValue + 1) : new BitSet());
        case Token.opNE:
        default:
          bs = BitSetUtil.setAll(atomCount);
          if (comparisonValue >= 0)
            bs.clear(comparisonValue);
          return bs;
        }
      } catch (Exception e) {
        return new BitSet();
      }
    }
    bs = new BitSet(atomCount);
    for (int i = 0; i < atomCount; ++i) {
      boolean match = false;
      Atom atom = atoms[i];
      switch (tokWhat) {
      default:
        propertyValue = Atom.atomPropertyInt(atom, tokWhat);
        break;
      case Token.configuration:
        // these are all-inclusive; no need to do a by-atom comparison
        return BitSetUtil.copy(viewer.getConformation(-1, comparisonValue - 1,
            false));
      case Token.symop:
        propertyBitSet = atom.getAtomSymmetry();
        if (propertyBitSet == null)
          continue;
        if (atom.getModelIndex() != iModel) {
          iModel = atom.getModelIndex();
          cellRange = modelSet.getModelCellRange(iModel);
          nOps = modelSet.getModelSymmetryCount(iModel);
        }
        if (bitsetBaseValue >= 200) {
          if (cellRange == null)
            continue;
          /*
 
View Full Code Here

Examples of org.milyn.javabean.binding.model.ModelSet

        return transformer;
    }

    private static Transformer newXMLBindingTransformer(final QName from, final QName to, Smooks smooks, XMLBindingTransformer.BindingDirection direction) {
        ModelSet beanModel = ModelSet.get(smooks.getApplicationContext());
        if (beanModel != null && !beanModel.getModels().isEmpty()) {
            return new XMLBindingTransformer(from, to, smooks, beanModel, direction);
        } else {
            throw TransformMessages.MESSAGES.invalidBindingConfiguration(direction.toString());
        }
    }
View Full Code Here

Examples of org.ontoware.rdf2go.model.ModelSet

  @Override
  @Test
  public void testSerialize() throws Exception {
    getModelSet().readFrom(TestData.getFoafAsStream(), Syntax.RdfXml);
    String serialize = getModelSet().serialize(Syntax.Nquads);
    ModelSet m1 = getModelFactory().createModelSet();
    m1.open();
    m1.readFrom(new StringReader(serialize), Syntax.Nquads);
    assertEquals(getModelSet().size(), m1.size());
    m1.close();
  }
View Full Code Here

Examples of org.ontoware.rdf2go.model.ModelSet

       
        long statementsChanged = 0;
   
    try
    {
      ModelSet model = DbFace.getModel();
      //LocalService service = SesameServer.getLocalService();
      //LocalRepository repository = (LocalRepository) service.getRepository("foafrealm-rew");
      //Graph graphNew = SesameDbFace.getDbFace(repository).getGraph();
     
      Model modelNew = DbFace.getTempModel();
     
      //- find all uris
      Iterator<Statement> it =  model.findStatements(null,null,null,null);
     
      while (it.hasNext())
      {
        Statement st = it.next();
View Full Code Here

Examples of org.ontoware.rdf2go.model.ModelSet

   * @return
   */
  public static String[] listExistingTags(String uri,ModelSet _model){
    List<String> results = new ArrayList<String>();
     
    ModelSet innerModel = null;
    if(_model!=null) innerModel = _model;
    else innerModel = DbFace.getModel();
   
    ClosableIterator<Statement> res = null;
    try
    {
      res = innerModel.findStatements(null,Variable.ANY, RDFS.seeAlso,new URIImpl(uri));
       
      while(res.hasNext()) {
        WebBookmarkResource wbr = WebBookmarkResource.getWebBookmarkResource((res.next().getSubject()).toString(),innerModel);
        List<String> tags = BookmarksHelper.listTags(wbr.getStringURI());
        for(String tag : tags){
View Full Code Here

Examples of org.ontoware.rdf2go.model.ModelSet

  @SuppressWarnings("unused")
  public static synchronized SscfTagger getSscfTaggerIfExists(String _uri,String _personUri,String _mbox_sha1sum,String typeUri,ModelSet _model)
  {
    //instroduced to have no mess with iterator, as it should be closed.
    boolean exists = false;
    ModelSet innerModel = _model;
    if(innerModel==null) innerModel = DbFace.getModel();
   
    try
    {
      ClosableIterator<Statement> si = innerModel.findStatements(null,new URIImpl(_uri), new URIImpl(S3B_SSCF.isIn), new URIImpl(_personUri));
       
      if(si.hasNext())
      {
        si.close();
        return getSscfTagger(_uri, _personUri, _mbox_sha1sum, typeUri,_model);
View Full Code Here

Examples of org.ontoware.rdf2go.model.ModelSet

   * @return String representation of current user's sioc dir
   */
  public static String getSiocDir(String ownerMbox,ModelSet _model) {
   
    // check if the sioc dir of curent user exists
    ModelSet innerModel = null;
    if(_model!=null) innerModel = _model;
    else innerModel = DbFace.getModel();
   
    try
    {
      QueryResultTable results = innerModel.querySelect(RdfQuery.RDF_GET_USER_SIOC_DIR.toString(
        S3B_SSCF.Directory , dirLabel, ownerMbox),"SPARQL");
      ClosableIterator<QueryRow> it = results.iterator();
      if (it.hasNext()) {
        QueryRow qr = it.next();
        if(qr.getValue(results.getVariables().get(0))!=null)
          return qr.getValue(results.getVariables().get(0)).toString();
      }
    }
    catch (Exception e)
    {
      // ignore
    }
   
    // if the dir does not exist, create it
    //XXX:fix foafrealm!!
    Person person = null;//PersonFactory.getPersonIfExists(new URIImpl(ownerMbox), null,innerModel);
    //if (person == null) {
    //  person = PersonFactory.createPerson(ownerMbox, null,innerModel);
    //}
    BookmarksHelper bh = new BookmarksHelper(dirUri);
    String uri = bh.createResource(dirUri, dirLabel, dirComment, person,true);
   
    try
    {
      innerModel.addStatement(null,innerModel.createURI(uri), innerModel.createURI(S3B_SSCF.isIn), innerModel.createURI(ownerMbox));
    }
    catch (Exception e)
    {
      //if the inserting is failed, removed just created resource
      XfoafSscfResource xfsr = XfoafSscfResource.getXfoafSscfResource(uri,innerModel);
View Full Code Here

Examples of org.ontoware.rdf2go.model.ModelSet

        List<Statement> stToAdd = new ArrayList<Statement>();
        List<Statement> stToRemove = new ArrayList<Statement>();
       
        Map<Resource,String> toChange = new HashMap<Resource,String>();
   
    ModelSet model = DbFace.getModel();
 
    URI type = model.createURI(RDF.type.toString());
    URI webres = model.createURI(S3B_SSCF.WebResource);
    URI seeAlso = RDFS.seeAlso;
   
    //- find all uris
    ClosableIterator<Statement> it =  model.findStatements(null,null, type,webres);
   
    while (it.hasNext())
    {
      Statement st = it.next();
 
      Matcher resource = Pattern.compile("^(.+)#([a-zA-Z0-9]{40})$").matcher(st.getSubject().toString());
     
      if(resource.matches())
      {
        if(resource.group(1)!=null)
        {
          ClosableIterator<Statement> it2 = null;
          try
          {
            it2 = model.findStatements(null,st.getSubject(), seeAlso, null);
           
            while(it2.hasNext())
              if(it2.next().getObject().toString().equals(resource.group(1)))
              {
                String uriStart = resource.group(1);
                if(uriStart.endsWith("/")) uriStart = uriStart.substring(0,uriStart.length()-1);
                String newUri = uriStart+"__"+resource.group(2)
                toChange.put(st.getSubject(),newUri);
              }
          }
          catch (Exception e)
          {
            //
          }
          finally {
            if(it2!=null)
              it2.close();
          }
         
        }
      }
    }
    it.close();
   
    for(Resource res:toChange.keySet())
    {
      try
      {
        stToAdd.clear();
        stToRemove.clear();
       
        //1. get all triples with our subject
        ClosableIterator<Statement> it3 = model.findStatements(null,res, null, null);
       
        //create new uri
        URI newUri = model.createURI(toChange.get(res));
       
        sb.append("* Old URI - ");
        sb.append(res.toString());
        sb.append("<br>* New URI - ");
        sb.append(newUri.toString());
        sb.append("<br>= statements changed: ");
       
       
        while(it3.hasNext())
        {
          Statement st = it3.next();         

          stToAdd.add(new StatementImpl(null,newUri, st.getPredicate(), st.getObject()));
          stToRemove.add(st);
         
          uriStetements++;
        }
        it3.close();
       
        //adding and removing inside the statement iterator
        model.addAll(stToAdd.iterator());
        for(Statement st:stToRemove)
          model.removeStatement(st);
       
        sb.append(uriStetements+"<br>");
        statementsChanged+=uriStetements;
 
       
View Full Code Here

Examples of org.ontoware.rdf2go.model.ModelSet

        final String expectedString = "null - http://nonexistent.com/abox#Document1823812 - http://www.w3.org/1999/02/22-rdf-syntax-ns#type - http://nonexistent.com/tbox#Document";
        final Object input = JsonUtils.fromString(inputstring);

        final RDF2GoTripleCallback callback = new RDF2GoTripleCallback();

        final ModelSet model = (ModelSet) JsonLdProcessor.toRDF(input, callback);

        // contains only one statement (type)
        final ClosableIterator<Statement> statements = model.iterator();
        final Statement stmt = statements.next();
        assertEquals(expectedString, stmt.getContext() + " - " + stmt.toString());
        assertFalse("Deserialized RDF contains more triples than expected", statements.hasNext());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.