Changeset 19725 in main


Ignore:
Timestamp:
01/15/20 20:10:21 (6 months ago)
Author:
GarthBraithwaite_STG
Message:

java - another tweak to setting and saving published date.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ibisph/src/main/java/org/ibisph/indicatorprofile/springmvc/databean/PublishIndicatorToXMLFileController.java

    r19724 r19725  
    163163    Node indicatorDocument = null;
    164164
    165     // get the IP document.
     165    // if the published date is null or the status date is greater than the
     166    // published date (is being published after mods/approvals) then NEW PUBLISH
     167    // set the published date to now.  Else it's a republishing - leave pub date.
     168    // NOTE that this MUST be performed here so that the pub date will be set
     169    // when converting to the XML doc.  Later in this code the IP will be saved
     170    // to the db if publishing. 
     171    Date publishedDate = indicatorDataBean.getPublishedDate();
     172    Date statusDate    = indicatorDataBean.getStatusDate();
     173    boolean isNewPublishedDate = ((publishedDate == null) || statusDate.after(publishedDate));
     174    if(isNewPublishedDate && indicatorDataBean.isActive()) {
     175      indicatorDataBean.setFieldValue("PUBLISHED_DATE", new java.util.Date());
     176    }
     177
     178    // Now that the pub date is set (if new pub date) get the IP document.
    166179    try {
    167180      indicatorDocument = this.indicatorDataBeanToXMLService.getDocument(indicatorDataBean);
     
    176189    }
    177190
    178     // IF ACTIVE, then save the IP and IPV XML files.  Else delete them.  Update the published IPs XML doc.
     191    // IF ACTIVE the process the publishing.  If new pub date then save the IP
     192    // to the db.  Then save the IP and IPV XML files. 
     193    // IF NOT ACTIVE delete the files. 
     194    // Update the published IPs XML doc.
    179195    String indicatorProfileFilePathAndName = IOPath.concat(this.filePath, indicatorDataBean.getName() + ".xml", "/");
    180196    if(indicatorDataBean.isActive()) {
    181197      try {
    182 
    183         // if the published date is null or the status date is greater than the
    184         // published date (is being published after mods/approvals) then set the
    185         // published date to now.  Else it's a republishing - leave published
    186         // date as is but set return message to include it is being republished.
    187         Date publishedDate = indicatorDataBean.getPublishedDate();
    188         Date statusDate    = indicatorDataBean.getStatusDate();
    189         boolean isNewPublishedDate = ((publishedDate == null) || statusDate.after(publishedDate));
    190198        if(isNewPublishedDate) {
    191199          logger.debug(".processIndicatorProfile - Publishing - New Publish Date. ");
     200          this.dataBeanDAOService.save(indicatorDataBean);
     201          returnMessage.append("Published:  ");
    192202        }
    193203        else {
    194204          logger.debug(".processIndicatorProfile - Republishing - Status and Publish Date have not changed. ");
    195         }
    196 
     205          returnMessage.append("Republished:  ");
     206        }
    197207        this.documentDAOService.save(indicatorDocument, indicatorProfileFilePathAndName);
    198208        int i = processIndicatorViews(indicatorDocument, true);
    199         if(isNewPublishedDate) {
    200           indicatorDataBean.setFieldValue("PUBLISHED_DATE", new java.util.Date());
    201           this.dataBeanDAOService.save(indicatorDataBean);
    202           returnMessage.append("Published:  ");
    203         }
    204         else {
    205           returnMessage.append("Republished:  ");
    206         }
     209
    207210        returnMessage.append(indicatorDataBean.getName())
    208211          .append("  (views count: ")
Note: See TracChangeset for help on using the changeset viewer.