-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Q20-15 - story/Q20-15 #33
base: develop
Are you sure you want to change the base?
Changes from 45 commits
b3a7d40
eac4100
77a175b
7aeff7a
2297cc0
5d940c8
c1d622b
ce2e3fa
274d9b4
9ccc289
26e079d
3c0fff9
47ea50c
8eaaf88
ee62a04
bab0acb
cfcd8af
03ebd67
3b28ae4
c0852d9
452c08e
7211aa9
5abf144
6200570
f461cec
c4e0d03
481cee5
362cb65
5a22df9
392d85c
e91de9e
5666077
344f59b
5defb60
bcb1b52
2223f0c
0b3606f
d809c7f
eee20d0
2b545e2
1165908
93b0d29
b132377
a56968a
967569b
cd77e32
3e5b4f6
89a902d
08411d9
814bdc9
5af8a7e
40f882b
5c19c21
4d5f37f
e462496
53cb294
e185877
e249731
6c7a5fe
86a25d3
19cdda1
814fb46
83e2a0e
f71b945
c26eb0f
519fcf6
06d4998
5bacdcd
f28fc45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,10 @@ | |
<admin.password>$2a$04$oQo44vqcDIFRoYKiAXoNheurzkwX9dcNmowvTX/hsWuBMwijqn44i</admin.password> | ||
|
||
<db.driver>com.mysql.jdbc.Driver</db.driver> | ||
<db.database.url>jdbc-url-to-db</db.database.url> | ||
<db.user>db-user</db.user> | ||
<db.password>db-password</db.password> | ||
<db.database.url>jdbc:mysql://localhost:3306/quadriga</db.database.url> | ||
<db.user></db.user> | ||
<db.password></db.password> | ||
|
||
|
||
<email.user></email.user> | ||
<email.password></email.password> | ||
|
@@ -41,10 +42,19 @@ | |
<neo4j.url>http://neo4j:quadriga@localhost:7474/</neo4j.url> | ||
<neo4j.database>quadriga</neo4j.database> | ||
|
||
<citesphere.base.url></citesphere.base.url> | ||
<quadriga.base.url></quadriga.base.url> | ||
<quadriga.jobstatus.api></quadriga.jobstatus.api> | ||
<quadriga.collectionpage.url></quadriga.collectionpage.url> | ||
|
||
<citesphere.base.url>https://diging-dev.asu.edu/citesphere-review/</citesphere.base.url> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should not be changed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should have a dummy default value |
||
<citesphere.client.id></citesphere.client.id> | ||
<citesphere.client.secret></citesphere.client.secret> | ||
jdamerow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<citesphere.client.id></citesphere.client.id> | ||
<citesphere.client.secret></citesphere.client.secret> | ||
|
||
|
||
<conceptpower.base.url></conceptpower.base.url> | ||
<log.level>info</log.level> | ||
|
||
<tomcat.deploy.path></tomcat.deploy.path> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package edu.asu.diging.quadriga.api.v1; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
|
||
import edu.asu.diging.quadriga.core.model.jobs.Job; | ||
import edu.asu.diging.quadriga.core.service.JobManager; | ||
|
||
public class JobStatusController { | ||
|
||
@Autowired | ||
private JobManager jobManager; | ||
|
||
|
||
@GetMapping(value = "/api/v1/job/{jobId}/status") | ||
public ResponseEntity<Job> getJobStatus(@PathVariable String jobId) { | ||
Job job = jobManager.get(jobId); | ||
if(job == null){ | ||
return new ResponseEntity<>(null,HttpStatus.NOT_FOUND); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fairly certain there is a constructor that just takes an httpstatus. |
||
} | ||
return new ResponseEntity<>(job, HttpStatus.OK); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package edu.asu.diging.quadriga.api.v1; | ||
|
||
import java.util.ArrayList; | ||
|
||
import java.util.List; | ||
|
||
import org.bson.types.ObjectId; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
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.RequestBody; | ||
|
||
import edu.asu.diging.quadriga.api.v1.model.PatternMapping; | ||
import edu.asu.diging.quadriga.api.v1.model.PatternMappingList; | ||
import edu.asu.diging.quadriga.core.model.EventGraph; | ||
import edu.asu.diging.quadriga.core.model.MappedTripleGroup; | ||
import edu.asu.diging.quadriga.core.model.jobs.Job; | ||
import edu.asu.diging.quadriga.core.service.AsyncPatternProcessor; | ||
import edu.asu.diging.quadriga.core.service.EventGraphService; | ||
import edu.asu.diging.quadriga.core.service.JobManager; | ||
|
||
@Controller | ||
public class MapGraphToTripleController { | ||
|
||
@Value("${quadriga_base_url}") | ||
private String quadrigaBaseUri; | ||
|
||
@Value("${quadriga_job_status_api}") | ||
private String quadrigaJobStatusUri; | ||
|
||
@Value("${quadriga_collection_page}") | ||
private String quadrigaCollectionPageUri; | ||
|
||
@Autowired | ||
private AsyncPatternProcessor asyncPatternProcessor; | ||
|
||
@Autowired | ||
private EventGraphService eventGraphService; | ||
|
||
@Autowired | ||
private JobManager jobManager; | ||
|
||
@PostMapping(value = "/api/v1/collection/{collectionId}/network/map") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should just be |
||
public ResponseEntity<List<JobPatternInfo>> mapPatternToTriples(@PathVariable String collectionId, | ||
@RequestBody PatternMappingList patternMappingList) { | ||
|
||
List<EventGraph> eventGraphs = eventGraphService.getEventGraphs(new ObjectId(collectionId)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these can be a lot of graphs. You don't want to load them all into memory. I don't think you want this done here. |
||
if (eventGraphs == null) { | ||
return new ResponseEntity<>(HttpStatus.NOT_FOUND); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the logic should rather be to check if the collection exists, not the if event graphs exists. it's fine (even if it doesn't make much sense) to try to run mappings on 0 event graphs. An invalid collection id, however, should return a not found. |
||
} | ||
|
||
List<JobPatternInfo> jobInfos = new ArrayList<>(); | ||
|
||
MappedTripleGroup mappedTripleGroup = new MappedTripleGroup(); | ||
mappedTripleGroup.set_id(new ObjectId()); | ||
mappedTripleGroup.setCollectionId(new ObjectId(collectionId)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should not be part of the controller, that's business logic. |
||
|
||
String jobId = jobManager.createJob(collectionId, mappedTripleGroup.get_id().toString(), eventGraphs.size()); | ||
|
||
List<Thread> transformationThreads = new ArrayList<>(); | ||
for (PatternMapping pattern : patternMappingList.getPatternMappings()) { | ||
Thread transformationThread = new Thread(() -> { | ||
asyncPatternProcessor.processPattern(jobId, collectionId, pattern, eventGraphs); | ||
JobPatternInfo jobInfo = new JobPatternInfo(); | ||
jobInfo.setJobId(jobId); | ||
jobInfo.setTrack(quadrigaBaseUri + quadrigaJobStatusUri + jobId + "/status"); | ||
jobInfo.setExplore(quadrigaBaseUri + quadrigaCollectionPageUri + collectionId); | ||
jobInfos.add(jobInfo); | ||
}); | ||
transformationThreads.add(transformationThread); | ||
transformationThread.start(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this above is all business logic and should not be done in the controller There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, you should create threads; use the async functionality of spring instead |
||
for (Thread thread : transformationThreads) { | ||
try { | ||
thread.join(); | ||
} catch (InterruptedException e) { | ||
System.out.println("Job thread was interrupted due to the exception:"+e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ??? |
||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is all not necessary when using Spring's async |
||
return new ResponseEntity<>(jobInfos, HttpStatus.OK); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be just one job for a transformation request. There might be multiple threads started to work on the individual patterns, but there should only be one job. |
||
} | ||
|
||
@GetMapping(value = "/api/v1/job/{jobId}/status") | ||
public ResponseEntity<Job> getJobStatus(@PathVariable String jobId) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be in it's own controller |
||
return new ResponseEntity<>(jobManager.get(jobId), HttpStatus.OK); | ||
} | ||
|
||
class JobPatternInfo { | ||
private String jobId; | ||
private String track; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is 'track'? |
||
private String explore; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is 'explore'? |
||
|
||
public String getJobId() { | ||
return jobId; | ||
} | ||
public void setJobId(String jobId) { | ||
this.jobId = jobId; | ||
} | ||
public String getTrack() { | ||
return track; | ||
} | ||
public void setTrack(String track) { | ||
this.track = track; | ||
} | ||
public String getExplore() { | ||
return explore; | ||
} | ||
public void setExplore(String explore) { | ||
this.explore = explore; | ||
} | ||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package edu.asu.diging.quadriga.api.v1.model; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class PatternMapping { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needs javadoc |
||
|
||
private String mappedTripleGroupId; | ||
jdamerow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private Metadata metadata; | ||
private Map<String, PatternNodeData> nodes; | ||
private List<Edge> edges; | ||
|
||
public String getMappedTripleGroupId() { | ||
return mappedTripleGroupId; | ||
} | ||
public void setMappedTripleGroupId(String mappedTripleGroupId) { | ||
this.mappedTripleGroupId = mappedTripleGroupId; | ||
} | ||
public Metadata getMetadata() { | ||
return metadata; | ||
} | ||
public void setMetadata(Metadata metadata) { | ||
this.metadata = metadata; | ||
} | ||
public Map<String, PatternNodeData> getNodes() { | ||
return nodes; | ||
} | ||
public void setNodes(Map<String, PatternNodeData> nodes) { | ||
this.nodes = nodes; | ||
} | ||
public List<Edge> getEdges() { | ||
return edges; | ||
} | ||
public void setEdges(List<Edge> edges) { | ||
this.edges = edges; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package edu.asu.diging.quadriga.api.v1.model; | ||
|
||
import java.util.List; | ||
|
||
public class PatternMappingList { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this class for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this class needed? Can't you just use a list? |
||
|
||
private List<PatternMapping> patternMappings; | ||
|
||
public List<PatternMapping> getPatternMappings() { | ||
return patternMappings; | ||
} | ||
|
||
public void setPatternMappings(List<PatternMapping> patternMappings) { | ||
this.patternMappings = patternMappings; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package edu.asu.diging.quadriga.api.v1.model; | ||
|
||
public class PatternNodeData { | ||
|
||
private String type; | ||
private String interpretation; | ||
private String conceptType; | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
public String getInterpretation() { | ||
return interpretation; | ||
} | ||
public void setInterpretation(String interpretation) { | ||
this.interpretation = interpretation; | ||
} | ||
public String getConceptType() { | ||
return conceptType; | ||
} | ||
public void setConceptType(String conceptType) { | ||
this.conceptType = conceptType; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,7 @@ public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { | |
Properties additionalProperties() { | ||
Properties properties = new Properties(); | ||
properties.setProperty("hibernate.hbm2ddl.auto", "update"); | ||
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect"); | ||
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL8Dialect"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should not be changed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? |
||
properties.setProperty("hibernate.show_sql", "true"); | ||
properties.setProperty("hibernate.id.new_generator_mappings", "true"); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package edu.asu.diging.quadriga.core.conceptpower; | ||
|
||
import edu.asu.diging.quadriga.core.model.conceptpower.ConceptEntry; | ||
import edu.asu.diging.quadriga.core.model.conceptpower.ConceptpowerResponse; | ||
|
||
public interface ConceptpowerConnector { | ||
|
||
/** | ||
* Retrieves the concept for the given id from Conceptpower | ||
* @param id is the concept id | ||
* @return the retrieved concept | ||
*/ | ||
ConceptEntry getConceptEntry(String id); | ||
|
||
/** | ||
* Retrieves the concept entries which are equal to the given interpretation | ||
* @param uri URI of interpretation | ||
* @return the retrieved results | ||
*/ | ||
ConceptpowerResponse findConceptEqualTo(String uri); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about these two (line 46 and 47). These are path from Quadriga itself, right? Just create a constant in the controller with that path and use the constant when you need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?