コード例 #1
0
 /** Return a list of all tests of the given type, according to the current filters */
 public List<Resource> findTestsOfType(Resource testType) {
   ArrayList<Resource> result = new ArrayList<>();
   StmtIterator si = testDefinitions.listStatements(null, RDF.type, testType);
   while (si.hasNext()) {
     Resource test = si.nextStatement().getSubject();
     boolean accept = true;
     // Check test status
     Literal status = (Literal) test.getProperty(RDFTest.status).getObject();
     if (approvedOnly) {
       accept = status.getString().equals(STATUS_FLAGS[0]);
     } else {
       accept = false;
       for (String STATUS_FLAG : STATUS_FLAGS) {
         if (status.getString().equals(STATUS_FLAG)) {
           accept = true;
           break;
         }
       }
     }
     // Check for blocked tests
     for (String BLOCKED_TEST : BLOCKED_TESTS) {
       if (BLOCKED_TEST.equals(test.toString())) {
         accept = false;
       }
     }
     // End of filter tests
     if (accept) {
       result.add(test);
     }
   }
   return result;
 }
コード例 #2
0
  public BedStats findAvailableBedsByClinic(Integer clinicId) {
    ClassLoader classLoader = getClass().getClassLoader();
    File file = new File(classLoader.getResource("sparqlQueries/BedsAvailabilityQuery").getFile());
    try {
      queryTemplate = FileUtils.readFileToString(file);
      List<String> params = new ArrayList<String>();
      params.add(clinicId.toString());
      String sparqlQuery = prepareQuery(queryTemplate, params);
      Query query = QueryFactory.create(sparqlQuery);
      QueryExecution qexec = QueryExecutionFactory.sparqlService(endpoint, query);
      System.out.println(sparqlQuery);
      ResultSet results = qexec.execSelect();
      if (results.hasNext()) {
        QuerySolution soln = results.nextSolution();

        Literal l = soln.getLiteral("bedsAvailable"); // Get a result variable - must be a literal
        BedStats bedStats = new BedStats();
        bedStats.setClinicId(clinicId);
        bedStats.setAvailabeBeds(l.getInt());
        return bedStats;
      } else {
        return null;
      }

    } catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }
コード例 #3
0
ファイル: SecuredSeqImpl.java プロジェクト: hmottestad/jena
 @Override
 public SecuredLiteral getLiteral(final int index)
     throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   final Literal literal = holder.getBaseItem().getLiteral(index);
   checkRead(new Triple(holder.getBaseItem().asNode(), RDF.li(index).asNode(), literal.asNode()));
   return SecuredLiteralImpl.getInstance(getModel(), literal);
 }
コード例 #4
0
ファイル: SecuredSeqImpl.java プロジェクト: hmottestad/jena
 @Override
 public String getLanguage(final int index)
     throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   final Literal literal = holder.getBaseItem().getLiteral(index);
   checkRead(new Triple(holder.getBaseItem().asNode(), RDF.li(index).asNode(), literal.asNode()));
   return literal.getLanguage();
 }
コード例 #5
0
  public BedStats findHospitalAvailableBedsAllClinics(String hospital) {
    ApplicationContext appContext = new ClassPathXmlApplicationContext();
    org.springframework.core.io.Resource resource =
        appContext.getResource("classpath:sparqlQueries/BedsAvailabilityQuery");
    try {
      InputStream is = resource.getInputStream();
      BufferedReader br = new BufferedReader(new InputStreamReader(is));

      String line;
      queryTemplate = "";
      while ((line = br.readLine()) != null) {
        queryTemplate += line + "\n";
      }
      br.close();
    } catch (IOException e1) {
      e1.printStackTrace();
      return null;
    }

    List<String> params = new ArrayList<String>();
    params.add(hospital);
    params.add(hospital);
    String sparqlQuery = prepareQuery(queryTemplate, params);
    System.out.println(sparqlQuery);
    Query query = QueryFactory.create(sparqlQuery);
    QueryExecution qexec = QueryExecutionFactory.sparqlService(endpoint, query);
    ResultSet results = qexec.execSelect();
    if (results.hasNext()) {
      QuerySolution soln = results.next();

      Literal available = soln.getLiteral("available"); // Get a result variable - must be a literal
      Literal deployed = soln.getLiteral("deployed");
      Literal supplementary = soln.getLiteral("supplementary");
      // Literal lastDate = soln.getLiteral("maxDate");
      BedStats bedStats = new BedStats();
      bedStats.setHospitalName(params.get(0));
      bedStats.setAvailabeBeds(available.getInt());
      bedStats.setDeployedBeds(deployed.getInt());
      bedStats.setSupplementaryBeds(supplementary.getInt());
      // bedStats.setLastDate(lastDate.getShort());
      return bedStats;
    } else {
      return null;
    }
  }
コード例 #6
0
ファイル: SecuredSeqImpl.java プロジェクト: hmottestad/jena
 private void checkCreate(final int index, final Literal l) {
   checkCreate(new Triple(holder.getBaseItem().asNode(), RDF.li(index).asNode(), l.asNode()));
 }