Coverage Report - com.buckosoft.PicMan.business.MetaSetChangeAuditor
 
Classes in this File Line Coverage Branch Coverage Complexity
MetaSetChangeAuditor
0%
0/19
0%
0/10
3.5
 
 1  
 /******************************************************************************
 2  
  * MetaSetChangeAuditor - Listen for changes to sets in case a MetaSet has changed.
 3  
  * 
 4  
  * PicMan - The BuckoSoft Picture Manager in Java
 5  
  * Copyright(c) 2011 - Dick Balaska
 6  
  * 
 7  
  */
 8  
 package com.buckosoft.PicMan.business;
 9  
 
 10  
 import java.util.List;
 11  
 
 12  
 import org.apache.commons.logging.Log;
 13  
 import org.apache.commons.logging.LogFactory;
 14  
 
 15  
 import com.buckosoft.PicMan.domain.MetaSet;
 16  
 import com.buckosoft.PicMan.domain.MetaSetRule;
 17  
 import com.buckosoft.PicMan.domain.Set;
 18  
 import com.buckosoft.PicMan.domain.SetSize;
 19  
 
 20  
 /** Listen for changes to sets in case a MetaSet has changed.
 21  
  * @author Dick Balaska
 22  
  * @since 2011/12/30
 23  
  * @version $Revision: 1.1 $ <br> $Date: 2013/12/26 01:26:08 $
 24  
  * @see <a href="http://cvs.buckosoft.com/Projects/java/PicMan/PicMan/src/com/buckosoft/PicMan/business/MetaSetChangeAuditor.java">MetaSetChangeAuditor.java</a>
 25  
  */
 26  0
 public class MetaSetChangeAuditor implements SetChangedListener {
 27  
 
 28  0
         protected final Log logger = LogFactory.getLog(getClass());
 29  
 
 30  
         private        PicManFacade        pmf;
 31  
 
 32  
         /** Set the reference to the PicMan API.
 33  
          * @param pmf The PicManFacade
 34  
          */
 35  
         public        void setPicMan(PicManFacade pmf) {
 36  0
                 this.pmf = pmf;
 37  0
                 this.pmf.addSetChangedListener(this);
 38  0
         }
 39  
 
 40  
         /** If a set has changed, perhaps any MetaSets that reference this set have also changed.
 41  
          * @param ss The SetSize that is changing.
 42  
          */
 43  
         @Override
 44  
         public void onSetChanged(SetSize ss) {
 45  0
                 List<Set> list = this.pmf.getDB().getSets();
 46  0
                 for (Set set : list) {
 47  0
                         if (set.isMetaSet()) {
 48  0
                                 MetaSet ms = pmf.getDB().getMetaSet(set.getSid());
 49  0
                                 for (MetaSetRule msr : ms.getRules()) {
 50  0
                                         if (msr.getType() == MetaSet.NAME) {
 51  0
                                                 if (msr.getValue().equals(ss.getSetName())) {
 52  0
                                                         logger.info("MetaSet changed: " + set.getName());
 53  0
                                                         SetSize mss = new SetSize(set.getName(), ss.getSize());
 54  0
                                                         pmf.fireSetSizeChanged(mss);
 55  0
                                                         break;
 56  
                                                 }
 57  
                                         }
 58  0
                                 }
 59  
                         }
 60  0
                 }
 61  0
         }
 62  
 
 63  
 }