View Javadoc
1   /*
2    * Copyright 2008-2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.module.purap.businessobject;
17  
18  import org.kuali.ole.integration.purap.CapitalAssetLocation;
19  import org.kuali.ole.integration.purap.CapitalAssetSystem;
20  import org.kuali.ole.integration.purap.ItemCapitalAsset;
21  
22  import java.util.LinkedHashMap;
23  
24  
25  /**
26   * @author Kuali Nervous System Team (kualidev@oncourse.iu.edu)
27   */
28  
29  public class PurchaseOrderCapitalAssetSystem extends PurchasingCapitalAssetSystemBase {
30  
31      private String documentNumber;
32  
33      /**
34       * Default constructor.
35       */
36      public PurchaseOrderCapitalAssetSystem() {
37          super();
38      }
39  
40      public PurchaseOrderCapitalAssetSystem(CapitalAssetSystem originalSystem) {
41          super();
42          if (originalSystem != null) {
43              this.setCapitalAssetSystemDescription(originalSystem.getCapitalAssetSystemDescription());
44              this.setCapitalAssetNotReceivedCurrentFiscalYearIndicator(originalSystem.isCapitalAssetNotReceivedCurrentFiscalYearIndicator());
45              this.setCapitalAssetTypeCode(originalSystem.getCapitalAssetTypeCode());
46              this.setCapitalAssetManufacturerName(originalSystem.getCapitalAssetManufacturerName());
47              this.setCapitalAssetModelDescription(originalSystem.getCapitalAssetModelDescription());
48              this.setCapitalAssetNoteText(originalSystem.getCapitalAssetNoteText());
49              populatePurchaseOrderItemCapitalAssets(originalSystem);
50              populateCapitalAssetLocations(originalSystem);
51              this.setCapitalAssetCountAssetNumber(originalSystem.getCapitalAssetCountAssetNumber());
52          }
53      }
54  
55      private void populatePurchaseOrderItemCapitalAssets(CapitalAssetSystem originalSystem) {
56          for (ItemCapitalAsset reqAsset : originalSystem.getItemCapitalAssets()) {
57              PurchaseOrderItemCapitalAsset poAsset = new PurchaseOrderItemCapitalAsset(reqAsset.getCapitalAssetNumber());
58              this.getItemCapitalAssets().add(poAsset);
59          }
60      }
61  
62      private void populateCapitalAssetLocations(CapitalAssetSystem originalSystem) {
63          for (CapitalAssetLocation reqLocation : originalSystem.getCapitalAssetLocations()) {
64              PurchaseOrderCapitalAssetLocation poLocation = new PurchaseOrderCapitalAssetLocation();
65              poLocation.setItemQuantity(reqLocation.getItemQuantity());
66              poLocation.setCampusCode(reqLocation.getCampusCode());
67              poLocation.setOffCampusIndicator(reqLocation.isOffCampusIndicator());
68              poLocation.setBuildingCode(reqLocation.getBuildingCode());
69              poLocation.setBuildingRoomNumber(reqLocation.getBuildingRoomNumber());
70              poLocation.setCapitalAssetLine1Address(reqLocation.getCapitalAssetLine1Address());
71              poLocation.setCapitalAssetCityName(reqLocation.getCapitalAssetCityName());
72              poLocation.setCapitalAssetStateCode(reqLocation.getCapitalAssetStateCode());
73              poLocation.setCapitalAssetPostalCode(reqLocation.getCapitalAssetPostalCode());
74              poLocation.setCapitalAssetCountryCode(reqLocation.getCapitalAssetCountryCode());
75              this.getCapitalAssetLocations().add(poLocation);
76          }
77      }
78  
79      public String getDocumentNumber() {
80          return documentNumber;
81      }
82  
83  
84      public Class getCapitalAssetLocationClass() {
85          return PurchaseOrderCapitalAssetLocation.class;
86      }
87  
88      @Override
89      public Class getItemCapitalAssetClass() {
90          return PurchaseOrderItemCapitalAsset.class;
91      }
92  
93      public void setDocumentNumber(String documentNumber) {
94          this.documentNumber = documentNumber;
95      }
96  
97      @Override
98      protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
99          LinkedHashMap m = new LinkedHashMap();
100         if (this.documentNumber != null) {
101             m.put("documentNumber", this.documentNumber.toString());
102         }
103         if (this.getCapitalAssetSystemIdentifier() != null) {
104             m.put("capitalAssetSystemIdentifier", this.getCapitalAssetSystemIdentifier().toString());
105         }
106         return m;
107     }
108 }