Package com.cardence.lawshelf.model

Examples of com.cardence.lawshelf.model.Section


    // Parent = subpart 5, but there is not a subpart 5
    // create subpart 5

    String[] pathelements = getItemPathElements(parentItemPath);
    String onlyHeadingWeCouldFigureOut = extractHeadingFromItemPath(pathelements, 0);
    Section newParentSection = new UscSection();
    newParentSection.setCode(model.getCode());
    newParentSection.setHeading(onlyHeadingWeCouldFigureOut);
    newParentSection.setShortHeading(onlyHeadingWeCouldFigureOut);
    newParentSection.setSourceReference(parentItemPath);
    newParentSection.addAttribute("itempath", parentItemPath);

    // in order to make this work right, we NEED the parent's parent
    // information to "fit" this in
    // LOOKUP PARENT'S PARENT
    String grampsItemPath = getParentItemPath(parentItemPath);
    String[] grampsPathElements = getItemPathElements(grampsItemPath);
    Integer grampsPrimaryKey = this.model.findPrimaryKey(grampsItemPath);

    if (grampsPrimaryKey == null && grampsPathElements.length > 0) {
      buildMissingParentSection(grampsItemPath);
    }

    String grampsLevelPosition = this.model.findLevelPosition(grampsItemPath);
    Integer grampsCurrentSequence = this.sectionSequenceTracker.get(grampsItemPath);
    Integer grampsNextSequence = 1;
    if (grampsCurrentSequence != null) {
      grampsNextSequence = grampsCurrentSequence + 1;
    }

    // add parent's parent information
    newParentSection.setParentSectionId(grampsPrimaryKey);
    newParentSection.setSectionSequence(grampsNextSequence);
    newParentSection.setParentLevelPosition(grampsLevelPosition);

    // STORE NEW SIMULATED PARENT
    persistence.storeSection(newParentSection);

    assert newParentSection.getId() != null : "Attempting to add a new parent section's primary key, but it is null after a save";
    log.debug("Adding Primary Key for itempath->sectionId: " + parentItemPath + "," + newParentSection.getId());
    this.model.addPrimaryKeyMapping(parentItemPath, newParentSection.getId());
    this.model.addLevelPositionMapping(parentItemPath, newParentSection.getLevelPosition());
    this.sectionSequenceTracker.put(parentItemPath, 0);
    // NEW PARENT IS NOW READY

    return newParentSection;
  }
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.