org.apache.jena.rdf.model.Model.enterCriticalSection()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.apache.jena.rdf.model.Model.enterCriticalSection()方法的一些代码示例,展示了Model.enterCriticalSection()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.enterCriticalSection()方法的具体详情如下:
包路径:org.apache.jena.rdf.model.Model
类名称:Model
方法名:enterCriticalSection

Model.enterCriticalSection介绍

暂无

代码示例

代码示例来源:origin: vivo-project/Vitro

@Override
public void enterCriticalSection(boolean readLockRequested) {
  inner.enterCriticalSection(readLockRequested);
}

代码示例来源:origin: vivo-project/Vitro

public LockedModel write() {
    model.enterCriticalSection(Lock.WRITE);
    return new LockedModel(model);
  }
}

代码示例来源:origin: vivo-project/Vitro

public LockedModel read() {
  model.enterCriticalSection(Lock.READ);
  return new LockedModel(model);
}

代码示例来源:origin: vivo-project/Vitro

public boolean usesGroup(Model model, Resource theClassGroup) throws IOException {
  model.enterCriticalSection(Lock.READ);
  try {	   
    return (model.contains((Resource) null, inClassGroupProp, theClassGroup));
  } finally {
    model.leaveCriticalSection();
  }
}

代码示例来源:origin: apache/jena

@Override
public void enterCriticalSection(final boolean readLockRequested)
    throws UpdateDeniedException, ReadDeniedException, AuthenticationRequiredException {
  if (readLockRequested) {
    checkRead();
  } else {
    checkUpdate();
  }
  holder.getBaseItem().enterCriticalSection(readLockRequested);
}

代码示例来源:origin: vivo-project/Vitro

/**
 * Get a list of statements from this model that match this pattern.
 */
public List<Statement> matchStatementsFromModel(Model m) {
  m.enterCriticalSection(Lock.READ);
  try {
    return m.listStatements(subject, predicate, object).toList();
  } finally {
    m.leaveCriticalSection();
  }
}

代码示例来源:origin: at.researchstudio.sat/won-core

public NeedState getNeedState() {
  Model sysInfoModel = getSysInfoModel();
  sysInfoModel.enterCriticalSection(true);
  RDFNode state = RdfUtils.findOnePropertyFromResource(sysInfoModel, getNeedNode(NeedGraphType.SYSINFO), WON.IS_IN_STATE);
  sysInfoModel.leaveCriticalSection();
  if (state.equals(WON.NEED_STATE_ACTIVE)) {
    return NeedState.ACTIVE;
  } else {
    return NeedState.INACTIVE;
  }
}

代码示例来源:origin: vivo-project/Vitro

private void renamePortal(Resource portal, String namespace, Model model) {
  model.enterCriticalSection(Lock.WRITE);
  try {
    ResourceUtils.renameResource(portal, namespace + portal.getLocalName());
  } finally {
    model.leaveCriticalSection();
  }
}

代码示例来源:origin: vivo-project/Vitro

private List<Resource> getPortal1s(Model model) {
  List<Resource> portals = new ArrayList<Resource>();
  try {
    model.enterCriticalSection(Lock.READ);
    ResIterator portalIt = model.listResourcesWithProperty(
        RDF.type, PORTAL);
    while (portalIt.hasNext()) {
      Resource portal = portalIt.nextResource();
      if ("portal1".equals(portal.getLocalName())) {
        portals.add(portal);
      }
    }
  } finally {
    model.leaveCriticalSection();
  }
  return portals;
}

代码示例来源:origin: vivo-project/Vitro

public ActionResult handleAction(Individual actionInd) {
    if (instanceOf(actionInd,WorkflowOntology.ClearModelAction)) {
      Model sourceModel = getModel(actionInd.getPropertyValue(WorkflowOntology.sourceModel)); 
      sourceModel.enterCriticalSection(Lock.WRITE);
      try{
        // this method is used so that any listeners can see each statement removed
        sourceModel.removeAll((Resource)null,(Property)null,(RDFNode)null);
      } finally {
        sourceModel.leaveCriticalSection();
      }
      return new ActionResultImpl();
    } else {
      return null;
    }        
  }
}

代码示例来源:origin: vivo-project/Vitro

private List<Map<String, String>> executeQuery(Query query, Model model) {
  model.enterCriticalSection(Lock.READ);        
  try{            
    QueryExecution qexec= QueryExecutionFactory.create(query, model );
    ResultSet results = qexec.execSelect();
    try{                
      return parseResults(results);
    }finally{ qexec.close(); }
  }finally{ model.leaveCriticalSection(); }
}

代码示例来源:origin: apache/jena

