Quellcode durchsuchen

Should have gone with the previous commit.

Lucas Albertins vor 2 Jahren
Ursprung
Commit
8ff2ef5fcc

+ 0 - 1
src/main/java/ua/be/wee/controller/rest/PMController.java

@@ -5,7 +5,6 @@ import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;

+ 14 - 0
src/main/java/ua/be/wee/model/pt/EndTraceEvent.java

@@ -1,8 +1,22 @@
 package ua.be.wee.model.pt;
 
 import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+
+import ua.be.wee.model.pm.PM;
 
 @Entity
 public class EndTraceEvent extends Event {
 	
+	@ManyToOne
+	private PM pmEnacted;
+
+	public PM getPmEnacted() {
+		return pmEnacted;
+	}
+
+	public void setPmEnacted(PM pmEnacted) {
+		this.pmEnacted = pmEnacted;
+	}
+	
 }

+ 5 - 5
src/main/java/ua/be/wee/model/pt/PT.java

@@ -15,11 +15,6 @@ import ua.be.wee.model.pm.PM;
 @Entity
 public class PT {
 	
-	@OneToOne
-	private PM pmEnacted;
-	
-	private Timestamp timestamp;
-	
 	@Id
 	private String iri;
 	
@@ -30,6 +25,11 @@ public class PT {
 	
 	@OneToMany
 	private List<TraceArtifact> inputs;
+	
+	@OneToOne
+	private PM pmEnacted;
+	
+	private Timestamp timestamp;
 
 	public PM getPmEnacted() {
 		return pmEnacted;

+ 33 - 0
src/main/java/ua/be/wee/model/repository/PTRepository.java

@@ -6,6 +6,7 @@ import java.util.List;
 import org.apache.jena.query.QuerySolution;
 import org.apache.jena.query.ResultSet;
 import org.apache.jena.rdf.model.RDFNode;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Repository;
 
 import ua.be.wee.model.nodes.Activity;
@@ -22,6 +23,9 @@ import ua.be.wee.model.util.DateTimeConverter;
 
 @Repository
 public class PTRepository {
+	
+	@Autowired
+	private PMRepository pmRepo;
 
 	public PT createTrace(PM pm) throws Exception {
 		int index = getNextIndex(pm);
@@ -425,6 +429,9 @@ public class PTRepository {
 				RDFNode rdfNode = next.get("?ts");
 				ev.setTimestamp(DateTimeConverter.convertSPARQLDateTimeToTimestamp(rdfNode.toString()));
 			}
+			
+			ev.setPmEnacted(pmRepo.getPM(pmIRI));
+			
 			return ev;
 		} else {
 			throw new Exception("Error inserting data.");
@@ -432,4 +439,30 @@ public class PTRepository {
 		
 	}
 
+	
+	public List<PT> getStartTraceEvents() {
+		List<PT> list = new ArrayList<PT>();
+		String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
+				+ "PREFIX tr: <http://ua.be/sdo2l/vocabulary/formalisms/processtraces#>\n"
+				+ "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n"
+				+ "SELECT ?trace ?pm ?ts WHERE {\n"
+				+ "	?trace rdf:type <http://ua.be/sdo2l/vocabulary/formalisms/processtraces#StartTraceEvent> ;\n"
+				+ "    	tr:relatesTo ?pm ;\n"
+				+ " 	tr:hasTimestamp ?ts ; \n"
+				+ "}";
+		ResultSet rs = FusekiWrapper.getInstance().execQuery(query);
+		while (rs.hasNext()) {
+			QuerySolution next = rs.next();
+			RDFNode trace = next.get("?trace");
+			RDFNode pm = next.get("?pm");
+			RDFNode ts = next.get("?ts");
+			PT pt = new PT();
+			pt.setIri(trace.toString());
+			pt.setTimestamp(DateTimeConverter.convertSPARQLDateTimeToTimestamp(ts.toString()));
+			pt.setPmEnacted(pmRepo.getPM(pm.toString()));
+			list.add(pt);
+		}
+		return list;
+	}
+
 }

+ 2 - 4
src/main/java/ua/be/wee/model/util/DateTimeConverter.java

@@ -6,12 +6,10 @@ import java.util.Calendar;
 import org.apache.jena.atlas.lib.DateTimeUtils;
 
 public class DateTimeConverter {
-
-	
 	
 	public static Timestamp convertSPARQLDateTimeToTimestamp(String dateTimeSparql) {
 		String[] split = dateTimeSparql.split("T");
-		return Timestamp.valueOf(split[0] + " " + split[1].split("\\.")[0]);
+		return Timestamp.valueOf(split[0].substring(0) + " " + split[1].substring(0,8));
 	}
 
 	public static String convertTimestampToSPARQLdateTime(Timestamp timestamp) {
@@ -20,5 +18,5 @@ public class DateTimeConverter {
 		String converted = DateTimeUtils.calendarToXSDDateTimeString(instance);
 		converted = "\"" + converted + "\"^^<http://www.w3.org/2001/XMLSchema#dateTime>";
 		return converted;
-	}	
+	}
 }