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.domains.enterprisemodel.storage.xmlfileimpl;
16:
17: import javax.xml.bind.JAXBException;
18:
19: import com.metaboss.enterprise.ps.PSDataSourceOperationInvocationException;
20: import com.metaboss.enterprise.ps.PSException;
21: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSEnterprise;
22: import com.metaboss.sdlctools.domains.enterprisemodel.storage.STEnterprise;
23: import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.EnterpriseDefType;
24: import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.SystemRefListType;
25:
26: // Local computer file system based implementation of the PSEnterprise
27: public class PSEnterpriseImpl implements PSEnterprise {
28: /* Returns enterprise entity corresponding to given reference or null struct if enterprise not found */
29: public STEnterprise getEnterprise(String pEnterpriseRef)
30: throws PSException {
31: EnterpriseDefType lEnterpriseDef = Storage
32: .getEnterprise(pEnterpriseRef);
33: if (lEnterpriseDef == null)
34: return null;
35: STEnterprise lStruct = new STEnterprise();
36: lStruct.EnterpriseRef = lEnterpriseDef.getEnterpriseRef();
37: lStruct.Description = lEnterpriseDef.getDescription();
38: return lStruct;
39: }
40:
41: /** Inserts new enterprise record into the database */
42: public void insertEnterprise(STEnterprise pRecord)
43: throws PSException {
44: try {
45: EnterpriseDefType lEnterpriseDef = Util.getObjectFactory()
46: .createEnterpriseDef();
47: lEnterpriseDef.setEnterpriseRef(pRecord.EnterpriseRef);
48: lEnterpriseDef.setDescription(pRecord.Description);
49: SystemRefListType lSystemRefList = Util.getObjectFactory()
50: .createSystemRefList();
51: lEnterpriseDef.setSystemRefList(lSystemRefList);
52: Storage.insertEnterprise(lEnterpriseDef);
53: } catch (JAXBException e) {
54: throw new PSDataSourceOperationInvocationException(e);
55: }
56: }
57:
58: /** Updates enterprise details in the database */
59: public void updateEnterprise(STEnterprise pUpdatedRecord)
60: throws PSException {
61: EnterpriseDefType lEnterpriseDef = Storage
62: .getEnterprise(pUpdatedRecord.EnterpriseRef);
63: if (lEnterpriseDef == null)
64: throw new PSException(
65: "Enterprise not found. EnterpriseRef : "
66: + pUpdatedRecord.EnterpriseRef);
67: lEnterpriseDef.setDescription(pUpdatedRecord.Description);
68: Storage.updateEnterprise(lEnterpriseDef);
69: }
70:
71: /** Deletes existing enterprise */
72: public void deleteEnterprise(String pEnterpriseRef)
73: throws PSException {
74: Storage.deleteEnterprise(pEnterpriseRef);
75: }
76:
77: /* Returns all system refs defined in this enterprise */
78: public String[] getAllSystemRefs(String pEnterpriseRef)
79: throws PSException {
80: return Storage.getEnterpriseSystemRefs(pEnterpriseRef);
81: }
82:
83: /* Returns all enterprises defined in this installation */
84: public String[] getAllEnterpriseRefs() throws PSException {
85: return Storage.getEnterpriseRefs();
86: }
87: }
|