@Override
  public void run()
   {
     for ( int i = 0 ; i < 2 ; i++ )
     {
       try {
         model.enterCriticalSection(readLock) ;
         if ( readLock )
           readOperation(false) ;
         else
           writeOperation(false) ;
       } finally { model.leaveCriticalSection() ; }
     }            
   }
}

代码示例来源:origin: org.apache.jena/jena-core

@Override
  public void run()
   {
     for ( int i = 0 ; i < 2 ; i++ )
     {
       try {
         model.enterCriticalSection(readLock) ;
         if ( readLock )
           readOperation(false) ;
         else
           writeOperation(false) ;
       } finally { model.leaveCriticalSection() ; }
     }            
   }
}

代码示例来源:origin: vivo-project/Vitro

/** 
 * Gets the requiredActions directly associated with page.
 */
public List<String> getRequiredActions(String pageUri){
  QuerySolutionMap initialBindings = new QuerySolutionMap();
  initialBindings.add("pageUri", ResourceFactory.createResource(pageUri));
  List<String> actions = new ArrayList<String>();
  
  Model dModel = getOntModelSelector().getDisplayModel();
  dModel.enterCriticalSection(false);
  try{
    QueryExecution qe = 
      QueryExecutionFactory.create( requiredActionsQuery, dModel, initialBindings);
    actions = executeQueryToList( qe );
    qe.close();
  }finally{
    dModel.leaveCriticalSection();
  }
  return actions;            
}

代码示例来源:origin: apache/jena

@Override
  public void run()
  {
    for (int i = 0; i < 2; i++)
    {
      try
      {
        lockModel.enterCriticalSection(readLock);
        if (readLock)
          readOperation(false);
        else
          writeOperation(false);
      }
      finally
      {
        lockModel.leaveCriticalSection();
      }
    }
  }
}

代码示例来源:origin: apache/jena

private Model executeSparqlConstruct(Model model, String sparql, boolean lock) {
  Query query = QueryFactory.create(sparql);
  try(QueryExecution queryExec = QueryExecutionFactory.create(query, model)) {
    model.enterCriticalSection(lock);
    try { return queryExec.execConstruct() ; }
    finally { model.leaveCriticalSection() ; }
  }
}

代码示例来源:origin: apache/jena

private ResultSetRewindable executeSparqlSelect(Model model, String sparql, boolean lock) {
  Query query = QueryFactory.create(sparql);
  try(QueryExecution queryExec = QueryExecutionFactory.create(query, model)) {
    model.enterCriticalSection(lock);
    try {
      return ResultSetFactory.makeRewindable(queryExec.execSelect());
    } finally {
      model.leaveCriticalSection();
    }
  }
}

代码示例来源:origin: vivo-project/Vitro

public static boolean includeInLinkedData(Resource object, Model contextModel) {
       boolean retval = false;
        contextModel.enterCriticalSection(Lock.READ);
        try {
    StmtIterator iter = contextModel.listStatements(object, RDF.type, (RDFNode)null);
        
    while (iter.hasNext()) {
      Statement stmt = iter.next();
      
      if (stmt.getObject().isResource() && contextModel.contains(stmt.getObject().asResource(), extendedLinkedDataProperty, xsdTrue)) {
        retval = true;
        break;
      }    
    }
    } finally {
      contextModel.leaveCriticalSection();
    }
        return retval;
}

代码示例来源:origin: vivo-project/Vitro

private Model getLabelAndTypes(Individual entity, Model ontModel, Model newModel){
  for( VClass vclass : entity.getVClasses()){
    newModel.add(newModel.getResource(entity.getURI()), RDF.type, newModel.getResource(vclass.getURI()));
  }
  
  ontModel.enterCriticalSection(Lock.READ);
  try {
    newModel.add(ontModel.listStatements(ontModel.getResource(entity.getURI()), RDFS.label, (RDFNode)null));
  } finally {
    ontModel.leaveCriticalSection();
  }
  
  return newModel;
}

代码示例来源:origin: vivo-project/Vitro

private void doSmushSingleModel(VitroRequest vreq) {
  OntModel source = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
  String[] sourceModel = vreq.getParameterValues("sourceModelName");
  for (String aSourceModel : sourceModel) {
    Model m = getModel(aSourceModel, vreq);
    source.addSubModel(m);
  }
  Model destination = getModel(vreq.getParameter("destinationModelName"),vreq);
  String propertyURIStr = vreq.getParameter("propertyURI");
  Property prop = ResourceFactory.createProperty(propertyURIStr);
  JenaIngestUtils utils = new JenaIngestUtils();
  destination.enterCriticalSection(Lock.WRITE);
  try {
    destination.add(utils.smushResources(source, prop));
  } finally {
    destination.leaveCriticalSection();
  }
}

相关文章

Model类方法