001/*
002 * Copyright 2008 The Kuali Foundation
003 * 
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * 
008 * http://www.opensource.org/licenses/ecl2.php
009 * 
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.ole.module.purap.businessobject;
017
018
019import org.apache.commons.lang.StringUtils;
020import org.kuali.ole.integration.purap.CapitalAssetLocation;
021import org.kuali.ole.integration.purap.CapitalAssetSystem;
022import org.kuali.ole.integration.purap.ItemCapitalAsset;
023import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
024
025import java.util.ArrayList;
026import java.util.LinkedHashMap;
027import java.util.List;
028
029public abstract class PurchasingCapitalAssetSystemBase extends PersistableBusinessObjectBase implements CapitalAssetSystem {
030
031    private Integer capitalAssetSystemIdentifier;
032    private String capitalAssetSystemDescription;
033    private boolean capitalAssetNotReceivedCurrentFiscalYearIndicator;
034    private String capitalAssetTypeCode;
035    private String capitalAssetManufacturerName;
036    private String capitalAssetModelDescription;
037    private String capitalAssetNoteText;
038    private List<ItemCapitalAsset> itemCapitalAssets;
039    private List<CapitalAssetLocation> capitalAssetLocations;
040    private CapitalAssetLocation newPurchasingCapitalAssetLocationLine;
041    private Integer capitalAssetCountAssetNumber;
042
043    public Integer getCapitalAssetCountAssetNumber() {
044        return capitalAssetCountAssetNumber;
045    }
046
047    public void setCapitalAssetCountAssetNumber(Integer capitalAssetCountAssetNumber) {
048        this.capitalAssetCountAssetNumber = capitalAssetCountAssetNumber;
049    }
050
051    public PurchasingCapitalAssetSystemBase() {
052        super();
053        itemCapitalAssets = new ArrayList();
054        capitalAssetLocations = new ArrayList();
055        this.setNewPurchasingCapitalAssetLocationLine(this.setupNewPurchasingCapitalAssetLocationLine());
056    }
057
058    public String getCapitalAssetSystemDescription() {
059        //This is needed because bean:define would throw error if capitalAssetSystemDescription is empty.
060        if (StringUtils.isEmpty(capitalAssetSystemDescription)) {
061            capitalAssetSystemDescription = new String(" ");
062        }
063        return capitalAssetSystemDescription;
064    }
065
066    public void setCapitalAssetSystemDescription(String capitalAssetSystemDescription) {
067        this.capitalAssetSystemDescription = capitalAssetSystemDescription;
068    }
069
070    public boolean isCapitalAssetNotReceivedCurrentFiscalYearIndicator() {
071        return capitalAssetNotReceivedCurrentFiscalYearIndicator;
072    }
073
074    public void setCapitalAssetNotReceivedCurrentFiscalYearIndicator(boolean capitalAssetNotReceivedCurrentFiscalYearIndicator) {
075        this.capitalAssetNotReceivedCurrentFiscalYearIndicator = capitalAssetNotReceivedCurrentFiscalYearIndicator;
076    }
077
078    public String getCapitalAssetTypeCode() {
079        return capitalAssetTypeCode;
080    }
081
082    public void setCapitalAssetTypeCode(String capitalAssetTypeCode) {
083        this.capitalAssetTypeCode = capitalAssetTypeCode;
084    }
085
086    public String getCapitalAssetManufacturerName() {
087        return capitalAssetManufacturerName;
088    }
089
090    public void setCapitalAssetManufacturerName(String capitalAssetManufacturerName) {
091        this.capitalAssetManufacturerName = capitalAssetManufacturerName;
092    }
093
094    public String getCapitalAssetModelDescription() {
095        return capitalAssetModelDescription;
096    }
097
098    public void setCapitalAssetModelDescription(String capitalAssetModelDescription) {
099        this.capitalAssetModelDescription = capitalAssetModelDescription;
100    }
101
102    public List<ItemCapitalAsset> getItemCapitalAssets() {
103        return itemCapitalAssets;
104    }
105
106    public void setItemCapitalAssets(List<ItemCapitalAsset> itemCapitalAssets) {
107        this.itemCapitalAssets = itemCapitalAssets;
108    }
109
110    public List<CapitalAssetLocation> getCapitalAssetLocations() {
111        return capitalAssetLocations;
112    }
113
114    public void setCapitalAssetLocations(List<CapitalAssetLocation> capitalAssetLocations) {
115        this.capitalAssetLocations = capitalAssetLocations;
116    }
117
118    public Integer getCapitalAssetSystemIdentifier() {
119        return capitalAssetSystemIdentifier;
120    }
121
122    public void setCapitalAssetSystemIdentifier(Integer capitalAssetSystemIdentifier) {
123        this.capitalAssetSystemIdentifier = capitalAssetSystemIdentifier;
124    }
125
126    public String getCapitalAssetNoteText() {
127        //This is needed because bean:define would throw error if capitalAssetNoteText is empty.
128        if (StringUtils.isEmpty(capitalAssetNoteText)) {
129            capitalAssetNoteText = new String(" ");
130        }
131        return capitalAssetNoteText;
132    }
133
134    public void setCapitalAssetNoteText(String capitalAssetNoteText) {
135        this.capitalAssetNoteText = capitalAssetNoteText;
136    }
137
138    public boolean isEmpty() {
139        return !(StringUtils.isNotEmpty(capitalAssetNoteText) || StringUtils.isNotEmpty(capitalAssetSystemDescription) || StringUtils.isNotEmpty(capitalAssetManufacturerName) || StringUtils.isNotEmpty(this.capitalAssetModelDescription) || StringUtils.isNotEmpty(capitalAssetTypeCode));
140    }
141
142    public abstract Class getItemCapitalAssetClass();
143
144    public abstract Class getCapitalAssetLocationClass();
145
146    //CAMS LOCATION   
147    public CapitalAssetLocation setupNewPurchasingCapitalAssetLocationLine() {
148        CapitalAssetLocation location = null;
149        try {
150            location = (CapitalAssetLocation) getCapitalAssetLocationClass().newInstance();
151        } catch (InstantiationException e) {
152            throw new RuntimeException("Unable to get class");
153        } catch (IllegalAccessException e) {
154            throw new RuntimeException("Unable to get class");
155        } catch (NullPointerException e) {
156            throw new RuntimeException("Can't instantiate Purchasing Account from base");
157        }
158
159        return location;
160    }
161
162    public void setNewPurchasingCapitalAssetLocationLine(CapitalAssetLocation newCapitalAssetLocationLine) {
163        this.newPurchasingCapitalAssetLocationLine = newCapitalAssetLocationLine;
164    }
165
166    public CapitalAssetLocation getNewPurchasingCapitalAssetLocationLine() {
167        return newPurchasingCapitalAssetLocationLine;
168    }
169
170    public CapitalAssetLocation getAndResetNewPurchasingCapitalAssetLocationLine() {
171        CapitalAssetLocation asset = getNewPurchasingCapitalAssetLocationLine();
172        setNewPurchasingCapitalAssetLocationLine(setupNewPurchasingCapitalAssetLocationLine());
173        return asset;
174    }
175
176    public void resetNewPurchasingCapitalAssetLocationLine() {
177        setNewPurchasingCapitalAssetLocationLine(setupNewPurchasingCapitalAssetLocationLine());
178    }
179
180    protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
181        LinkedHashMap m = new LinkedHashMap();
182        if (this.capitalAssetSystemIdentifier != null) {
183            m.put("capitalAssetSystemIdentifier", this.capitalAssetSystemIdentifier.toString());
184        }
185        return m;
186    }
187
188}