Examples of TextBean


Examples of org.openqreg.bean.TextBean

   *            The text
   * @throws SQLException
   */
  public void saveText(String docName, String id, String isocode,
      Connection con, Timestamp created, String text) throws SQLException {
    TextBean texts = new TextBean();
    texts.setId(id);
    texts.setLanguageid(isocode); // getLangId(isocode));
    // If no iso code specified, assume Swedish
    if (isocode == null || isocode.equals("")) {
      texts.setLanguageid(SWEDISH_ISO);
    } else {
      texts.setLanguageid(isocode);
    }
    texts.setCreatedby(SYSTEM);
    texts.setTscreated(created);
    // texts.setOrdernr(new Integer(orderNr));
    texts.setDocument(docName);
    if (text.equals("")) {
      log.log(Level.WARN, "The text is empty, id: " + id + " isocode: "
          + isocode);
    }
    texts.setText(text);
    // texts.setType(type);
//    texts.remove(con);
    texts.create(con);
  }
View Full Code Here

Examples of org.openqreg.bean.TextBean

        con = dbCon != null ? dbCon : getConnection();

        // remove all old texts
        Collection<TextBean> col = TextFinder.findByDocument(dbCon,
            documentname);
        TextBean tBean = null;
        Iterator<TextBean> it = col.iterator();
        while(it.hasNext()) {
          tBean = it.next();
          // only remove texts of target language!
          if (tBean.getLanguageid().equals(targetlang)) {
            tBean.remove(con);
          }
        }
       
        // start iterating texts
        for (Iterator i = body.elementIterator(); i.hasNext();) {
View Full Code Here

Examples of org.openqreg.bean.TextBean

   *            The text
   * @throws SQLException
   */
  public void saveText(String docName, String id, String isocode,
      Connection con, Timestamp created, String text) throws SQLException {
    TextBean texts = new TextBean();
    texts.setId(id);
    texts.setLanguageid(isocode); // getLangId(isocode));
    // If no iso code specified, assume Swedish
    if (isocode == null || isocode.equals("")) {
      texts.setLanguageid(SWEDISH_ISO);
    } else {
      texts.setLanguageid(isocode);
    }
    texts.setCreatedby(SYSTEM);
    texts.setTscreated(created);
    // texts.setOrdernr(new Integer(orderNr));
    texts.setDocument(docName);
    if (text.equals("")) {
      log.log(Level.WARN, "The text is empty, id: " + id + " isocode: "
          + isocode);
    }
    texts.setText(text);
    // texts.setType(type);
    texts.remove(con);
    texts.create(con);
  }
View Full Code Here

Examples of org.openqreg.bean.TextBean

      throws SQLException {
    try {
      Timestamp tsCreated = new Timestamp(
          new GregorianCalendar().getTimeInMillis());
      String text = "";
      TextBean textBean = new TextBean();
      List<Node> labelList;
      String type, fullId = "";
      type = textNode.valueOf("@type");
      fullId = addType(id, type);

      // delete this text all languages
      // Collection<TextBean> col = TextFinder.findByTextid(con, fullId);
      // for (TextBean t : col) {
      // t.remove(con);
      // }

      labelList = textNode.selectNodes("label");
      for (Node labelNode : labelList) {
        textBean = new TextBean();
        textBean.setId(fullId);
        textBean.setLanguageid(labelNode.valueOf("@lang"));
        textBean.setCreatedby(SYSTEM);
        textBean.setTscreated(tsCreated);
        textBean.setDocument(getDocumentName());
        text = labelNode.getText();
        text.replaceAll("\n", " ").replaceAll("\t", "")
            .replaceAll("&lt;", "<").replaceAll("&gt;", ">");
        textBean.setText(text);
        textBean.create(con);
      }
    } catch (SQLException e) {
      log.log(Level.ERROR, "saveText: " + id + " text: " + ": " + e);
      throw (e);
    }
View Full Code Here

Examples of org.openqreg.bean.TextBean

            root.addAttribute("xsi:noNamespaceSchemaLocation",
                "http://www.ucr.uu.se/xmlschema/" + getSchema("textSchema"));
          
            root.addElement("documentname").setText(getDocumentName().equals("") ? "All texts" : getDocumentName());
           
      TextBean text;
      Element textElement = null;
      Element labelElement;
      String id, lastId = "", currentId = "";
      String type = "";
      int c = 0;
            for (Iterator it = col.iterator(); it.hasNext();) {
              c++;
        text = (TextBean) it.next();
        currentId = text.getId();
        if (lastId.equals(currentId) && textElement != null) {
          //If same id, different language
          labelElement = textElement.addElement("label");
          labelElement.setText(text.getText());
          labelElement.addAttribute("lang", text.getLanguageid());
        } else {
          textElement = root.addElement("text");
          if (currentId.lastIndexOf("_") == -1) {
            //No type was found
            log.log(Level.WARN, currentId + " has no type!");
            id = currentId;
          } else {
            //Type found from last underscore
            type = getType(currentId);
            if (type.equals("")) {
              //No type found, correct in the resulting xml later!
              id = currentId;
            } else {
              //Type found
              id = currentId.substring(0, currentId.lastIndexOf("_"));
            }
          }
          /*
          prefix = getPrefix(currentId);
          if (! prefix.equals("")) {
            textElement.addElement("prefix").setText(prefix);
            id = getId(true, currentId);
          } else {
            //No prefix
            id = getId(false, currentId);
          }*/
          textElement.addElement("id").setText(id);
          textElement.addElement("type").setText(type);
         
          labelElement = textElement.addElement("label");
          labelElement.setText(text.getText());
          labelElement.addAttribute("lang", text.getLanguageid());
          lastId = currentId;
        }
            }
            return newDocument;
           
View Full Code Here

Examples of org.openqreg.bean.TextBean

        // nothing
      }

      // System.out.println(period);

      TextBean textBean = null;
      // System.out.println("xxx5");

      Collection<TextBean> col = null;
      search = decode(search);
      search = "%" + search + "%";
      if (returnAll) {
        col = TextFinderBase.findAll();
      } else {
        col = TextFinder.specSearchByIdText(user, 500, search, search);
      }
      Iterator<TextBean> it = col.iterator();
      // System.out.println("xxx6");

      out.append(
          toXML("totalno", new Integer(col.size()).toString()));
      out.append("<status>");
      out.append("OK");
      out.append("</status>\n");
      out.append("<step>");
      out.append("SEARCH");
      out.append("</step>\n");
      out.append("<texts>\n");
      int i = 0;
      // while (it.hasNext() && i < 5) {
      while (it.hasNext()) {
        textBean = it.next();
        if (i >= pStart && i <= pEnd) {
          out.append("<entry>\n");
          out.append(
              toXML("id", textBean.getId().toString()));
          out.append(
              toXML("languageid", textBean.getLanguageid()));
          //out.append(toXML("text", textBean.getText()));
          out.append(toXML("text", encode(textBean.getText())));
          out.append(
              toXML("document", textBean.getDocument()));
          out.append(
              toXML("tscreated", textBean.getTscreated()
                  .toString().substring(0, 16)));
          if (null != textBean.getTsupdated()) {
            out.append(
                toXML("tsupdated", textBean.getTsupdated()
                    .toString().substring(0, 16)));
          } else {
            out.append(toXML("tsupdated", ""));
          }
          out.append(
              toXML("createdby", textBean.getCreatedby()));
          out.append(
              toXML("updatedby", textBean.getUpdatedby()));
          out.append("</entry>\n");
        }
        i++;
      }
      out.append("</texts>\n");
View Full Code Here

Examples of org.openqreg.bean.TextBean

    StringBuffer out = new StringBuffer();
    try {
      String id = incXML.substring(incXML.indexOf("<id>") + 4, incXML
          .indexOf("</id>"));

      TextBean textBean = null;

      Collection<TextBean> col = null;
      col = TextFinder.findByTextid(id);
      Iterator<TextBean> it = col.iterator();

      out.append(toXML("totalno", "1"));
      out.append("<status>");
      out.append("OK");
      out.append("</status>\n");
      out.append("<step>");
      out.append("GETONE");
      out.append("</step>\n");
      out.append("<texts>\n");

      // writes all but the rest of languages
      if (it.hasNext()) {
        textBean = it.next();
        out.append("<entry>\n");
        out.append(toXML("id", textBean.getId().toString()));
        // out.append(toXML("text", textBean.getText()));
        out.append(toXML("text", encode(textBean.getText())));
        out.append(toXML("document", textBean.getDocument()));
        out.append(toXML("tscreated", textBean.getTscreated()
            .toString().substring(0, 16)));
        if (null != textBean.getTsupdated()) {
          out.append(toXML("tsupdated", textBean.getTsupdated()
              .toString().substring(0, 16)));
        } else {
          out.append(toXML("tsupdated", ""));
        }
        out.append(toXML("createdby", textBean.getCreatedby()));
        out.append(toXML("updatedby", textBean.getUpdatedby()));
        out.append("<languages>\n");
        out.append(toXML(textBean.getLanguageid(), encode(textBean
            .getText())));

      }
      // if we have more languages write them
      while (it.hasNext()) {
        textBean = it.next();
        out.append(toXML(textBean.getLanguageid(), encode(textBean
            .getText())));
      }
      out.append("</languages>\n");
      out.append("</entry>\n");
      out.append("</texts>\n");
View Full Code Here

Examples of org.openqreg.bean.TextBean

  }

  protected String getDocuments() {
    StringBuffer out = new StringBuffer();
    try {
      TextBean textBean = null;

      Collection<TextBean> col = null;
      col = TextFinder.findUniqueDocuments();
      Iterator<TextBean> it = col.iterator();

      out.append(toXML("totalno", "x"));
      out.append("<status>");
      out.append("OK");
      out.append("</status>\n");
      out.append("<step>");
      out.append("GETDOCUMENTS");
      out.append("</step>\n");
      out.append("<documents>\n");

      while (it.hasNext()) {
        textBean = it.next();
        out.append(toXML("document", textBean.getDocument()));
      }
      out.append("</documents>\n");
    } catch (Exception e) {
      System.out.println("error.asfk");
      System.out.println("error" + e);
View Full Code Here

Examples of org.openqreg.bean.TextBean

    StringBuffer out = new StringBuffer();
    try {
      String id = incXML.substring(incXML.indexOf("<id>") + 4, incXML
          .indexOf("</id>"));

      TextBean textBean = null;

      Collection<TextBean> col = null;
      col = TextFinder.findByTextid(id);
      Iterator<TextBean> it = col.iterator();

      out.append(toXML("totalno", "1"));
      out.append("<status>");
      out.append("OK");
      out.append("</status>\n");
      out.append("<step>");
      out.append("GETONE");
      out.append("</step>\n");
      out.append("<texts>\n");

      // writes all but the rest of languages
      if (it.hasNext()) {
        textBean = it.next();
        out.append("<entry>\n");
        out.append(toXML("id", textBean.getId().toString()));
        out.append(toXML("text", textBean.getText()));
        out.append(toXML("document", textBean.getDocument()));
        out.append(
            toXML("tscreated", textBean.getTscreated().toString()
                .substring(0, 16)));
        if (null != textBean.getTsupdated()) {
          out.append(
              toXML("tsupdated", textBean.getTsupdated()
                  .toString().substring(0, 16)));
        } else {
          out.append(toXML("tsupdated", ""));
        }
        out.append(
            toXML("createdby", textBean.getCreatedby()));
        out.append(
            toXML("updatedby", textBean.getUpdatedby()));
        out.append("<languages>\n");
        out.append(
            toXML(textBean.getLanguageid(), textBean.getText()));

      }
      // if we have more languages write them
      while (it.hasNext()) {
        textBean = it.next();
        out.append(
            toXML(textBean.getLanguageid(), textBean.getText()));
      }
      out.append("</languages>\n");
      out.append("</entry>\n");
      out.append("</texts>\n");
    } catch (Exception e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.