private void CheckOutAction() {
   String confirmMsg =
       member.getFirstName()
           + ":\nYou will checkout the book "
           + pub.getTitle()
           + ".\nPlease confirm!";
   int confirm =
       MessageBox.show(
           checkoutStage,
           confirmMsg,
           "Question dialog",
           MessageBox.ICON_QUESTION | MessageBox.YES | MessageBox.NO | MessageBox.DEFAULT_BUTTON2);
   // proceed if confirmed
   if (confirm == MessageBox.YES) {
     setLibraryMember(memberID.getText());
     if (saveCheckOutRecord()) {
       MessageBox.show(
           checkoutStage,
           "Check out successfully!",
           "Success Infomation",
           MessageBox.ICON_INFORMATION | MessageBox.OK | MessageBox.DEFAULT_BUTTON2);
     }
   }
 }
Example #2
0
  public void buildModel(Model model) {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = null;
    try {
      builder = factory.newDocumentBuilder();
    } catch (Exception e) {
      e.printStackTrace();
    }
    Document document = null;
    try {
      document = builder.parse("dblp.xml");
    } catch (SAXException | IOException e) {
      e.printStackTrace();
    }
    document.getDocumentElement().normalize();
    System.out.println("Root Element : " + document.getDocumentElement().getNodeName());
    NodeList nodeList = document.getElementsByTagName("article");
    System.out.println(nodeList.getLength());

    for (int temp = 0; temp < nodeList.getLength(); temp++) {
      Node node = nodeList.item(temp);
      // Identifying the child tag of employee encountered
      if (node.getNodeType() == Node.ELEMENT_NODE) {
        Publication pub = new Publication();

        pub.idkey = node.getAttributes().getNamedItem("key").getNodeValue();
        pub.mdate = node.getAttributes().getNamedItem("mdate").getNodeValue();

        NodeList childNodes = node.getChildNodes();
        for (int j = 0; j < childNodes.getLength(); j++) {
          Node cNode = childNodes.item(j);
          if (cNode.getNodeType() == Node.ELEMENT_NODE) {
            String content = cNode.getLastChild().getTextContent().trim();

            // replace all ' with space
            if (content.indexOf('\'') != -1) {
              content = content.replace("'", "''");
            }

            switch (cNode.getNodeName()) {
              case "author":
                pub.author.add(content);
                break;
              case "title":
                pub.title = content;
                break;
              case "pages":
                pub.pages = content;
                break;
              case "year":
                pub.year = content;
                break;
              case "volume":
                pub.volume = content;
                break;
              case "journal":
                pub.journal = content;
                break;
              case "number":
                pub.numbers = content;
                break;
              case "url":
                pub.url = content;
              case "ee":
                pub.ee = content;
                break;
            }
          }
        } // end of for and build a complete publication

        Resource resource = model.createResource(NS + pub.title);
        Property key = model.createProperty(NS + "key");
        Property mdate = model.createProperty(NS + "mdate");
        Property author = model.createProperty(NS + "author");
        Property pages = model.createProperty(NS + "pages");
        Property year = model.createProperty(NS + "year");
        Property volume = model.createProperty(NS + "volume");
        Property journal = model.createProperty(NS + "journal");
        Property number = model.createProperty(NS + "number");
        Property url = model.createProperty(NS + "url");
        Property ee = model.createProperty(NS + "ee");

        resource
            .addProperty(key, pub.idkey, XSDDatatype.XSDstring)
            .addProperty(mdate, pub.mdate, XSDDatatype.XSDstring)
            .addProperty(author, pub.authorToString(), XSDDatatype.XSDstring)
            .addProperty(pages, pub.pages, XSDDatatype.XSDstring)
            .addProperty(year, pub.year, XSDDatatype.XSDstring)
            .addProperty(volume, pub.volume, XSDDatatype.XSDstring)
            .addProperty(journal, pub.journal, XSDDatatype.XSDstring)
            .addProperty(number, pub.numbers, XSDDatatype.XSDstring)
            .addProperty(url, pub.url, XSDDatatype.XSDstring)
            .addProperty(ee, pub.ee, XSDDatatype.XSDstring);
      }
    }
  }