Changeset 6510


Ignore:
Timestamp:
Aug 11, 2014, 9:29:17 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

References #1786: Create one log entry for every changed property instead of building a comma-separated summary

Use ADD and REMOVE change type instead of CREATE/DELETE for changes that are not made on the main item. For example, when adding an annotation or data file to an item.

Location:
branches/3.3-stable
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-stable/src/core/net/sf/basedb/core/Update.java

    r6489 r6510  
    970970        if (info.startsWith("Annotation created: "))
    971971        {
    972           // Annotation created: <name> --> CREATE + Annotation[<name>]
     972          // Annotation created: <name> --> ADD + Annotation[<name>]
    973973          fixQuery.setString("ci", "Annotation[" + info.substring("Annotation created: ".length()) + "]");
    974           fixQuery.setInteger("ct", ChangeType.CREATE.getValue());
     974          fixQuery.setInteger("ct", ChangeType.ADD.getValue());
    975975        }
    976976        else if (info.startsWith("Annotation updated: "))
     
    982982        else if (info.startsWith("Annotation deleted: "))
    983983        {
    984           // Annotation deleted: <name> --> DELETE + Annotation[<name>]
     984          // Annotation deleted: <name> --> REMOVE + Annotation[<name>]
    985985          fixQuery.setString("ci", "Annotation[" + info.substring("Annotation deleted: ".length()) + "]");
    986           fixQuery.setInteger("ct", ChangeType.DELETE.getValue());
     986          fixQuery.setInteger("ct", ChangeType.REMOVE.getValue());
    987987        }
    988988        else if (info.startsWith("File created: "))
    989989        {
    990           // File created: <name> --> CREATE + File[<name>]
     990          // File created: <name> --> ADD + File[<name>]
    991991          fixQuery.setString("ci", "File[" + info.substring("File created: ".length()) + "]");
    992           fixQuery.setInteger("ct", ChangeType.CREATE.getValue());
     992          fixQuery.setInteger("ct", ChangeType.ADD.getValue());
    993993        }
    994994        else if (info.startsWith("File updated: "))
     
    10001000        else if (info.startsWith("File deleted: "))
    10011001        {
    1002           // File deleted: <name> --> DELETE + File[<name>]
     1002          // File deleted: <name> --> REMOVE + File[<name>]
    10031003          fixQuery.setString("ci", "File[" + info.substring("File deleted: ".length()) + "]");
    1004           fixQuery.setInteger("ct", ChangeType.DELETE.getValue());
     1004          fixQuery.setInteger("ct", ChangeType.REMOVE.getValue());
    10051005        }
    10061006        else if (info.startsWith("Updated: "))
  • branches/3.3-stable/src/core/net/sf/basedb/core/log/ChangeType.java

    r5054 r6510  
    3434  CREATE(1, "created"),
    3535  UPDATE(2, "updated"),
    36   DELETE(3, "deleted");
     36  DELETE(3, "deleted"),
     37  ADD(4, "added"),
     38  REMOVE(5, "removed");
    3739 
    3840  private final int value;
  • branches/3.3-stable/src/core/net/sf/basedb/core/log/db/AnnotationLogger.java

    r6358 r6510  
    3434import net.sf.basedb.core.data.ChangeHistoryDetailData;
    3535import net.sf.basedb.core.data.LoggableData;
     36import net.sf.basedb.core.log.ChangeType;
    3637import net.sf.basedb.core.log.EntityDetails;
    3738import net.sf.basedb.core.log.EntityLogger;
     
    124125    if (parentId == null) return;
    125126   
     127    ChangeType changeType = details.getChangeType();
     128    if (changeType == ChangeType.CREATE)
     129    {
     130      changeType = ChangeType.ADD;
     131    }
     132    else if (changeType == ChangeType.DELETE)
     133    {
     134      changeType = ChangeType.REMOVE;
     135    }
     136   
    126137    ChangeHistoryDetailData change = new ChangeHistoryDetailData();
    127     change.setChangeType(details.getChangeType().getValue());
     138    change.setChangeType(changeType.getValue());
    128139    change.setItemId(parentId);
    129140    change.setItemType(parentType);
  • branches/3.3-stable/src/core/net/sf/basedb/core/log/db/AnyToAnyLogger.java

    r6359 r6510  
    7979    String propertyPrefix = "Link["+link.getName()+"]";
    8080    ChangeType changeType = details.getChangeType();
    81    
     81    if (changeType == ChangeType.CREATE)
     82    {
     83      changeType = ChangeType.ADD;
     84    }
     85    else if (changeType == ChangeType.DELETE)
     86    {
     87      changeType = ChangeType.REMOVE;
     88    }
     89
    8290    boolean delegateLogging = false;
    8391    if (!factory.isLoggingDetailedProperties())
     
    107115          int toId = link.getToId();
    108116         
    109           if (changeType == ChangeType.CREATE)
     117          if (changeType == ChangeType.ADD)
    110118          {
    111119            change.setNewValue(createLoggableString(logControl, toType, toId));
    112120          }
    113           else if (changeType == ChangeType.DELETE)
     121          else if (changeType == ChangeType.REMOVE)
    114122          {
    115123            change.setOldValue(createLoggableString(logControl, toType, toId));
     
    136144    if (delegateLogging)
    137145    {
    138       List<ChangeHistoryDetailData> changes = details.toChangeDetails(parentType, parentId, propertyPrefix, details.getChangeType(), factory.isLoggingDetailedProperties(), factory.isLoggingOldPropertyValues());
     146      List<ChangeHistoryDetailData> changes = details.toChangeDetails(parentType, parentId, propertyPrefix, changeType, factory.isLoggingDetailedProperties(), factory.isLoggingOldPropertyValues());
    139147      dbLogManager.logChangeDetails(changes, details);
    140148    }
  • branches/3.3-stable/src/core/net/sf/basedb/core/log/db/FileSetMemberLogger.java

    r6359 r6510  
    126126    else
    127127    {
     128      if (changeType == ChangeType.CREATE)
     129      {
     130        changeType = ChangeType.ADD;
     131      }
     132      else if (changeType == ChangeType.DELETE)
     133      {
     134        changeType = ChangeType.REMOVE;
     135      }
     136
    128137      // Create a single entry with the file name
    129138      ChangeHistoryDetailData change = new ChangeHistoryDetailData();
     
    135144      {
    136145        String fileName = member.getFile().getName();
    137         if (changeType == ChangeType.CREATE)
     146        if (changeType == ChangeType.ADD)
    138147        {
    139148          change.setNewValue(fileName);
  • branches/3.3-stable/www/views/jobs/view_job.jsp

    r6504 r6510  
    582582              %>
    583583              <tbl:row>
    584                 <tbl:cell column="changeType"><%=change.getChangeType()%> <%=change.getItemType()%></tbl:cell>
     584                <tbl:cell column="changeType"><%=change.getChangeType()%></tbl:cell>
    585585                <tbl:cell column="item"><%=ChangeHistoryUtil.getItem(dc, change, false, false)%></tbl:cell>
    586586                <tbl:cell column="info"><%=HTML.encodeTags(change.getChangeInfo())%></tbl:cell>
Note: See TracChangeset for help on using the changeset viewer.