Revision: 1783
Author: [email protected]
Date: Tue Dec 15 16:31:12 2009
Log: Add a getFeaturedProject method. At this stage it simply returns a
random project.
http://code.google.com/p/simal/source/detail?r=1783
Modified:
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/model/jena/simal/JenaSimalRepository.java
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/rdf/ISimalRepository.java
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/unitTest/MockRepository.java
=======================================
---
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/model/jena/simal/JenaSimalRepository.java
Wed Nov 25 15:03:27 2009
+++
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/model/jena/simal/JenaSimalRepository.java
Tue Dec 15 16:31:12 2009
@@ -32,6 +32,7 @@
import java.net.URL;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Random;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
@@ -307,6 +308,28 @@
}
return projects;
}
+
+
+ /**
+ * Get a featured project. At the present time this will
+ * return a single random project from the repository.
+ *
+ * @return
+ * @throws SimalRepositoryException
+ */
+ public IProject getFeaturedProject() throws SimalRepositoryException {
+ IProject project;
+ Set<IProject> allProjects = getAllProjects();
+ Random rand = new Random();
+ int size = allProjects.size();
+ if (size > 0) {
+ int idx = rand.nextInt(size);
+ project = (IProject) allProjects.toArray()[idx];
+ } else {
+ project = null;
+ }
+ return project;
+ }
/**
* @refactor should be moved to ProjectService class
=======================================
---
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/rdf/ISimalRepository.java
Wed Nov 25 15:03:27 2009
+++
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/rdf/ISimalRepository.java
Tue Dec 15 16:31:12 2009
@@ -331,5 +331,15 @@
* @return true if the id is a valid Simal ID
*/
public boolean isValidSimalID(String id);
+
+
+ /**
+ * Get a featured project. At the present time this will
+ * return a single random project from the repository.
+ *
+ * @return
+ * @throws SimalRepositoryException
+ */
+ public IProject getFeaturedProject() throws SimalRepositoryException;
}
=======================================
---
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/unitTest/MockRepository.java
Sun Jun 28 15:08:08 2009
+++
/trunk/uk.ac.osswatch.simal.core/src/test/java/uk/ac/osswatch/simal/unitTest/MockRepository.java
Tue Dec 15 16:31:12 2009
@@ -307,5 +307,10 @@
// TODO Auto-generated method stub
return null;
}
+
+public IProject getFeaturedProject() throws SimalRepositoryException {
+ // TODO Auto-generated method stub
+ return null;
+}
}
--
You received this message because you are subscribed to the Google Groups
"Simal Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/simal-commits?hl=en.