001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.sdlctools.services.metadatamanagement.domainsupportservicesmanagement;
016:
017: import java.util.Collection;
018: import java.util.Iterator;
019:
020: import javax.naming.Context;
021: import javax.naming.InitialContext;
022: import javax.naming.NamingException;
023:
024: import com.metaboss.enterprise.bo.BOException;
025: import com.metaboss.enterprise.bs.BSDomainObjectInvocationException;
026: import com.metaboss.enterprise.bs.BSException;
027: import com.metaboss.enterprise.bs.BSNamingAndDirectoryServiceInvocationException;
028: import com.metaboss.sdlctools.models.ModelRepository;
029: import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
030: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
031: import com.metaboss.sdlctools.services.metadatamanagement.BSDomainSupportServicesManagement;
032:
033: // The only implementation we can think of at the moment
034: public class BSDomainSupportServicesManagementImpl implements
035: BSDomainSupportServicesManagement {
036: // Generates all necessary metadata
037: public void updateMetadataForSystem(String pSystemRef)
038: throws BSException {
039: try {
040: // Get the referenced objects from the model
041: Context lContext = new InitialContext();
042: ModelRepository lModelRepository = (ModelRepository) lContext
043: .lookup(ModelRepository.COMPONENT_URL);
044: MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) lModelRepository
045: .getDefaultModelExtent();
046: com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lSystem = (com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) lMetaBossModelPackage
047: .getModelElement().getByRef(pSystemRef);
048: Collection lDomains = lSystem.getDomains();
049: lModelRepository.beginTransaction();
050: try {
051: for (Iterator lDomainsIterator = lDomains.iterator(); lDomainsIterator
052: .hasNext();) {
053: Domain lDomain = (Domain) lDomainsIterator.next();
054: DomainSupportServiceMetadataGenerator
055: .updateMetadata(lDomain);
056: }
057: lModelRepository.commitTransaction();
058: lModelRepository.saveDefaultModel(true);
059: } finally {
060: if (lModelRepository.isInTransaction())
061: lModelRepository.rollbackTransaction();
062: }
063: } catch (NamingException e) {
064: throw new BSNamingAndDirectoryServiceInvocationException(e);
065: } catch (BOException e) {
066: throw new BSDomainObjectInvocationException(
067: "Exception caught during updating of enterprise domain support services metadata.",
068: e);
069: }
070: }
071:
072: // Generates all necessary metadata
073: public void updateMetadataForDomain(String pDomainRef)
074: throws BSException {
075: try {
076: // Get the referenced objects from the model
077: Context lContext = new InitialContext();
078: ModelRepository lModelRepository = (ModelRepository) lContext
079: .lookup(ModelRepository.COMPONENT_URL);
080: MetaBossModelPackage lMetaBossModelPackage = (MetaBossModelPackage) lModelRepository
081: .getDefaultModelExtent();
082: Domain lDomain = (Domain) lMetaBossModelPackage
083: .getModelElement().getByRef(pDomainRef);
084: lModelRepository.beginTransaction();
085: try {
086: DomainSupportServiceMetadataGenerator
087: .updateMetadata(lDomain);
088: lModelRepository.commitTransaction();
089: lModelRepository.saveDefaultModel(true);
090: } finally {
091: if (lModelRepository.isInTransaction())
092: lModelRepository.rollbackTransaction();
093: }
094: } catch (NamingException e) {
095: throw new BSNamingAndDirectoryServiceInvocationException(e);
096: } catch (BOException e) {
097: throw new BSDomainObjectInvocationException(
098: "Exception caught during updating of enterprise domain support services metadata.",
099: e);
100: }
101: }
102: }
|