Exemplo n.º 1
0
 Parser(String uri) {
   try {
     SAXParserFactory parserFactory = SAXParserFactory.newInstance();
     SAXParser parser = parserFactory.newSAXParser();
     ConfigHandler handler = new ConfigHandler();
     parser.getXMLReader().setFeature("http://xml.org/sax/features/validation", true);
     parser.parse(new File(uri), handler);
   } catch (IOException e) {
     System.out.println("Error reading URI: " + e.getMessage());
   } catch (SAXException e) {
     System.out.println("Error in parsing: " + e.getMessage());
   } catch (ParserConfigurationException e) {
     System.out.println("Error in XML parser configuration: " + e.getMessage());
   }
   System.out.println("Number of Persons : " + Person.numberOfPersons());
   nameLengthStatistics();
   System.out.println(
       "Number of Publications with authors/editors: " + Publication.getNumberOfPublications());
   System.out.println(
       "Maximum number of authors/editors in a publication: "
           + Publication.getMaxNumberOfAuthors());
   publicationCountStatistics();
   Person.enterPublications();
   Person.printCoauthorTable();
   Person.printNamePartTable();
   Person.findSimilarNames();
 }
 @Factory("publication33List")
 public void initPublication33List() {
   log.info("initPublication33List");
   publication33List = new HashMap<String, String>();
   for (Object o : em.createQuery("from " + "Publication").getResultList()) {
     Publication p = (Publication) o;
     publication33List.put(p.getName(), p.getId().toString());
   }
 }
