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.domains.enterprisemodel.storage.xmlfileimpl;
016:
017: import javax.xml.bind.JAXBException;
018:
019: import com.metaboss.enterprise.ps.PSDataSourceOperationInvocationException;
020: import com.metaboss.enterprise.ps.PSException;
021: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSSystem;
022: import com.metaboss.sdlctools.domains.enterprisemodel.storage.STSystem;
023: import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.ApplicationRefListType;
024: import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.DomainRefListType;
025: import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.ServicemoduleRefListType;
026: import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.SystemDefType;
027:
028: // Local computer file system based implementation of the PSSystem
029: public class PSSystemImpl implements PSSystem {
030: /* Returns system description entity corresponding to given reference or null struct if system not found */
031: public STSystem getSystem(String pSystemRef) throws PSException {
032: SystemDefType lSystemDef = Storage.getSystem(pSystemRef);
033: if (lSystemDef == null)
034: return null;
035: STSystem lStruct = new STSystem();
036: lStruct.SystemRef = lSystemDef.getSystemRef();
037: lStruct.Description = lSystemDef.getDescription();
038: return lStruct;
039: }
040:
041: /** Inserts new system record into the database */
042: public void insertSystem(STSystem pRecord) throws PSException {
043: try {
044: SystemDefType lSystemDef = Util.getObjectFactory()
045: .createSystemDef();
046: lSystemDef.setSystemRef(pRecord.SystemRef);
047: lSystemDef.setDescription(pRecord.Description);
048: DomainRefListType lDomainRefList = Util.getObjectFactory()
049: .createDomainRefList();
050: lSystemDef.setDomainRefList(lDomainRefList);
051: ServicemoduleRefListType lServicemoduleRefList = Util
052: .getObjectFactory().createServicemoduleRefList();
053: lSystemDef.setServicemoduleRefList(lServicemoduleRefList);
054: ApplicationRefListType lApplicationRefList = Util
055: .getObjectFactory().createApplicationRefList();
056: lSystemDef.setApplicationRefList(lApplicationRefList);
057: Storage.insertSystem(lSystemDef);
058: } catch (JAXBException e) {
059: throw new PSDataSourceOperationInvocationException(e);
060: }
061: }
062:
063: /** Updates system details in the database */
064: public void updateSystem(STSystem pUpdatedRecord)
065: throws PSException {
066: SystemDefType lSystemDef = Storage
067: .getSystem(pUpdatedRecord.SystemRef);
068: if (lSystemDef == null)
069: throw new PSException("System not found. SystemRef : "
070: + pUpdatedRecord.SystemRef);
071: lSystemDef.setDescription(pUpdatedRecord.Description);
072: Storage.updateSystem(lSystemDef);
073: }
074:
075: /** Deletes existing system */
076: public void deleteSystem(String pSystemRef) throws PSException {
077: Storage.deleteSystem(pSystemRef);
078: }
079:
080: /** Returns list of all datatypes defined in this enterprise */
081: public String[] getAllDatatypeRefs(String pSystemRef)
082: throws PSException {
083: return Storage.getSystemDatatypeRefs(pSystemRef);
084: }
085:
086: /** Returns list of all typetemplates defined in this enterprise */
087: public String[] getAllTypetemplateRefs(String pSystemRef)
088: throws PSException {
089: return Storage.getSystemTypetemplateRefs(pSystemRef);
090: }
091:
092: /* Returns list of all domain refs defined in the specified system */
093: public String[] getAllDomainRefs(String pSystemRef)
094: throws PSException {
095: SystemDefType lSystemDef = Storage.getSystem(pSystemRef);
096: if (lSystemDef == null)
097: return null;
098: return (String[]) lSystemDef.getDomainRefList().getDomainRef()
099: .toArray(
100: new String[lSystemDef.getDomainRefList()
101: .getDomainRef().size()]);
102: }
103:
104: /** Returns list of servicemodule references defined in the specified system */
105: public String[] getAllServicemoduleRefs(String pSystemRef)
106: throws PSException {
107: SystemDefType lSystemDef = Storage.getSystem(pSystemRef);
108: if (lSystemDef == null)
109: return null;
110: return (String[]) lSystemDef.getServicemoduleRefList()
111: .getServicemoduleRef().toArray(
112: new String[lSystemDef.getServicemoduleRefList()
113: .getServicemoduleRef().size()]);
114: }
115:
116: /** Returns list of appication references defined in the specified system */
117: public String[] getAllApplicationRefs(String pSystemRef)
118: throws PSException {
119: SystemDefType lSystemDef = Storage.getSystem(pSystemRef);
120: if (lSystemDef == null)
121: return null;
122: return (String[]) lSystemDef.getApplicationRefList()
123: .getApplicationRef().toArray(
124: new String[lSystemDef.getApplicationRefList()
125: .getApplicationRef().size()]);
126: }
127: }
|