Package org.openqreg.bean

Examples of org.openqreg.bean.TextBean


* @return A populated TextBean
*
* @throws SQLException
*/
protected static TextBean populate(ResultSet rs) throws SQLException {
TextBean valueObject = new TextBean();
valueObject.setAutoid((Long)rs.getObject(1));
valueObject.setId((String)rs.getObject(2));
valueObject.setLanguageid((String)rs.getObject(3));
valueObject.setText((String)rs.getObject(4));
valueObject.setDocument((String)rs.getObject(5));
valueObject.setTscreated((java.sql.Timestamp)rs.getObject(6));
valueObject.setTsupdated((java.sql.Timestamp)rs.getObject(7));
valueObject.setCreatedby((String)rs.getObject(8));
valueObject.setUpdatedby((String)rs.getObject(9));
return valueObject;
}
View Full Code Here


* @throws SQLException
*/
public static Collection<TextBean> findAll(Connection con) throws SQLException {
PreparedStatement pStmt = null;
ResultSet rs = null;
TextBean valueObject = null;
Collection<TextBean> col = Collections.synchronizedList(new ArrayList<TextBean>());
try{
pStmt = con.prepareStatement(FIND_ALL_STATEMENT);
rs = pStmt.executeQuery();
while (rs.next()){
valueObject = populate(rs);
valueObject.afterPopulate(con);
col.add(valueObject);
}
return col;
}finally{
if(null!=rs){
View Full Code Here

* @throws SQLException
*/
public static Object findByPrimaryKey(Connection con, PrimaryKey key) throws SQLException {
PreparedStatement pStmt = null;
ResultSet rs = null;
TextBean valueObject = null;
TextKey primaryKey = (TextKey) key;
try{
pStmt = con.prepareStatement(TextBeanBase.SELECT_STATEMENT);
pStmt.setObject(1, primaryKey.getAutoid());
rs = pStmt.executeQuery();
while (rs.next()){
valueObject = populate(rs);
valueObject.afterPopulate(con);
}
return valueObject;
}finally{
if(null!=rs){
rs.close();
View Full Code Here

      for (TextBean textBean : textCol) {
        textBean.remove(con);
      }

      // create new texts
      TextBean tempText = null;
      for (TransportText transportText : ttg.getTransportTextCol()) {
        tempText = new TextBean();
        tempText.setDocument(document);
        tempText.setId(textId);
        tempText.setText(transportText.getText());
        tempText.setLanguageid(transportText.getLanguageid());
        tempText.setCreatedby(userId);
        tempText.setUpdatedby(userId);
        tempText.setTscreated(now);
        tempText.setTsupdated(now);
        tempText.create(con);
      }

      con.commit();

    } catch (SQLException sqle) {
View Full Code Here

      String type = "";
     
      //remove all texts from this document
      Collection<TextBean> col = TextFinder.findByDocument(dbCon,
          documentName);
      TextBean tBean = null;
      Iterator<TextBean> it = col.iterator();
      while(it.hasNext()) {
        tBean = it.next();
        tBean.remove(con);
      }
     
      List<Node> labelList;
      for (int i = 0; i < list.size(); i++) {
        node = list.get(i);
View Full Code Here

   *            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

        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

   *            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

      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

            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

TOP

Related Classes of org.openqreg.bean.TextBean

Copyright © 2018 www.massapicom. 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.