Exemplo n.º 3
0
  @Test
  public void shouldEnsureThePublicationIsOpenBeforeReadingPosition() {
    publication.close();
    assertThat(publication.position(), is(Publication.CLOSED));

    final InOrder inOrder = Mockito.inOrder(conductorLock, conductor);
    inOrder.verify(conductorLock).lock();
    inOrder.verify(conductor).releasePublication(publication);
    inOrder.verify(conductorLock).unlock();
  }
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    JSONObject result = new JSONObject();
    PrintWriter out = response.getWriter();

    try {
      try {
        response.setContentType("text/html;charset=UTF-8");

        int idPublication =
            Integer.parseInt("" + request.getSession().getAttribute("idPublication"));
        String title = request.getParameter("title");
        String publicationIssue = request.getParameter("publicationIsse");
        String year = request.getParameter("year");
        String numberPage = request.getParameter("numberPage");
        String link = request.getParameter("link");
        String type = request.getParameter("type");
        String authors = request.getParameter("otherAuthors");
        String pAbstract = request.getParameter("abstract");

        HttpSession session = request.getSession();
        PhdStudent loggedPerson = (PhdStudent) session.getAttribute("phdStudent"); // da verificare

        Publication publication = new Publication();

        publication.setTitle(title);
        publication.setPublicationIssue(publicationIssue);
        publication.setYear(year);
        publication.setNumberPages(Integer.parseInt(numberPage));
        publication.setLink(link);
        publication.setType(type);
        publication.setAuthors(authors);
        publication.setAbstract(pAbstract);
        publication.setFkPhdstudent(loggedPerson.getfkAccount()); // da modificare ancora

        PublicationManager.getInstance().update(idPublication, publication);
        result.put("result", true);

        out.println("<script type=\"text/javascript\">");
        out.println("alert('La pubblicazione è stata modificata.');");
        out.println("location='publicationActivity.jsp';");
        out.println("</script>");
      } catch (SQLException ex) {
        Logger.getLogger(UpdatePublicationServlet.class.getName()).log(Level.SEVERE, null, ex);
        result.put("result", false);
      } catch (ClassNotFoundException ex) {
        Logger.getLogger(UpdatePublicationServlet.class.getName()).log(Level.SEVERE, null, ex);
      }
      out.write(result.toString());

    } catch (JSONException ex) {
      Logger.getLogger(UpdatePublicationServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Exemplo n.º 5
0
  @Test
  public void shouldNotUnmapBuffersBeforeLastRelease() throws Exception {
    publication.incRef();
    publication.close();

    verify(logBuffers, never()).close();

    final InOrder inOrder = Mockito.inOrder(conductorLock, conductor);
    inOrder.verify(conductorLock).lock();
    inOrder.verify(conductorLock).unlock();
    inOrder.verifyNoMoreInteractions();
  }
Exemplo n.º 6
0
  @Test
  public void shouldUnmapBuffersWithMultipleReferences() throws Exception {
    publication.incRef();
    publication.close();

    publication.close();

    final InOrder inOrder = Mockito.inOrder(conductorLock, conductor);
    inOrder.verify(conductorLock).lock();
    inOrder.verify(conductor).releasePublication(publication);
    inOrder.verify(conductorLock).unlock();
    inOrder.verifyNoMoreInteractions();
  }
Exemplo n.º 7
0
  @Before
  public void setUp() {
    when(publicationLimit.getVolatile()).thenReturn(2L * SEND_BUFFER_CAPACITY);
    when(logBuffers.termBuffers()).thenReturn(termBuffers);
    when(logBuffers.termLength()).thenReturn(TERM_MIN_LENGTH);
    when(logBuffers.metaDataBuffer()).thenReturn(logMetaDataBuffer);
    when(conductor.mainLock()).thenReturn(conductorLock);

    initialTermId(logMetaDataBuffer, TERM_ID_1);
    timeOfLastStatusMessage(logMetaDataBuffer, 0);

    for (int i = 0; i < PARTITION_COUNT; i++) {
      termBuffers[i] = new UnsafeBuffer(allocateDirect(TERM_MIN_LENGTH));
    }

    publication =
        new Publication(
            conductor,
            CHANNEL,
            STREAM_ID_1,
            SESSION_ID_1,
            publicationLimit,
            logBuffers,
            CORRELATION_ID);

    publication.incRef();

    initialiseTailWithTermId(logMetaDataBuffer, PARTITION_INDEX, TERM_ID_1);
  }
Exemplo n.º 8
0
  @Test
  public void shouldReleaseResourcesIdempotently() throws Exception {
    publication.close();
    publication.close();

    final InOrder inOrder = Mockito.inOrder(conductorLock, conductor);
    inOrder.verify(conductorLock).lock();
    inOrder.verify(conductor).releasePublication(publication);
    inOrder.verify(conductorLock).unlock();
    inOrder.verify(conductorLock).lock();
    inOrder.verify(conductorLock).unlock();
    inOrder.verifyNoMoreInteractions();
  }
Exemplo n.º 9
0
  private void readNext() throws XMLStreamException {
    Publication publication = new Publication();
    while (xmlEventReader.hasNext()) {
      XMLEvent xmlEvent = xmlEventReader.nextEvent();
      if (xmlEvent.isStartElement()) {
        StartElement startElement = xmlEvent.asStartElement();

        if (in_publication_types(startElement.getName().getLocalPart())) {
          publication = new Publication();
          publication.type = startElement.getName().getLocalPart();
          in_publication = true;
          continue;
        }

        if (in_publication && startElement.getName().getLocalPart().equals("title")) {
          xmlEvent = xmlEventReader.nextEvent();
          publication.title = xmlEvent.toString();
          continue;
        }
      }

      if (xmlEvent.isEndElement()) {
        if (in_publication_types(xmlEvent.asEndElement().getName().getLocalPart())) {
          if (publication.title != null && !publication.title.equals("")) {
            next_publications.add(publication);
          }
          publication = new Publication();
          in_publication = false;

          if (next_publications.size() >= BUFFER_SIZE) {
            break;
          }
        }
      }
    }
  }
Exemplo n.º 10
0
  @Test
  public void testGetOrcidWork() {
    String doi = "10.1029\\/2002JD002436";
    String title =
        "5 on chemistry and nitrate aerosol formation in the lower troposphere under photosmog conditions";
    String fullCitation =
        "Riemer, N, 2003, '5 on chemistry and nitrate aerosol formation in the lower troposphere under photosmog conditions', <i>Journal of Geophysical Research<\\/i>, vol. 30, no. D4, p. 1255.";
    String coins =
        "ctx_ver=Z39.88-2004&rft_val_fmt=info:ofi\\/fmt:kev:mtx:journal&rft_id=info:doi\\/10.1029\\/2002JD002436&rtf.genre=journal-article&rtf.spage=1255&rtf.date=2003&rtf.aulast=Riemer&rtf.aufirst=N.&rtf.auinit=N&rtf.atitle=5 on chemistry and nitrate aerosol formation in the lower troposphere under photosmog conditions&rtf.jtitle=Journal of Geophysical Research&rtf.volume=30&rtf.issue=D4";

    Publication publication = new Publication();
    publication.setDoi(doi);
    publication.setTitle(title);
    publication.setFullCitation(fullCitation);
    publication.setCoins(coins);

    OrcidWork orcidWork = publication.getOrcidWork();
    assertNotNull(orcidWork);
    assertEquals(
        doi,
        orcidWork
            .getWorkExternalIdentifiers()
            .getWorkExternalIdentifier()
            .get(0)
            .getWorkExternalIdentifierId()
            .getContent());
    assertEquals(
        WorkExternalIdentifierType.DOI,
        orcidWork
            .getWorkExternalIdentifiers()
            .getWorkExternalIdentifier()
            .get(0)
            .getWorkExternalIdentifierType());
    assertEquals(title, orcidWork.getWorkTitle().getTitle().getContent());
    assertEquals(fullCitation, orcidWork.getWorkCitation().getCitation());
    PublicationDate publicationDate = orcidWork.getPublicationDate();
    assertNotNull(publicationDate);
    assertEquals(null, publicationDate.getDay());
    assertEquals(null, publicationDate.getMonth());
    assertEquals("2003", publicationDate.getYear().getValue());
    assertEquals(1, orcidWork.getWorkContributors().getContributor().size());
    Contributor contributor = orcidWork.getWorkContributors().getContributor().get(0);
    assertEquals("Riemer N.", contributor.getCreditName().getContent());
    assertEquals(
        ContributorRole.AUTHOR, contributor.getContributorAttributes().getContributorRole());
    assertEquals(
        SequenceType.FIRST, contributor.getContributorAttributes().getContributorSequence());
  }
Exemplo n.º 11
0
 @Test
 public void shouldReportMaxMessageLength() {
   assertThat(
       publication.maxMessageLength(),
       is(FrameDescriptor.computeMaxMessageLength(TERM_MIN_LENGTH)));
 }
Exemplo n.º 12
0
 @Test
 public void shouldReportThatPublicationHasBeenConnectedYet() {
   when(conductor.isPublicationConnected(anyLong())).thenReturn(true);
   assertTrue(publication.isConnected());
 }
Exemplo n.º 13
0
 @Test
 public void shouldReportThatPublicationHasNotBeenConnectedYet() {
   when(publicationLimit.getVolatile()).thenReturn(0L);
   when(conductor.isPublicationConnected(anyLong())).thenReturn(false);
   assertFalse(publication.isConnected());
 }
Exemplo n.º 14
0
 @Test
 public void shouldEnsureThePublicationIsOpenBeforeClaim() {
   publication.close();
   final BufferClaim bufferClaim = new BufferClaim();
   assertThat(publication.tryClaim(SEND_BUFFER_CAPACITY, bufferClaim), is(Publication.CLOSED));
 }
Exemplo n.º 15
0
 @Test
 public void shouldEnsureThePublicationIsOpenBeforeOffer() {
   publication.close();
   assertTrue(publication.isClosed());
   assertThat(publication.offer(atomicSendBuffer), is(Publication.CLOSED));
 }
Exemplo n.º 16
0
 public void initDB() {
   Address var1 = new Address();
   var1.setStreet("Mekelweg");
   var1.setCity("Delft");
   var1.setPhone("015");
   Address Mekelweg4 = var1;
   Address var2 = new Address();
   var2.setStreet("Ringwade 1");
   var2.setCity("Nieuwegein");
   var2.setPhone("030");
   Address Ordina = var2;
   Person var3 = new Person();
   var3.setFullname("Eelco Visser");
   var3.setEmail("*****@*****.**");
   var3.setAddress(Mekelweg4);
   var3.setHomepage("http://www.eelcovisser.net");
   var3.setPhoto("/img/eelcovisser.jpg");
   Person EelcoVisser = var3;
   User var4 = new User();
   var4.setUsername("EelcoVisser");
   var4.setPassword("foo");
   var4.setPerson(EelcoVisser);
   EelcoVisser.setUser(var4);
   Person var5 = new Person();
   var5.setFullname("Arie van Deursen");
   var5.setEmail("*****@*****.**");
   var5.setAddress(Mekelweg4);
   var5.setHomepage("http://www.st.ewi.tudelft.nl/~arie/");
   var5.setPhoto("http://www.st.ewi.tudelft.nl/~arie/pictures/arie-in-delft-klein.jpg");
   Person ArieVanDeursen = var5;
   Person var6 = new Person();
   var6.setFullname("Jos Warmer");
   var6.setEmail("*****@*****.**");
   var6.setAddress(Ordina);
   var6.setHomepage("http://www.klasse.nl/who/cv-jos.html");
   var6.setPhoto("http://www.klasse.nl/who/images/jos.gif");
   Person JosWarmer = var6;
   ResearchProject var7 = new ResearchProject();
   var7.setFullname("Model-Driven Software Evolution");
   var7.setAcronym("MoDSE");
   Set var8 = new HashSet();
   var8.add(EelcoVisser);
   var8.add(ArieVanDeursen);
   var8.add(JosWarmer);
   var7.setMembers(var8);
   var7.setDescription(
       "The promise of model-driven engineering (MDE) is that the development and maintenance effort can be reduced by working at the model instead of the code level. Models define what is variable in a system, and code generators produce the functionality that is common in the application domain. The problem with model-driven engineering is that it can lead to a lock-in in the abstractions and generator technology adopted at project initiation. Software systems need to evolve, and systems built using model-driven approaches are no exception. What complicates model-driven engineering is that it requires multiple dimensions of evolution. In regular evolution, the modeling language is used to make the changes. In meta-model evolution, changes are required to the modeling notation. In platform evolution, the code generators and application framework change to reflect new requirements on the target platform. Finally, in abstraction evolution, new modeling languages are added to the set of (modeling) languages to reflect increased understanding of a technical or business domain. While MDE has been optimized for regular evolution, presently little or no support exists for metamodel, platform and abstraction evolution. It is this gap that this project proposes to address. The first fundamental premise of this proposal is that evolution should be a continuous process. Software development is a continuous search for recurring patterns, which can be captured using domain-specific modeling languages. After developing a number of systems using a particular meta-model, new patterns may be recognized that can be captured in a higher-level or richer meta-model. The second premise is that reengineering of legacy systems to the model-driven paradigm should be a special case of this continuous evolution, and should be performed incrementally. The goal of this project is to develop a systematic approach to model-driven software evolution. This approach includes methods, techniques, and underlying tool support. We will develop a prototype programming environment that assists software engineers with the introduction, development, and maintenance of models and domain-specific languages.");
   ResearchProject MoDSE = var7;
   Publication var9 = new Publication();
   var9.setTitle("Domain-Specific Language Engineering");
   List var10 = new ArrayList();
   var10.add(EelcoVisser);
   var9.setAuthors(var10);
   var9.setYear(2007);
   var9.setAbstract(
       "The goal of domain-specific languages (DSLs) is to increase the productivity of software engineers by abstracting from low-level boilerplate code. Introduction of DSLs in the software development process requires a smooth workflow for the production of DSLs themselves. This tutorial gives an overview of all aspects of DSL engineering: domain analysis, language design, syntax definition, code generation, deployment, and evolution, discussing research challenges on the way. The concepts are illustrated with DSLs for web applications built using several DSLs for DSL engineering: SDF for syntax definition, Stratego/XT for code generation, and Nix for software deployment.");
   Set var11 = new HashSet();
   var11.add(MoDSE);
   var9.setProjects(var11);
   Publication GTTSE07 = var9;
   Publication var12 = new Publication();
   var12.setTitle("Model-Driven Software Evolution: A Research Agenda");
   List var13 = new ArrayList();
   var13.add(ArieVanDeursen);
   var13.add(JosWarmer);
   var13.add(EelcoVisser);
   var12.setAuthors(var13);
   var12.setYear(2006);
   var12.setAbstract(
       "Software systems need to evolve, and systems built using model-driven approaches are no exception.  What complicates model-driven engineering is that it requires multiple dimensions of evolution. In regular evolution, the modeling language is used to make the changes. In meta-model evolution, changes are required to the modeling notation.  In platform evolution, the code generators and application framework change to reflect new requirements on the target platform. Finally, in abstraction evolution, new modeling languages are added to the set of (modeling) languages to reflect increased understanding of a technical or business domain.  While MDE has been optimized for regular evolution, presently little or no support exists for metamodel, platform and abstraction evolution. In this paper, we analyze the problems raised by the evolution of model-based software systems and identify challenges to be addressed by research in this area.");
   Set var14 = new HashSet();
   var14.add(MoDSE);
   var12.setProjects(var14);
   Publication MoDSE07 = var12;
   MoDSE.setProposal(MoDSE07);
   Set var15 = new HashSet();
   var15.add(MoDSE07);
   var15.add(GTTSE07);
   MoDSE.setPublications(var15);
   em.persist(MoDSE);
 }
Exemplo n.º 17
0
 @Test
 public void shouldReportInitialPosition() {
   assertThat(publication.position(), is(0L));
 }
Exemplo n.º 18
0
  /**
   * tiendv
   *
   * @param instancesData
   * @param pubA
   * @param pubB
   * @param Feature : select features
   * @param label
   * @return
   */
  public static Instance calculateVectorWithSelectFeatures(
      Instances instancesData,
      Publication pubA,
      Publication pubB,
      Feature selectFeature,
      String label) {
    AuthorSimilarity authorSimilarity = new AuthorSimilarity();
    AffiliationSimilarity affiliationSimilarity = new AffiliationSimilarity();
    CoAuthorSimilarity coAuthorSimilarity = new CoAuthorSimilarity();
    KeywordSimilarity keywordSimilarity = new KeywordSimilarity();
    InterestKeywordSimilarity interestKeywordSimilarity = new InterestKeywordSimilarity();
    int dimension = selectFeature.getNumberSelectFeature() + 1;
    Instance simple = new SparseInstance(dimension);

    if (selectFeature.getJcAuthorName() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.JC_AUTHOR_NAME),
          authorSimilarity.makeJaccardSimilarity(pubA, pubB));

    if (selectFeature.getJcAffiliation() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.JC_AFFILIATION),
          affiliationSimilarity.makeJaccardSimilarity(pubA, pubB));

    if (selectFeature.getJcCoAuthor() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.JC_CO_AUTHOR),
          coAuthorSimilarity.makeJaccardSimilarity(pubA, pubB));

    if (selectFeature.getJcKeyword() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.JC_KEYWORD),
          keywordSimilarity.makeJaccardSimilarity(pubA, pubB));

    if (selectFeature.getJcInterestingKeyword() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.JC_INTERESTING_KEYWORD),
          interestKeywordSimilarity.makeJaccardSimilarity(pubA, pubB));

    if (selectFeature.getLevenshteinAuthorname() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.LEVENSHTEIN_AUTHOR_NAME),
          authorSimilarity.makeLevenshteinSimilarity(pubA, pubB));

    if (selectFeature.getLevenshteinAffiliaiton() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.LEVENSHTEIN_AFFILIATION),
          affiliationSimilarity.makeLevenshteinSimilarity(pubA, pubB));

    if (selectFeature.getJaroAuthorName() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.JARO_AUTHOR_NAME),
          authorSimilarity.makeJaroSimilarity(pubA, pubB));

    if (selectFeature.getJaroAffiliation() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.JARO_AFFILIATION),
          affiliationSimilarity.makeJaroSimilarity(pubA, pubB));

    if (selectFeature.getJarowinklerAuthorName() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.JAROWINKLER_AUTHOR_NAME),
          authorSimilarity.makeJaroWinklerSimilarity(pubA, pubB));

    if (selectFeature.getJarowinklerAffiliaiton() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.JAROWIKLER_AFFILIATION),
          affiliationSimilarity.makeJaroWinklerSimilarity(pubA, pubB));

    if (selectFeature.getSmithWatermanAuthorName() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.SMITHWATERMAN_AUTHOR_NAME),
          authorSimilarity.makeSmithWatermanSimilarity(pubA, pubB));

    if (selectFeature.getSmithWatermanAffiliation() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.SMITHWATERMAN_AFFILIATION),
          affiliationSimilarity.makeSmithWatermanSimilarity(pubA, pubB));

    if (selectFeature.getMongeElkanAuthorName() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.MONGEELKAN_AUTHOR_NAME),
          authorSimilarity.makeMongeElkanSimilarity(pubA, pubB));

    if (selectFeature.getMongeElkanAffiliation() == true)
      simple.setValue(
          (Attribute) instancesData.attribute(Feature.MONGEELKAN_AFFILIATION),
          affiliationSimilarity.makeMongeElkanSimilarity(pubA, pubB));

    // Add more feature here
    int sum = pubA.getMainAuthor().getAuthorResult() + pubB.getMainAuthor().getAuthorResult();

    if (sum == 2)
      simple.setValue(
          (Attribute) instancesData.attribute(selectFeature.getNumberSelectFeature()), "same");
    else
      simple.setValue(
          (Attribute) instancesData.attribute(selectFeature.getNumberSelectFeature()), "diff");

    return simple;
  }