1
2
3
4
5
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
21
22
23
24
25
26 public class MetaSetChangeAuditor implements SetChangedListener {
27
28 protected final Log logger = LogFactory.getLog(getClass());
29
30 private PicManFacade pmf;
31
32
33
34
35 public void setPicMan(PicManFacade pmf) {
36 this.pmf = pmf;
37 this.pmf.addSetChangedListener(this);
38 }
39
40
41
42
43 @Override
44 public void onSetChanged(SetSize ss) {
45 List<Set> list = this.pmf.getDB().getSets();
46 for (Set set : list) {
47 if (set.isMetaSet()) {
48 MetaSet ms = pmf.getDB().getMetaSet(set.getSid());
49 for (MetaSetRule msr : ms.getRules()) {
50 if (msr.getType() == MetaSet.NAME) {
51 if (msr.getValue().equals(ss.getSetName())) {
52 logger.info("MetaSet changed: " + set.getName());
53 SetSize mss = new SetSize(set.getName(), ss.getSize());
54 pmf.fireSetSizeChanged(mss);
55 break;
56 }
57 }
58 }
59 }
60 }
61 }
62
63 }