On Sunday 29 June 2008 18:16, batosai at freenetproject.org wrote:
> Author: batosai
> Date: 2008-06-29 17:16:21 +0000 (Sun, 29 Jun 2008)
> New Revision: 20869
>
> Added:
> trunk/apps/WoT/src/plugins/WoT/Score.java
> Modified:
> trunk/apps/WoT/src/plugins/WoT/Identity.java
> Log:
> Added a class to handle Scores for an identity in a trust tree.
> Also made identities able to find their own score in a particular trust
tree.
>
> Modified: trunk/apps/WoT/src/plugins/WoT/Identity.java
> ===================================================================
> --- trunk/apps/WoT/src/plugins/WoT/Identity.java 2008-06-29 17:03:08 UTC
(rev 20868)
> +++ trunk/apps/WoT/src/plugins/WoT/Identity.java 2008-06-29 17:16:21 UTC
(rev 20869)
> @@ -22,6 +22,8 @@
> import org.xml.sax.SAXException;
>
> import com.db4o.ObjectContainer;
> +import com.db4o.ObjectSet;
> +import com.db4o.query.Query;
>
> /**
> * An identity as handled by the WoT (a SSK)
> @@ -78,7 +80,39 @@
> saxParser.parse(pis,new IdentityParser());
> }
>
> + public int getScore(OwnIdentity treeOwner, ObjectContainer db) {
> +
> + Query query = db.query();
> + query.constrain(Score.class);
> + query.descend("treeOwner").constrain(treeOwner);
> + query.descend("target").constrain(this);
Try adding .identity() to these two lines to match the exact pointer instead
of "similar objects".
> + ObjectSet<Score> score = query.execute();
> +
> + if(score.size() == 1) {
> + return score.next().getScore();
> + }
> + else {
> + return 0;
> + }
> + }
>
> + public int getRank(OwnIdentity treeOwner, ObjectContainer db) {
> +
> + Query query = db.query();
> + query.constrain(Score.class);
> + query.descend("treeOwner").constrain(treeOwner);
> + query.descend("target").constrain(this);
> + ObjectSet<Score> score = query.execute();
> +
> + if(score.size() == 1) {
> + return score.next().getRank();
> + }
> + else {
> + return -1;
> + }
> + }
> +
> +
> /**
> * @return requestURI
> */
>
> Added: trunk/apps/WoT/src/plugins/WoT/Score.java
> ===================================================================
> --- trunk/apps/WoT/src/plugins/WoT/Score.java (rev
0)
> +++ trunk/apps/WoT/src/plugins/WoT/Score.java 2008-06-29 17:16:21 UTC (rev
20869)
> @@ -0,0 +1,57 @@
> +/**
> + * This code is part of WoT, a plugin for Freenet. It is distributed
> + * under the GNU General Public License, version 2 (or at your option
> + * any later version). See http://www.gnu.org/ for details of the GPL.
> + */
> +package plugins.WoT;
> +
> +/**
> + * @author Julien Cornuwel (batosai at batosai.net) 0x61917D90
> + *
> + */
> +public class Score {
> +
> + private OwnIdentity treeOwner;
> + private Identity target;
> + private int score;
> + private int rank;
> +
> + public Score (OwnIdentity treeOwner, Identity target, int score, int
> rank)
{
> + this.treeOwner = treeOwner;
> + this.target = target;
> + this.score = score;
> + this.rank = rank;
> + }
> +
> + public OwnIdentity getTreeOwner() {
> + return treeOwner;
> + }
> +
> + public void setTreeOwner(OwnIdentity treeOwner) {
> + this.treeOwner = treeOwner;
> + }
> +
> + public Identity getTarget() {
> + return target;
> + }
> +
> + public void setTarget(Identity target) {
> + this.target = target;
> + }
> +
> + public int getScore() {
> + return score;
> + }
> +
> + public void setScore(int score) {
> + this.score = score;
> + }
> +
> + public int getRank() {
> + return rank;
> + }
> +
> + public void setRank(int rank) {
> + this.rank = rank;
> + }
> +}
>
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20080805/89d0a1ed/attachment.pgp>