01: package org.andromda.metafacades.emf.uml2;
02:
03: import org.andromda.metafacades.uml.FilteredCollection;
04: import org.andromda.metafacades.uml.ModelElementFacade;
05: import org.andromda.metafacades.uml.UMLMetafacadeProperties;
06: import org.apache.commons.collections.CollectionUtils;
07: import org.apache.commons.lang.ObjectUtils;
08:
09: /**
10: * MetafacadeLogic implementation for
11: * org.andromda.metafacades.uml.PackageFacade.
12: *
13: * @see org.andromda.metafacades.uml.PackageFacade
14: */
15: public class PackageFacadeLogicImpl extends PackageFacadeLogic {
16: public PackageFacadeLogicImpl(
17: final org.eclipse.uml2.Package metaObject,
18: final String context) {
19: super (metaObject, context);
20: }
21:
22: /**
23: * @see org.andromda.metafacades.uml.PackageFacade#findModelElement(java.lang.String)
24: */
25: protected org.andromda.metafacades.uml.ModelElementFacade handleFindModelElement(
26: final java.lang.String fullyQualifiedName) {
27: Object modelElement = null;
28: if (this .logger.isDebugEnabled()) {
29: this .logger.debug("Looking for >> " + fullyQualifiedName);
30: }
31: modelElement = UmlUtilities
32: .findByFullyQualifiedName(
33: this .metaObject.eResource().getResourceSet(),
34: fullyQualifiedName,
35: ObjectUtils
36: .toString(this
37: .getConfiguredProperty(UMLMetafacadeProperties.NAMESPACE_SEPARATOR)),
38: true);
39: if (this .logger.isDebugEnabled()) {
40: this .logger.debug("Found: '" + modelElement + "'");
41: }
42: return (ModelElementFacade) this .shieldedElement(modelElement);
43: }
44:
45: /**
46: * @see org.andromda.metafacades.uml.PackageFacade#getClasses()
47: */
48: protected java.util.Collection handleGetClasses() {
49: return new FilteredCollection(this .metaObject
50: .getOwnedElements()) {
51: public boolean evaluate(final Object object) {
52: return object instanceof org.eclipse.uml2.Class;
53: }
54: };
55: }
56:
57: /**
58: * @see org.andromda.metafacades.uml.PackageFacade#getSubPackages()
59: */
60: protected java.util.Collection handleGetSubPackages() {
61: return this .metaObject.getNestedPackages();
62: }
63:
64: /**
65: * @see org.andromda.metafacades.uml.PackageFacade#getModelElements()
66: */
67: protected java.util.Collection handleGetModelElements() {
68: return CollectionUtils.collect(this .metaObject.getModel()
69: .allOwnedElements(), UmlUtilities.ELEMENT_TRANSFORMER);
70: }
71:
72: /**
73: * @see org.andromda.metafacades.uml.PackageFacade#getOwnedElements()
74: */
75: protected java.util.Collection handleGetOwnedElements() {
76: return CollectionUtils.collect(this.metaObject
77: .getOwnedMembers(), UmlUtilities.ELEMENT_TRANSFORMER);
78: }
79: }
|