diff --git a/src/main/java/org/wikitolearn/wikirating/model/Process.java b/src/main/java/org/wikitolearn/wikirating/model/Process.java index 44f0be1..d703c3d 100644 --- a/src/main/java/org/wikitolearn/wikirating/model/Process.java +++ b/src/main/java/org/wikitolearn/wikirating/model/Process.java @@ -1,61 +1,72 @@ package org.wikitolearn.wikirating.model; import org.neo4j.ogm.annotation.GraphId; import org.neo4j.ogm.annotation.NodeEntity; +import org.neo4j.ogm.annotation.Relationship; import org.wikitolearn.wikirating.util.enums.ProcessResult; import org.wikitolearn.wikirating.util.enums.ProcessType; import java.util.Date; /** * This class represents a Process happened in the engine. * It has a definite type and can have different results. It is saved in the DB * as a Process vertex. * @author aletundo * @author valsdav */ @NodeEntity( label = "Process") public class Process { @GraphId private Long graphId; private Date timestamp; private ProcessType processType; private ProcessResult processResult; + @Relationship(type="PREVIOUS_PROCESS", direction = Relationship.OUTGOING) + private Process previousProcess; public Process() {} public Process(Date timestamp, ProcessType processType, ProcessResult processResult) { this.timestamp = timestamp; this.processType = processType; this.processResult = processResult; } public Process(ProcessType processType){ this.timestamp = new Date(); this.processType = processType; this.processResult = ProcessResult.ONGOING; } public Date getTimestamp() { return timestamp; } public void setTimestamp(Date timestamp) { this.timestamp = timestamp; } public ProcessType getProcessType() { return processType; } public void setProcessType(ProcessType processType) { this.processType = processType; } public ProcessResult getProcessResult() { return processResult; } public void setProcessResult(ProcessResult processResult) { this.processResult = processResult; } + + public Process getPreviousProcess() { + return previousProcess; + } + + public void setPreviousProcess(Process previousProcess) { + this.previousProcess = previousProcess; + } } diff --git a/src/main/java/org/wikitolearn/wikirating/model/Revision.java b/src/main/java/org/wikitolearn/wikirating/model/Revision.java index bbd2db3..65eff8d 100644 --- a/src/main/java/org/wikitolearn/wikirating/model/Revision.java +++ b/src/main/java/org/wikitolearn/wikirating/model/Revision.java @@ -1,300 +1,312 @@ package org.wikitolearn.wikirating.model; import org.neo4j.ogm.annotation.GraphId; import org.neo4j.ogm.annotation.Index; import org.neo4j.ogm.annotation.NodeEntity; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import org.neo4j.ogm.annotation.Relationship; +import java.util.Set; + /** * This class handles the data of the Revision of a page. * Created by valsdav on 14/03/17. */ @JsonIgnoreProperties(ignoreUnknown = true) @NodeEntity( label = "Revision" ) public class Revision { @GraphId private Long graphId; private int revid; private int userid; private int parentid; private long length; private double changeCoefficient; private double currentMeanVote; private double currentVotesReliability; private double currentNormalisesVotesReliability; private double totalMeanVote; private double totalVotesReliability; private double totalNormalisesVotesReliability; private boolean validated; private String lang; @Index(unique = true, primary=true) private String langRevId; @Relationship(type="PREVIOUS_REVISION", direction = Relationship.OUTGOING) private Revision previousRevision; + @Relationship(type="VOTE", direction = Relationship.INCOMING) + private Set votes; /** * */ public Revision() {} /** * @param revid * @param userid * @param parentid * @param length * @param changeCoefficient * @param currentMeanVote * @param currentVotesReliability * @param currentNormalisesVotesReliability * @param totalMeanVote * @param totalVotesReliability * @param totalNormalisesVotesReliability * @param validated * @param lang */ public Revision(int revid, int userid, int parentid, long length, double changeCoefficient, double currentMeanVote, double currentVotesReliability, double currentNormalisesVotesReliability, double totalMeanVote, double totalVotesReliability, double totalNormalisesVotesReliability, boolean validated, String lang) { this.revid = revid; this.userid = userid; this.parentid = parentid; this.length = length; this.changeCoefficient = changeCoefficient; this.currentMeanVote = currentMeanVote; this.currentVotesReliability = currentVotesReliability; this.currentNormalisesVotesReliability = currentNormalisesVotesReliability; this.totalMeanVote = totalMeanVote; this.totalVotesReliability = totalVotesReliability; this.totalNormalisesVotesReliability = totalNormalisesVotesReliability; this.validated = validated; this.lang = lang; } /** * @return the revid */ public int getRevid() { return revid; } /** * @param revid the revid to set */ public void setRevid(int revid) { this.revid = revid; } /** * @return the userid */ public int getUserid() { return userid; } /** * @param userid the userid to set */ public void setUserid(int userid) { this.userid = userid; } /** * @return the parentid */ public int getParentid() { return parentid; } /** * @param parentid the parentid to set */ public void setParentid(int parentid) { this.parentid = parentid; } /** * @return the length */ public long getLength() { return length; } /** * @param length the length to set */ public void setLength(long length) { this.length = length; } /** * @return the changeCoefficient */ public double getChangeCoefficient() { return changeCoefficient; } /** * @param changeCoefficient the changeCoefficient to set */ public void setChangeCoefficient(double changeCoefficient) { this.changeCoefficient = changeCoefficient; } /** * @return the currentMeanVote */ public double getCurrentMeanVote() { return currentMeanVote; } /** * @param currentMeanVote the currentMeanVote to set */ public void setCurrentMeanVote(double currentMeanVote) { this.currentMeanVote = currentMeanVote; } /** * @return the currentVotesReliability */ public double getCurrentVotesReliability() { return currentVotesReliability; } /** * @param currentVotesReliability the currentVotesReliability to set */ public void setCurrentVotesReliability(double currentVotesReliability) { this.currentVotesReliability = currentVotesReliability; } /** * @return the currentNormalisesVotesReliability */ public double getCurrentNormalisesVotesReliability() { return currentNormalisesVotesReliability; } /** * @param currentNormalisesVotesReliability the currentNormalisesVotesReliability to set */ public void setCurrentNormalisesVotesReliability(double currentNormalisesVotesReliability) { this.currentNormalisesVotesReliability = currentNormalisesVotesReliability; } /** * @return the totalMeanVote */ public double getTotalMeanVote() { return totalMeanVote; } /** * @param totalMeanVote the totalMeanVote to set */ public void setTotalMeanVote(double totalMeanVote) { this.totalMeanVote = totalMeanVote; } /** * @return the totalVotesReliability */ public double getTotalVotesReliability() { return totalVotesReliability; } /** * @param totalVotesReliability the totalVotesReliability to set */ public void setTotalVotesReliability(double totalVotesReliability) { this.totalVotesReliability = totalVotesReliability; } /** * @return the totalNormalisesVotesReliability */ public double getTotalNormalisesVotesReliability() { return totalNormalisesVotesReliability; } /** * @param totalNormalisesVotesReliability the totalNormalisesVotesReliability to set */ public void setTotalNormalisesVotesReliability(double totalNormalisesVotesReliability) { this.totalNormalisesVotesReliability = totalNormalisesVotesReliability; } /** * @return the validated */ public boolean isValidated() { return validated; } /** * @param validated the validated to set */ public void setValidated(boolean validated) { this.validated = validated; } /** * @return the lang */ public String getLang() { return lang; } /** * @param lang the lang to set */ public void setLang(String lang) { this.lang = lang; } /** * @return the langRevId */ public String getLangRevId() { return langRevId; } /** * @param langRevId the langRevId to set */ public void setLangRevId(String langRevId) { this.langRevId = langRevId; } /** * * @return */ public Revision getPreviousRevision() { return previousRevision; } /** * * @param previousRevision */ public void setPreviousRevision(Revision previousRevision) { this.previousRevision = previousRevision; } + public Set getVotes() { + return votes; + } + + public void setVotes(Set votes) { + this.votes = votes; + } + /* (non-Javadoc) - * @see java.lang.Object#toString() - */ + * @see java.lang.Object#toString() + */ @Override public String toString() { return "Revision [graphId=" + graphId + ", revid=" + revid + ", userid=" + userid + ", parentid=" + parentid + ", length=" + length + ", changeCoefficient=" + changeCoefficient + ", currentMeanVote=" + currentMeanVote + ", currentVotesReliability=" + currentVotesReliability + ", currentNormalisesVotesReliability=" + currentNormalisesVotesReliability + ", totalMeanVote=" + totalMeanVote + ", totalVotesReliability=" + totalVotesReliability + ", totalNormalisesVotesReliability=" + totalNormalisesVotesReliability + ", validated=" + validated + ", lang=" + lang + ", langRevId=" + langRevId + "]"; } } \ No newline at end of file diff --git a/src/main/java/org/wikitolearn/wikirating/model/TemporaryVote.java b/src/main/java/org/wikitolearn/wikirating/model/TemporaryVote.java new file mode 100644 index 0000000..af01ea5 --- /dev/null +++ b/src/main/java/org/wikitolearn/wikirating/model/TemporaryVote.java @@ -0,0 +1,58 @@ +package org.wikitolearn.wikirating.model; + +import org.neo4j.ogm.annotation.EndNode; +import org.neo4j.ogm.annotation.GraphId; +import org.neo4j.ogm.annotation.NodeEntity; + +/** + * This entity represents a Vote that has to be validating, + * connecting the user and the Revision after a fetch of the mediawiki api. + * Created by valsdav on 24/03/17. + */ +@NodeEntity (label="TempVote") +public class TemporaryVote { + @GraphId private Long graphId; + private double value; + private double reliability; + private int userid; + private int langRevId; + + public TemporaryVote(double value, double reliability, int userid, int langRevId) { + this.value = value; + this.reliability = reliability; + this.userid = userid; + this.langRevId = langRevId; + } + + public double getValue() { + return value; + } + + public void setValue(double value) { + this.value = value; + } + + public double getReliability() { + return reliability; + } + + public void setReliability(double reliability) { + this.reliability = reliability; + } + + public int getUserid() { + return userid; + } + + public void setUserid(int userid) { + this.userid = userid; + } + + public int getLangRevId() { + return langRevId; + } + + public void setLangRevId(int langRevId) { + this.langRevId = langRevId; + } +} diff --git a/src/main/java/org/wikitolearn/wikirating/model/User.java b/src/main/java/org/wikitolearn/wikirating/model/User.java index 03d0612..c626b60 100644 --- a/src/main/java/org/wikitolearn/wikirating/model/User.java +++ b/src/main/java/org/wikitolearn/wikirating/model/User.java @@ -1,150 +1,160 @@ /** * */ package org.wikitolearn.wikirating.model; import org.neo4j.ogm.annotation.GraphId; import org.neo4j.ogm.annotation.Index; import org.neo4j.ogm.annotation.NodeEntity; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import org.neo4j.ogm.annotation.Relationship; import java.util.Set; /** * @author aletundo, valsdav * */ @NodeEntity( label = "User") @JsonIgnoreProperties(ignoreUnknown = true) public class User { @GraphId private Long graphId; @JsonProperty("name") private String username; @Index(unique=true,primary = true) private int userid; private double votesReliability; private double contributesReliability; private double totalReliability; @Relationship( type="AUTHOR", direction = Relationship.OUTGOING) - private Set pagesAuthored; + private Set revisionsAuthored; + @Relationship( type="VOTE", direction = Relationship.OUTGOING) + private Set votes; /** * */ public User() {} /** * @param username * @param userid * @param votesReliability * @param contributesReliability * @param totalReliability */ public User(String username, int userid, double votesReliability, double contributesReliability, double totalReliability) { this.username = username; this.userid = userid; this.votesReliability = votesReliability; this.contributesReliability = contributesReliability; this.totalReliability = totalReliability; } /** * @return the username */ public String getUsername() { return username; } /** * @param username the username to set */ public void setUsername(String username) { this.username = username; } /** * @return the userid */ public int getUserid() { return userid; } /** * @param userid the userid to set */ public void setUserId(int userid) { this.userid = userid; } /** * @return the votesReliability */ public double getVotesReliability() { return votesReliability; } /** * @param votesReliability the votesReliability to set */ public void setVotesReliability(double votesReliability) { this.votesReliability = votesReliability; } /** * @return the contributesReliability */ public double getContributesReliability() { return contributesReliability; } /** * @param contributesReliability the contributesReliability to set */ public void setContributesReliability(double contributesReliability) { this.contributesReliability = contributesReliability; } /** * @return the totalReliability */ public double getTotalReliability() { return totalReliability; } /** * @param totalReliability the totalReliability to set */ public void setTotalReliability(double totalReliability) { this.totalReliability = totalReliability; } /** * * @return */ - public Set getPagesAuthored() { - return pagesAuthored; + public Set getRevisionsAuthored() { + return revisionsAuthored; } /** * - * @param pagesAuthored + * @param revisionsAuthored */ - public void setPagesAuthored(Set pagesAuthored) { - this.pagesAuthored = pagesAuthored; + public void setRevisionsAuthored(Set revisionsAuthored) { + this.revisionsAuthored = revisionsAuthored; + } + + public Set getVotes() { + return votes; + } + + public void setVotes(Set votes) { + this.votes = votes; } /* (non-Javadoc) - * @see java.lang.Object#toString() - */ + * @see java.lang.Object#toString() + */ @Override public String toString() { return "User [username=" + username + ", userid=" + userid + ", votesReliability=" + votesReliability + ", contributesReliability=" + contributesReliability + ", totalReliability=" + totalReliability + "]"; } } diff --git a/src/main/java/org/wikitolearn/wikirating/model/Vote.java b/src/main/java/org/wikitolearn/wikirating/model/Vote.java index f1af7d6..d95cfbb 100644 --- a/src/main/java/org/wikitolearn/wikirating/model/Vote.java +++ b/src/main/java/org/wikitolearn/wikirating/model/Vote.java @@ -1,69 +1,86 @@ /** * */ package org.wikitolearn.wikirating.model; -import org.neo4j.ogm.annotation.GraphId; -import org.neo4j.ogm.annotation.NodeEntity; +import com.oracle.webservices.internal.api.EnvelopeStyle; +import org.neo4j.ogm.annotation.*; /** * @author aletundo, valsdav * */ -@NodeEntity( label = "Vote") +@RelationshipEntity( type = "VOTE") public class Vote { @GraphId private Long graphId; private double value; private double reliability; - + @StartNode private User user; + @EndNode private Revision revision; /** * */ public Vote() {} /** * @param value * @param reliability */ public Vote(double value, double reliability) { this.value = value; this.reliability = reliability; } /** * @return the value */ public double getValue() { return value; } /** * @param value the value to set */ public void setValue(double value) { this.value = value; } /** * @return the reliability */ public double getReliability() { return reliability; } /** * @param reliability the reliability to set */ public void setReliability(double reliability) { this.reliability = reliability; } + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Revision getRevision() { + return revision; + } + + public void setRevision(Revision revision) { + this.revision = revision; + } + /* (non-Javadoc) - * @see java.lang.Object#toString() - */ + * @see java.lang.Object#toString() + */ @Override public String toString() { return "Vote [value=" + value + ", reliability=" + reliability + "]"; } }