Package com.cardence.lawshelf.model

Examples of com.cardence.lawshelf.model.Section


  private static final String SQL_UPDATE_SECTION = "update section set parent_section_id = ?, code_id = ?, heading = ?, short_heading = ?, source_reference = ?, section_sequence = ?, level_type = ?, level_position = ?, heading_text = ? where id = ?";
  private static final String SQL_CREATE_SECTION = "insert into section (parent_section_id, code_id, heading, short_heading, source_reference, section_sequence, level_type, level_position, heading_text) values (?, ?, ?, ?, ?, ?, ?, ?, ?) ";

  private static final class SectionMapper implements RowMapper<Section> {
    public Section mapRow(ResultSet rs, int rowNum) throws SQLException {
      Section section = new Section();

      Section parent = new Section();
      parent.setId(rs.getInt("parent_section_id"));
      section.setParentSectionId(parent.getId());
      section.setParent(parent);

      Code code = new Code();
      code.setId(rs.getInt("code_id"));
      section.setCode(code);
View Full Code Here


  }

  private Section convertSectionXml(
      com.cardence.lawshelf.model.xml.Section xmlSection, Section parent,
      Code code) {
    Section s = new Section();
    s.setHeading(xmlSection.getHeading());
    s.setTextHeading(xmlSection.getTitle());
    s.setLevelPosition("" + xmlSection.getLevelPosition());
    s.setLevelType(xmlSection.getLevelType());
    if (xmlSection.getSequence() != null) {
      s.setSectionSequence(xmlSection.getSequence().intValue());
    }
    s.setSourceReference(xmlSection.getReference());
    s.setShortHeading(xmlSection.getShortHeading());

    // set in the code
    s.setCode(code);
    s.setCodeId(code.getId());

    // set in the parent
    if (parent != null) {
      s.setParent(parent);
      s.setParentSectionId(parent.getId());
    }

    // store!
    this.storeSection(s);
View Full Code Here

  private static final String SQL_CREATE = "insert into content_full (section_id, content, format_type, is_only_notes) values (?,?,?,?)";

  private static final class ContentMapper implements RowMapper<ContentFull> {
    public ContentFull mapRow(ResultSet rs, int rowNum) throws SQLException {
      ContentFull c = new ContentFull();
      Section section = new Section();
      section.setId(rs.getInt("section_id"));
      c.setContent(rs.getString("content"));
      c.setSection(section);
      c.setSectionId(section.getId());
      c.setNotes(rs.getBoolean("is_only_notes"));
      c.setFormatType(rs.getString("format_type"));
      c.setId(rs.getInt("id"));
      return c;
    }
View Full Code Here

      + "values (?, ?, ?, ?, ?, ?, ?, ?, ?)";

  private static final class ContentMapper implements RowMapper<ContentPart> {
    public ContentPart mapRow(ResultSet rs, int rowNum) throws SQLException {
      ContentPart c = new ContentPart();
      Section section = new Section();
      section.setId(rs.getInt("section_id"));
      c.setSection(section);
      c.setSectionId(section.getId());
      c.setContent(rs.getString("content"));
      c.setContentSequence(rs.getInt("content_sequence"));
      c.setContentType(rs.getString("content_type"));
      c.setHeader(rs.getBoolean("is_heading"));
      c.setNotes(rs.getBoolean("is_notes"));
View Full Code Here

  private void storeSection(Section section) {
    assert section != null : "section is null";

    if (section.getId() == null) {
      Section foundSection = this.sectionDao
          .findSectionByCodeAndReference(section.getCodeId(),
              section.getSourceReference());

      if (foundSection != null) {
        // found one... update
        section.setId(foundSection.getId());
        this.sectionDao.updateSection(section);
        section.setIsNewRecord(Boolean.FALSE);
      } else {
        // did not find one... create
        Integer newId = this.sectionDao.createSection(section);
View Full Code Here

    this.isBody = true;
  }

  public void endBody() {

    Section priorSection = this.model.getSection();
    if (priorSection != null) {
      sectionEnd();
    }

    this.isBody = false;
View Full Code Here

      } else if (type.equals("AUTHORITIES-USC-TITLE-STATUS")) {
        code.setStatus(value);
        code.addAttribute(type, value);
      }
    } else if (this.isBody) {
      Section section = this.model.getSection();

      if (type.equals("documentid")) {

        this.addMetaNodesToSection(value);
        this.sectionStart(commentHtml);

      } else if (type.equals("field-start")) {
        this.fieldStart(value);
        this.startMetaNode(new MetaNode(value, "comment"));

      } else if (type.equals("field-end")) {
        this.fieldEnd(value);
        this.endMetaNode(value);

      } else if (type.equals("expcite")) {
        this.updateMetaNodeSectionTitle(value);
        if (section != null) {
          section.addAttribute(type, value);
        }

      } else if (type.equals("itempath")) {
        this.updateMetaNodeSectionTitle(value);
        if (section != null) {
          section.setSourceReference(value);
          section.addAttribute(type, value);
        }

      } else if (type.equals("itemsortkey")) {
        this.updateMetaNodeSectionTitle(value);
        if (section != null) {
          section.addAttribute(type, value);
        }
      }
    }
  }
View Full Code Here

   * wait till the sectionEnd() method to find the parent
   *
   * @param documentString
   */
  private void sectionStart(String documentString) {
    Section priorSection = this.model.getSection();

    if (priorSection != null) {
      // NOT THE FIRST - CLOSE THE PREVIOUS ONE
      sectionEnd();
    }
    // create a new one
    Section newSection = new UscSection();
    newSection.setCode(model.getCode());

    // process document text from comment
    String[] tokenString = StringUtils.tokenizeToStringArray(documentString, " ", true, true);
    for (String str : tokenString) {
      String[] documentElements = StringUtils.split(str, ":");
      if (documentElements == null) {
        log.debug("documentElements does not contain a ':' for string: " + str);
      } else {
        newSection.addAttribute(documentElements[0], documentElements[1]);
      }
    }

    // Is the previous element my parent???

View Full Code Here

   * OPERATION TO ADD THE DB PK ID AS THE PARENT
   *
   * - DB WRITE: SECTION PLUS ALL CONTENT (FULL AND PARTS)
   */
  private void sectionEnd() {
    Section currentSection = this.model.getSection();
    String itempath = currentSection.getSourceReference();

    // get the primary key for the "parent" section
    String[] pathelements = getItemPathElements(itempath);

    if (pathelements != null && pathelements.length > 0 && !pathelements[0].equals(itempath)) {
      pathelements = Arrays.copyOf(pathelements, pathelements.length - 1);

      // String parentItempath = "/"
      // + StringUtils.arrayToDelimitedString(pathelements, "/");

      String parentItempath = getParentItemPath(itempath);
      Integer parentPrimaryKey = this.model.findPrimaryKey(parentItempath);

      if (parentPrimaryKey == null && pathelements.length > 0) {
        // BUILD THE MISSING PARENT!!!
        this.buildMissingParentSection(parentItempath);
         parentPrimaryKey = this.model.findPrimaryKey(parentItempath);
      }
      String parentLevelPosition = this.model.findLevelPosition(parentItempath);
      Integer currentSequence = this.sectionSequenceTracker.get(parentItempath);
      Integer nextSequence = 1;
      if (currentSequence != null) {
        nextSequence = currentSequence + 1;
      }

      log.debug("looking for parent primary key: used itempath [" + itempath
          + "], converted to parent item path [" + parentItempath + "] found pk [" + parentPrimaryKey + "]");

      // add parent's primary key
      currentSection.setParentSectionId(parentPrimaryKey);
      currentSection.setSectionSequence(nextSequence);
      currentSection.setParentLevelPosition(parentLevelPosition);
      this.sectionSequenceTracker.put(parentItempath, nextSequence);
    }
    // SAVE SECTION
    persistence.storeSection(currentSection);

    // CONFIRM: ADD PK TO MODEL TRACKER
    assert currentSection.getId() != null : "Attempting to add a section's primary key, but it is null after a save";
    log.debug("Adding Primary Key for itempath->sectionId: " + itempath + "," + currentSection.getId());
    this.model.addPrimaryKeyMapping(itempath, currentSection.getId());
    this.model.addLevelPositionMapping(itempath, currentSection.getLevelPosition());
    this.sectionSequenceTracker.put(itempath, 0); // this is for any
                            // children

    // SAVE CONTENTS
    ContentFull contentFull = this.convertUscFieldsToContentFull(currentSection);
    List<ContentPart> contentPartList = this.convertUscFieldsToContentPartList(currentSection);

    // RULE: If content is ONLY NOTES, it almost always
    // (I have not seen an exception yet)
    // is all DIVS and TABLES...
    // VERY difficult to chop up into content parts... only store full for
    // now.
    persistence.storeContentFull(contentFull, (!currentSection.getIsNewRecord() == Boolean.TRUE));
    if (!contentFull.isNotes()) {
      persistence.storeContentParts(currentSection.getId(), contentFull.getId(), contentPartList,
          (!currentSection.getIsNewRecord() == Boolean.TRUE));
    }

    this.workingUscFieldList = null;
    this.currentUscField = null;

View Full Code Here

   */
  public void storeSection(Section section) {
    assert section != null : "section is null";

    if (section.getId() == null) {
      Section foundSection = this.sectionDao.findSectionByCodeAndReference(section.getCodeId(),
          section.getSourceReference());

      if (foundSection != null) {
        // found one... update
        section.setId(foundSection.getId());
        this.sectionDao.updateSection(section);
        section.setIsNewRecord(Boolean.FALSE);
      } else {
        // did not find one... create
        Integer newId = this.sectionDao.createSection(section);
View Full Code Here

TOP

Related Classes of com.cardence.lawshelf.model.Section

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.