@Test public void testGetCirclePublicationsFromDatabase() throws FileNotFoundException, UnsupportedEncodingException { int count = 0; System.out.println("\n========== TEST 1 - Get Circle publication =========="); // Circle circle = persistenceStrategy.getCircleDAO().getById( // "e61d08f9-afd4-4600-9c16-78a62cdfbee0" ); List<Circle> circles = persistenceStrategy.getCircleDAO().getAll(); if (!circles.isEmpty()) for (Circle circle : circles) { PrintWriter writer = new PrintWriter( "C:/Users/Piro/Desktop/Circles/Circles/" + circle.getId() + ".txt", "UTF-8"); writer.println("Circle Name : " + circle.getName()); for (Publication publication : circle.getPublications()) { if (publication.getAbstractText() != null) { writer.println(publication.getTitle()); writer.println(publication.getAbstractText()); writer.println(); count++; } } writer.println(); writer.println(count); count = 0; writer.close(); } }
/** * Create a cluster for publications, based on language and year * * @param author * @param publicationClustersMap */ public void constructPublicationClusterByLanguageAndYear( Author author, Map<String, PublicationClusterHelper> publicationClustersMap) { // fill publication clusters // prepare calendar for publication year Calendar calendar = Calendar.getInstance(); // get all publications from specific author and put it into cluster for (Publication publication : author.getPublications()) { // only proceed publication that have date, language and abstract if (publication.getAbstractText() == null || publication.getAbstractText().equals("")) continue; if (publication.getPublicationDate() == null) continue; if (publication.getLanguage() == null) continue; // get publication year calendar.setTime(publication.getPublicationDate()); // construct clusterMap key String clusterMapKey = publication.getLanguage() + calendar.get(Calendar.YEAR); // construct publication map if (publicationClustersMap.get(clusterMapKey) == null) { // not exist create new cluster PublicationClusterHelper publicationCluster = new PublicationClusterHelper(); publicationCluster.setLangauge(publication.getLanguage()); publicationCluster.setYear(calendar.get(Calendar.YEAR)); publicationCluster.addPublicationAndUpdate(publication); // add into map publicationClustersMap.put(clusterMapKey, publicationCluster); } else { // exist on map, get the cluster PublicationClusterHelper publicationCluster = publicationClustersMap.get(clusterMapKey); publicationCluster.addPublicationAndUpdate(publication); } } }