01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.sdlctools.services.metadatamanagement.domainimplicitelementsmanagement;
16:
17: import java.util.Collection;
18: import java.util.Iterator;
19:
20: import javax.naming.Context;
21: import javax.naming.InitialContext;
22: import javax.naming.NamingException;
23:
24: import com.metaboss.enterprise.bo.BOException;
25: import com.metaboss.enterprise.bs.BSDomainObjectInvocationException;
26: import com.metaboss.enterprise.bs.BSException;
27: import com.metaboss.enterprise.bs.BSNamingAndDirectoryServiceInvocationException;
28: import com.metaboss.sdlctools.models.ModelRepository;
29: import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
30: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
31: import com.metaboss.sdlctools.services.metadatamanagement.BSDomainImplicitElementsManagement;
32:
33: // The only implementation we can think of at the moment
34: public class BSDomainImplicitElementsManagementImpl implements
35: BSDomainImplicitElementsManagement {
36: // Generates all necessary metadata
37: public void updateMetadataForSystem(String pSystemRef)
38: throws BSException {
39: try {
40: // Get the referenced objects from the model
41: Context lContext = new InitialContext();
42: ModelRepository lModelRepository = (ModelRepository) lContext
43: .lookup(ModelRepository.COMPONENT_URL);
44: MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) lModelRepository
45: .getDefaultModelExtent();
46: com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = (com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) lMetaBossModelPackage
47: .getModelElement().getByRef(pSystemRef);
48: Collection lProblems = lMetaBossModelPackage
49: .refVerifyConstraints(true);
50: lModelRepository.beginTransaction();
51: try {
52: Collection lDomains = lSystem.getDomains();
53: for (Iterator lDomainsIterator = lDomains.iterator(); lDomainsIterator
54: .hasNext();) {
55: Domain lDomain = (Domain) lDomainsIterator.next();
56: DatatypeMetadataGenerator.updateMetadata(lDomain);
57: // Selector metadata is now taken care of by assistant
58: // SelectorMetadataGenerator.updateMetadata(lDomain);
59: }
60: lModelRepository.commitTransaction();
61: lModelRepository.saveDefaultModel(true);
62: } finally {
63: if (lModelRepository.isInTransaction())
64: lModelRepository.rollbackTransaction();
65: }
66: } catch (NamingException e) {
67: throw new BSNamingAndDirectoryServiceInvocationException(e);
68: } catch (BOException e) {
69: throw new BSDomainObjectInvocationException(
70: "Exception caught during updating of enterprise domain support services metadata.",
71: e);
72: }
73: }
74:
75: // Generates all necessary metadata
76: public void updateMetadataForDomain(String pDomainRef)
77: throws BSException {
78: try {
79: // Get the referenced objects from the model
80: Context lContext = new InitialContext();
81: ModelRepository lModelRepository = (ModelRepository) lContext
82: .lookup(ModelRepository.COMPONENT_URL);
83: MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) lModelRepository
84: .getDefaultModelExtent();
85: Domain lDomain = (Domain) lMetaBossModelPackage
86: .getModelElement().getByRef(pDomainRef);
87: DatatypeMetadataGenerator.updateMetadata(lDomain);
88: // Selector metadata is now taken care of by assistant
89: // SelectorMetadataGenerator.updateMetadata(lDomain);
90: } catch (NamingException e) {
91: throw new BSNamingAndDirectoryServiceInvocationException(e);
92: } catch (BOException e) {
93: throw new BSDomainObjectInvocationException(
94: "Exception caught during updating of enterprise domain support services metadata.",
95: e);
96: }
97: }
98: }
|