Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test(groups= { "default" },priority=8,enabled=true)
- public void testPreparedQueryCacheGeneration3DFromVirtuosoToMongoDB_50() throws Exception{
- String projectName = "projectTest";
- String simulationName = "simulationUnitTest";
- System.out.println("STARTING 50");
- JenaModel model = new JenaModel();
- String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
- + "PREFIX owl: <http://www.w3.org/2002/07/owl#> "
- + "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
- + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
- + "PREFIX fem: <http://www.sifemontologies.com/ontologies/FiniteElementModel.owl#> "
- + "PREFIX pak: <http://www.sifemontologies.com/ontologies/FEMSettingsPAK.owl#> "
- + "PREFIX sim: <http://www.sifemontologies.com/ontologies/Simulation.owl#> "
- + "SELECT ?material ?materialType ?node ?xCoord ?yCoord ?zCoord ?translationX ?translationY ?translationZ ?subDomain ?id "
- + "FROM NAMED <http://www.sifemontologies.com/ontologies/displacement_50> "
- + "WHERE { "
- + "GRAPH ?g { "
- + "?material rdf:type fem:Material . ?material fem:hasMaterialNumber ?y . ?material pak:hasMaterialSettings ?z . ?z pak:MATTYPE ?materialType. FILTER (?y=1) . ?node rdf:type fem:Node . "
- + "?node fem:isNodeOf ?subDomain. ?node fem:hasNodeID ?id. ?subDomain fem:makesUp ?subDomainGroup. ?subDomainGroup fem:hasMaterial ?material. ?node fem:hasXCoordinate ?xCoord . ?node fem:hasYCoordinate ?yCoord . ?node fem:hasZCoordinate ?zCoord . ?node fem:holdsValueFor ?b . ?b rdf:type fem:Translation. ?b sim:hasVectorValue ?a . ?a sim:isReal true . ?a sim:hasVectorXValue ?translationX . ?a sim:hasVectorYValue ?translationY . ?a sim:hasVectorZValue ?translationZ . "
- + "} "
- + " }";
- List<String> queryVariables = new ArrayList<String>();
- ResultSet results = Util.executeQuery(query, virtDataset);
- queryVariables.add("material");queryVariables.add("materialType");queryVariables.add("node");
- queryVariables.add("xCoord");queryVariables.add("yCoord");queryVariables.add("zCoord");
- queryVariables.add("translationX");queryVariables.add("translationY");queryVariables.add("translationZ");
- queryVariables.add("subDomain");queryVariables.add("id");
- Map<String, List<RDFNode>> queryModel = model.queryModelWithResultService(results,queryVariables);
- //List<RDFNode> materials = queryModel.get(queryVariables.get(0));
- //List<RDFNode> materialTypes = queryModel.get(queryVariables.get(1));
- List<String> nodes = new Util().changeFromRDFNodeToStringList(queryModel.get(queryVariables.get(2)));
- List<String> xCoords = new Util().changeFromRDFNodeToStringList(queryModel.get(queryVariables.get(3)));
- //List<RDFNode> yCoords = queryModel.get(queryVariables.get(4));
- List<String> zCoords = new Util().changeFromRDFNodeToStringList(queryModel.get(queryVariables.get(5)));
- List<String> translationXs = new Util().changeFromRDFNodeToStringList(queryModel.get(queryVariables.get(6)));
- //List<RDFNode> translationYs = queryModel.get(queryVariables.get(7));
- //List<String> translationZs = new Util().changeFromRDFNodeToStringList(queryModel.get(queryVariables.get(8)));
- List<String> subDomains = new Util().changeFromRDFNodeToStringList(queryModel.get(queryVariables.get(9)));
- List<String> ids = new Util().changeFromRDFNodeToStringList(queryModel.get(queryVariables.get(10)));
- System.out.println("Nodes number: " + nodes.size());
- //Assert.assertEquals(""+nodes.size()+"".trim(),"9600".trim());
- // List<String> nodes = Collections.EMPTY_LIST;
- // List<String> xCoords = Collections.EMPTY_LIST;
- // List<String> translationXs = Collections.EMPTY_LIST;
- // List<String> subDomains = Collections.EMPTY_LIST;
- // List<String> ids = Collections.EMPTY_LIST;
- //
- if(nodes.toString().contains("[")){
- String nodesStr = new Util().removeListKeysFromString(nodes.toString().replace(" ",""));
- nodes = Arrays.asList(nodesStr.split(","));
- String xCoordStr = new Util().removeListKeysFromString(xCoords.toString().replace(" ",""));
- xCoords = Arrays.asList(xCoordStr.split(","));
- String translationXStr = new Util().removeListKeysFromString(translationXs.toString().replace(" ",""));
- translationXs = Arrays.asList(translationXStr.split(","));
- String zCoordsStr = new Util().removeListKeysFromString(zCoords.toString().replace(" ",""));
- zCoords = Arrays.asList(zCoordsStr.split(","));
- String subDomainStr = new Util().removeListKeysFromString(subDomains.toString().replace(" ",""));
- subDomains = Arrays.asList(subDomainStr.split(","));
- String idsStr = new Util().removeListKeysFromString(ids.toString().replace(" ",""));
- ids = Arrays.asList(idsStr.split(","));
- }
- int size = subDomains.size();
- Map<String, Double> nodeXDisplacement = new HashMap<String, Double>();
- Map<String, Double> nodeZCoord = new HashMap<String, Double>();
- Map<Integer, String> idNodeMap = new HashMap<Integer, String>();
- Map<String, Double> nodeXCoord = new HashMap<String, Double>();
- System.out.println("size: "+size);
- for(int i=0; i<size; i++){
- String displacementXStr = new Util().fixNumericValueForCacheList(translationXs.get(i));
- String currentZCoordStr = new Util().fixNumericValueForCacheList(zCoords.get(i));
- String currentXCoordStr = new Util().fixNumericValueForCacheList(xCoords.get(i));
- String idStr = new Util().fixNumericValueForCacheList(ids.get(i));
- if(displacementXStr==null || currentXCoordStr==null || idStr==null || currentZCoordStr==null){
- continue;
- }
- Double displacementX = new Double(displacementXStr);
- Double currentZCoord = new Double(currentZCoordStr);
- Double currentXCoord = new Double(currentXCoordStr);
- String node = nodes.get(i);
- int nodeNumber = new Integer(idStr);
- nodeXDisplacement.put(node, displacementX);
- nodeZCoord.put(node, currentZCoord);
- nodeXCoord.put(node, currentXCoord);
- idNodeMap.put(nodeNumber, node);
- }
- System.out.println("Final Nodes Remaining: " + idNodeMap.size());
- //Assert.assertEquals(""+idNodeMap.size()+"".trim(),"2020".trim());
- List<String> datax = new ArrayList<String>();
- List<String> datay = new ArrayList<String>();
- List<String> dataz = new ArrayList<String>();
- List<Integer> nodeSortedIds = new ArrayList<Integer>();
- for(int i : idNodeMap.keySet()) {
- nodeSortedIds.add(i);
- }
- Collections.sort(nodeSortedIds);
- Double previousXCoord = new Double(Float.MIN_VALUE);
- for(Integer id : nodeSortedIds){
- String node = idNodeMap.get(id);
- Double displacement = nodeXDisplacement.get(node);
- Double currentXCoord = nodeXCoord.get(node);
- Double currentZCoord = nodeZCoord.get(node);
- if(currentXCoord > previousXCoord){
- datax.add(currentXCoord.toString());
- datay.add(displacement.toString());
- dataz.add(currentZCoord.toString());
- previousXCoord = currentXCoord;
- }
- }
- ViewTO viewTO = new ViewTO();
- for (String value : datax) {
- viewTO.getxView().add(value);
- }
- for (String value : datay) {
- viewTO.getyView().add(value);
- }
- for (String value : dataz) {
- viewTO.getzView().add(value);
- }
- DataSetHashCacheTO greenwoodCache = new DataSetHashCacheTO();
- greenwoodCache.setProjectName(projectName.toUpperCase());
- greenwoodCache.setSimulationName(simulationName.toUpperCase());
- greenwoodCache.setxName("BasilarMembraneMagnitude".toUpperCase());
- greenwoodCache.setyName("DistanceFromTheCochleaBasis".toUpperCase());
- greenwoodCache.setyName("ZValueForDisplacement".toUpperCase());
- greenwoodCache.setHash(Util.generateHashCacheID(greenwoodCache));
- greenwoodCache.setViewTO(viewTO);
- greenwoodCache.setFrequency("50");
- dataSetHashCacheDAO.insert(greenwoodCache);
- System.out.println("DONE!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement