Subversion Repositories SmartDukaan

Rev

Rev 78 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 78 Rev 99
Line 1... Line 1...
1
/**
1
/**
2
 * 
2
 * 
3
 */
3
 */
4
package in.shop2020.metamodel.util;
4
package in.shop2020.metamodel.util;
5
 
5
 
-
 
6
import java.util.ArrayList;
-
 
7
import java.util.List;
-
 
8
 
6
import in.shop2020.metamodel.definitions.BulletDefinition;
9
import in.shop2020.metamodel.definitions.BulletDefinition;
7
import in.shop2020.metamodel.definitions.Catalog;
10
import in.shop2020.metamodel.definitions.Catalog;
8
import in.shop2020.metamodel.definitions.CompositeDefinition;
11
import in.shop2020.metamodel.definitions.CompositeDefinition;
9
import in.shop2020.metamodel.definitions.DatatypeDefinition;
12
import in.shop2020.metamodel.definitions.DatatypeDefinition;
10
import in.shop2020.metamodel.definitions.DefinitionsContainer;
13
import in.shop2020.metamodel.definitions.DefinitionsContainer;
Line 29... Line 32...
29
	 * Expanded from DatatypeDefinition ID 
32
	 * Expanded from DatatypeDefinition ID 
30
	 */
33
	 */
31
	private DatatypeDefinition datatypeDefinition ;
34
	private DatatypeDefinition datatypeDefinition ;
32
	
35
	
33
	/**
36
	/**
34
	 * Expanded from unit ID
37
	 * List of Expanded from unit IDs
35
	 */
38
	 */
36
	private Unit unit;
39
	private List<Unit> units;
37
	
40
	
38
	/**
41
	/**
39
	 * Interpreted from type of DatatypeDefinition object. True if its 
42
	 * Interpreted from type of DatatypeDefinition object. True if its 
40
	 * Composite type.
43
	 * Composite type.
41
	 */
44
	 */
Line 58... Line 61...
58
		throws Exception {
61
		throws Exception {
59
		super(bulletDefinition.getDatatypeDefinitionID());
62
		super(bulletDefinition.getDatatypeDefinitionID());
60
		
63
		
61
		// Copy rest of the properties
64
		// Copy rest of the properties
62
		this.setDescription(bulletDefinition.getDescription());
65
		this.setDescription(bulletDefinition.getDescription());
63
		this.setUnitID(bulletDefinition.getUnitID());
66
		this.setUnitIDs(bulletDefinition.getUnitIDs());
64
		this.setLearned(bulletDefinition.isLearned());
67
		this.setLearned(bulletDefinition.isLearned());
65
		this.setMultivalue(bulletDefinition.isMultivalue());
68
		this.setMultivalue(bulletDefinition.isMultivalue());
66
		
69
		
67
		DefinitionsContainer defs = 
70
		DefinitionsContainer defs = 
68
			Catalog.getInstance().getDefinitionsContainer();
71
			Catalog.getInstance().getDefinitionsContainer();
Line 80... Line 83...
80
		}
83
		}
81
		else if(this.datatypeDefinition instanceof EnumDefinition) {
84
		else if(this.datatypeDefinition instanceof EnumDefinition) {
82
			this.isEnumerated = true;
85
			this.isEnumerated = true;
83
		}
86
		}
84
		
87
		
85
		// Expand unit id
88
		// Expand unit ids
86
		if(bulletDefinition.getUnitID() != 0L) {
89
		List<Long> unitIDs = bulletDefinition.getUnitIDs();
-
 
90
		
-
 
91
		if(unitIDs != null) {
-
 
92
			this.units = new ArrayList<Unit>();
-
 
93
			
-
 
94
			for(Long unitID : unitIDs) {
87
			this.unit = defs.getUnit(bulletDefinition.getUnitID());
95
				Unit unit = defs.getUnit(unitID);
-
 
96
				this.units.add(unit);
-
 
97
			}
88
		}
98
		}
89
	}
99
	}
90
 
100
 
91
	/**
101
	/**
92
	 * @return the datatypeDefinition
102
	 * @return the datatypeDefinition
Line 96... Line 106...
96
	}
106
	}
97
 
107
 
98
	/**
108
	/**
99
	 * @return the unit
109
	 * @return the unit
100
	 */
110
	 */
101
	public Unit getUnit() {
111
	public List<Unit> getUnits() {
102
		return this.unit;
112
		return this.units;
103
	}
113
	}
104
 
114
 
105
	/**
115
	/**
106
	 * @return the isComposite
116
	 * @return the isComposite
107
	 */
117
	 */
Line 121... Line 131...
121
	 */
131
	 */
122
	@Override
132
	@Override
123
	public String toString() {
133
	public String toString() {
124
		return "ExpandedBulletDefinition [datatypeDefinition="
134
		return "ExpandedBulletDefinition [datatypeDefinition="
125
				+ datatypeDefinition + ", isComposite=" + isComposite
135
				+ datatypeDefinition + ", isComposite=" + isComposite
126
				+ ", isEnumerated=" + isEnumerated + ", unit=" + unit
136
				+ ", isEnumerated=" + isEnumerated + ", units=" + units + "]";
127
				+ ", getDatatypeDefinitionID()=" + getDatatypeDefinitionID()
-
 
128
				+ ", getDescription()=" + getDescription() + ", getUnitID()="
-
 
129
				+ getUnitID() + ", isLearned()=" + isLearned()
-
 
130
				+ ", isMultivalue()=" + isMultivalue() + "]";
-
 
131
	}
137
	}
132
 
138
 
133
}
139
}