001 /*
002 * Copyright 2011 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 */
016 package org.kuali.kfs.module.purap.businessobject;
017
018 import java.util.LinkedHashMap;
019
020 import org.kuali.kfs.integration.purap.CapitalAssetLocation;
021 import org.kuali.kfs.integration.purap.CapitalAssetSystem;
022 import org.kuali.kfs.integration.purap.ItemCapitalAsset;
023
024
025
026 /**
027 * @author Kuali Nervous System Team (kualidev@oncourse.iu.edu)
028 */
029
030 public class PurchaseOrderCapitalAssetSystem extends PurchasingCapitalAssetSystemBase {
031
032 private String documentNumber;
033
034 /**
035 * Default constructor.
036 */
037 public PurchaseOrderCapitalAssetSystem() {
038 super();
039 }
040
041 public PurchaseOrderCapitalAssetSystem(CapitalAssetSystem originalSystem) {
042 super();
043 if (originalSystem != null) {
044 this.setCapitalAssetSystemDescription(originalSystem.getCapitalAssetSystemDescription());
045 this.setCapitalAssetNotReceivedCurrentFiscalYearIndicator(originalSystem.isCapitalAssetNotReceivedCurrentFiscalYearIndicator());
046 this.setCapitalAssetTypeCode(originalSystem.getCapitalAssetTypeCode());
047 this.setCapitalAssetManufacturerName(originalSystem.getCapitalAssetManufacturerName());
048 this.setCapitalAssetModelDescription(originalSystem.getCapitalAssetModelDescription());
049 this.setCapitalAssetNoteText(originalSystem.getCapitalAssetNoteText());
050 populatePurchaseOrderItemCapitalAssets(originalSystem);
051 populateCapitalAssetLocations(originalSystem);
052 this.setCapitalAssetCountAssetNumber(originalSystem.getCapitalAssetCountAssetNumber());
053 }
054 }
055
056 private void populatePurchaseOrderItemCapitalAssets(CapitalAssetSystem originalSystem) {
057 for (ItemCapitalAsset reqAsset : originalSystem.getItemCapitalAssets()) {
058 PurchaseOrderItemCapitalAsset poAsset = new PurchaseOrderItemCapitalAsset(reqAsset.getCapitalAssetNumber());
059 this.getItemCapitalAssets().add(poAsset);
060 }
061 }
062
063 private void populateCapitalAssetLocations(CapitalAssetSystem originalSystem) {
064 for (CapitalAssetLocation reqLocation : originalSystem.getCapitalAssetLocations()) {
065 PurchaseOrderCapitalAssetLocation poLocation = new PurchaseOrderCapitalAssetLocation();
066 poLocation.setItemQuantity(reqLocation.getItemQuantity());
067 poLocation.setCampusCode(reqLocation.getCampusCode());
068 poLocation.setOffCampusIndicator(reqLocation.isOffCampusIndicator());
069 poLocation.setBuildingCode(reqLocation.getBuildingCode());
070 poLocation.setBuildingRoomNumber(reqLocation.getBuildingRoomNumber());
071 poLocation.setCapitalAssetLine1Address(reqLocation.getCapitalAssetLine1Address());
072 poLocation.setCapitalAssetCityName(reqLocation.getCapitalAssetCityName());
073 poLocation.setCapitalAssetStateCode(reqLocation.getCapitalAssetStateCode());
074 poLocation.setCapitalAssetPostalCode(reqLocation.getCapitalAssetPostalCode());
075 poLocation.setCapitalAssetCountryCode(reqLocation.getCapitalAssetCountryCode());
076 this.getCapitalAssetLocations().add(poLocation);
077 }
078 }
079
080 public String getDocumentNumber() {
081 return documentNumber;
082 }
083
084 @Override
085 public Class getCapitalAssetLocationClass() {
086 return PurchaseOrderCapitalAssetLocation.class;
087 }
088
089 @Override
090 public Class getItemCapitalAssetClass() {
091 return PurchaseOrderItemCapitalAsset.class;
092 }
093
094 public void setDocumentNumber(String documentNumber) {
095 this.documentNumber = documentNumber;
096 }
097
098 @Override
099 protected LinkedHashMap toStringMapper() {
100 LinkedHashMap m = new LinkedHashMap();
101 if (this.documentNumber != null) {
102 m.put("documentNumber", this.documentNumber.toString());
103 }
104 if (this.getCapitalAssetSystemIdentifier() != null) {
105 m.put("capitalAssetSystemIdentifier", this.getCapitalAssetSystemIdentifier().toString());
106 }
107 return m;
108 }
109 }