Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 282.47 KB | None | 0 0
  1. package com.lhs.Contract.bscs_core;
  2.  
  3. ///////////////////////////////////////////////////////////////////////////////
  4. //Copyright (c) 2004 LHS Telekom GmbH & Co. KG
  5. //
  6. //The copyright in this work is vested in LHS. The information contained in
  7. //this work (either in whole or in part) is confidential and must not be
  8. //modified, reproduced, disclosed or disseminated to others or used for
  9. //purposes other than that for which it is supplied, without the prior
  10. //written permission of LHS. If this work or any part hereof is furnished to
  11. //a third party by virtue of a contract with that party, use of this work by
  12. //such party shall be governed by the express contractual terms between LHS,
  13. //which is party to that contract and the said party.
  14. //
  15. //The information in this document is subject to change without notice and
  16. //should not be construed as a commitment by LHS. LHS assumes no
  17. //responsibility for any errors that may appear in this document. With the
  18. //appearance of a new version of this document all older versions become
  19. //invalid.
  20. //
  21. //All rights reserved.
  22. ///////////////////////////////////////////////////////////////////////////////
  23.  
  24. import java.math.BigDecimal;
  25. import java.sql.Timestamp;
  26. import java.util.*;
  27. import java.util.logging.Level;
  28.  
  29. import org.eclipse.persistence.descriptors.RelationalDescriptor;
  30. import org.eclipse.persistence.expressions.Expression;
  31. import org.eclipse.persistence.expressions.ExpressionBuilder;
  32. import org.eclipse.persistence.indirection.ValueHolder;
  33. import org.eclipse.persistence.indirection.ValueHolderInterface;
  34. import org.eclipse.persistence.queries.DirectReadQuery;
  35.  
  36. import com.lhs.ccb.func.ect.ComponentException;
  37. import com.lhs.ccb.func.ect.SystemException;
  38. import com.lhs.ccb.func.ect.ValidationException;
  39. import com.lhs.ccb.sfw.application.AbstractFactory;
  40. import com.lhs.ccb.sfw.application.ServiceContext;
  41. import com.lhs.ccb.sfw.domain.AbstractDomainObject;
  42. import com.lhs.ccb.sfw.domain.AbstractDomainObjectI;
  43. import com.lhs.ccb.sfw.domain.TransactionContext;
  44. import com.lhs.ccb.sfw.license.LicenseInitializer;
  45. import com.lhs.ccb.sfw.license.LicenseInitializer.LicenseFeature;
  46. import com.lhs.ccb.sfw.license.LicenseUtilsFacade;
  47. import com.lhs.ccb.sfw.persistence.FWPrimaryKeyFactory;
  48. import com.lhs.ccb.sfw.persistence.FWValueHolder;
  49. import com.lhs.ccb.sfw.utilities.CAASDateConverter;
  50. import com.lhs.ccb.sfw.utilities.CAASTimeConverter;
  51. import com.lhs.ccb.sfw.utilities.NullConversion;
  52. import com.lhs.ccb.sfw.utilities.ServerTime;
  53.  
  54. import com.lhs.Billing.bscs_core.BillMedium;
  55. import com.lhs.Billing.bscs_core.BillingAccount;
  56. import com.lhs.Billing.bscs_core.BillingAccountAssignment;
  57. import com.lhs.Billing.bscs_core.external.BillingAccountI;
  58. import com.lhs.Billing.bscs_core.external.BillingAdministratorI;
  59. import com.lhs.BusinessPartner.bscs_core.*;
  60. import com.lhs.BusinessPartner.bscs_core.external.CustomerOrgNodeI;
  61. import com.lhs.BusinessPartner.bscs_core.external.DealerOrgNodeI;
  62. import com.lhs.BusinessPartner.bscs_core.external.OrgNodeI;
  63. import com.lhs.BusinessPartner.bscs_core.external.OrgNodeStatusI;
  64. import com.lhs.BusinessPartnerEventManagement.bscs_core.BusinessPartnerEventManagementAdministrator;
  65. import com.lhs.BusinessPartnerEventManagement.bscs_core.BusinessPartnerEventMessage;
  66. import com.lhs.BusinessPartnerEventManagement.bscs_core.external.BusinessPartnerEventMessageI;
  67. import com.lhs.BusinessPartnerEventManagement.bscs_core.external.NLSSystemEventMessageDefinitionI;
  68. import com.lhs.BusinessPartnerEventManagement.bscs_core.external.SystemEventMessageDefinitionI;
  69. import com.lhs.CommonDomain.Parameter.bscs_core.Parameter;
  70. import com.lhs.CommonDomain.Parameter.bscs_core.ParameterValueNode;
  71. import com.lhs.CommonDomain.Parameter.bscs_core.external.ParameterValueNodeI;
  72. import com.lhs.CommonDomain.bscs_core.BusinessUnit;
  73. import com.lhs.CommonDomain.bscs_core.CMSUser;
  74. import com.lhs.CommonDomain.bscs_core.DomainService;
  75. import com.lhs.CommonDomain.bscs_core.external.GMDActionI;
  76. import com.lhs.CommonDomain.bscs_core.external.KeyValueI;
  77. import com.lhs.CommonDomain.bscs_core.external.LogicalI;
  78. import com.lhs.CommonDomain.bscs_core.external.ReasonI;
  79. import com.lhs.Contract.bscs_core.SharedAccountPackageAssignment.Role;
  80. import com.lhs.Contract.bscs_core.external.*;
  81. import com.lhs.Contract.bscs_core.persistence.PContractPamScheme;
  82. import com.lhs.FrameworkExtension.bscs_core.NLSAdministrator;
  83. import com.lhs.FrameworkExtension.bscs_core.PluginAdministrator;
  84. import com.lhs.FrameworkExtension.bscs_core.PluginEvent;
  85. import com.lhs.Pricing.bscs_core.external.PricingSchemeI;
  86. import com.lhs.Product.bscs_core.*;
  87. import com.lhs.Product.bscs_core.external.*;
  88. import com.lhs.Product.bscs_core.persistence.PPamClass;
  89. import com.lhs.Resource.bscs_core.Attributes;
  90. import com.lhs.Resource.bscs_core.PhoneNumber;
  91. import com.lhs.Resource.bscs_core.PhoneNumberPortingInformation;
  92. import com.lhs.Resource.bscs_core.ResourceAdministrator;
  93. import com.lhs.Resource.bscs_core.external.*;
  94. import com.lhs.TaskManagement.bscs_core.*;
  95. import com.lhs.TaskManagement.bscs_core.external.ActionDetailsI;
  96. import com.lhs.TaskManagement.bscs_core.external.TaskI;
  97. import com.lhs.TaskManagement.bscs_core.external.TaskTypeI;
  98. import com.lhs.Topology.bscs_core.Instance;
  99. import com.lhs.Topology.bscs_core.Network;
  100. import com.lhs.Topology.bscs_core.TopologyAdministrator;
  101. import com.lhs.Topology.bscs_core.external.PrepaidProfileI;
  102. import com.lhs.Topology.bscs_core.external.TechnologyI;
  103. import com.lhs.Topology.bscs_core.external.TelecomTechnologyI;
  104. import com.lhs.cms.AdministratorFactory;
  105. import com.lhs.cms.billing.domain.BillingAccountAssignmentTemplateRule;
  106.  
  107. /**
  108. * File : Contract.java
  109. * Classes : Contract
  110. * Interfaces : None
  111. *
  112. * @author C.Kaiser
  113. */
  114. public class Contract extends AbstractDomainObject implements ContractI
  115. {
  116. /**
  117. * Constant for the jWhat tool, do not delete or modify.
  118. */
  119. @SuppressWarnings("hiding")
  120. public final static String WHAT_ID = "%Z%%W%, %I%, %E%";
  121.  
  122. /**
  123. * Reference to the contract type.
  124. * CONTRACT_ALL.CONTRACT_TYPE_ID
  125. */
  126. ValueHolderInterface _contractType = new ValueHolder();
  127.  
  128. /**
  129. * Date, the TIMM has been generated. Linked to CONTRACT_ALL.PRODUCT_HISTORY_DATE
  130. */
  131. protected java.sql.Timestamp _timmGenerationDate = NullConversion.TIMESTAMP_NULL_VALUE;
  132. /**
  133. * Date, when the contract will be canceled prospectivly. Linked to CONTRACT_ALL.CO_EXPIR_DATE
  134. */
  135. protected java.sql.Timestamp _expirationDate = NullConversion.TIMESTAMP_NULL_VALUE;
  136.  
  137. /**
  138. * PrimaryKey of the contract.
  139. * Linked to CONTRACT_ALL.CO_ID (CustomerContract)
  140. */
  141. public long _id = NullConversion.LONG_NULL_VALUE;
  142.  
  143. /**
  144. * Counter for multiuser access Linked to CONTRACT_ALL.REC_VERSION
  145. */
  146. protected java.math.BigDecimal _recordVersion = INIT_REC_VERSION;
  147.  
  148. /**
  149. * External key of the contract
  150. * Linked to CONTRACT_ALL.CO_CODE
  151. */
  152. protected String _code = NullConversion.STRING_NULL_VALUE;
  153. /**
  154. * Type of Contract: 'S' -> sales contract (normal customer contract) 'A' -> Agreement contract Linked to CONTRACT_ALL.TYPE
  155. */
  156. protected String _type = NullConversion.STRING_NULL_VALUE;
  157.  
  158. /**
  159. * agreement type
  160. * "SP": Service Provider Agreement
  161. * "IC": Inter-exchange Carrier Agreement
  162. * "EC": Exchange Carrier Agreement
  163. * "RA": Roaming Agreement
  164. * "CA": CIBER Roaming Agreement
  165. * "DC": Dealer agreement (new value because dealer contract do not exist in previous releases)
  166. * "MO": MVNO agreement
  167. * "CP": content provider
  168. * "": other kind of contract
  169. * Linked to CONTRACT_ALL.AGREEMENT_TYPE (still needed on db level but not exposed through the SOI)
  170. */
  171. protected String _agreementType = NullConversion.STRING_NULL_VALUE;
  172.  
  173. /**
  174. * Date, the contract has been signed.
  175. * Linked to CONTRACT_ALL.CO_SIGNED (CustomerContract)
  176. */
  177. protected Date _signingDate = NullConversion.DATE_NULL_VALUE;
  178.  
  179. /**
  180. * Date, when the contract has been entered.
  181. * Linked to CONTRACT_ALL.CO_ENTDATE (CustomerContract)
  182. */
  183. protected Date _creationDate = NullConversion.DATE_NULL_VALUE;
  184.  
  185. /**
  186. * _statusValidFromDate
  187. * Date, when the status change will be valid
  188. * Linked to CONTRACT_ALL.CH_STATUS_VALIDFROM
  189. */
  190. protected Timestamp _statusValidFromDate = NullConversion.TIMESTAMP_NULL_VALUE;
  191.  
  192. /**
  193. * _contractHolder- used as second party
  194. * Business partner, to which this contract is assigned
  195. * Linked to CONTRACT_ALL.CUSTOMER_ID (CustomerContract)
  196. *
  197. * @see com.lhs.BusinessPartner.bscs_core.OrgNode
  198. */
  199. protected ValueHolderInterface _contractHolder = new ValueHolder();
  200.  
  201. /**
  202. * The first contract holder
  203. */
  204. protected ValueHolderInterface _firstContractHolder = new ValueHolder();
  205.  
  206. /**
  207. * Internal class holding references to all ContractSections
  208. * assigned to the contract.
  209. *
  210. * @see com.lhs.Contract.bscs_core.CompositeContractSection
  211. */
  212. protected CompositeContractSection _compositeContractSection;
  213.  
  214. /**
  215. * the id of the business unit the contract is assigned to
  216. */
  217. protected long _businessUnitId = NullConversion.LONG_NULL_VALUE;
  218.  
  219. /**
  220. * description of the contract
  221. */
  222. protected String _description = NullConversion.STRING_NULL_VALUE;
  223.  
  224. /**
  225. * Date, the contract has been activated for the first time. Linked to CONTRACT_ALL.CO_ACTIVATED
  226. */
  227. protected java.sql.Timestamp _activationDate = NullConversion.TIMESTAMP_NULL_VALUE;
  228.  
  229. /**
  230. * Date, when the contract has been modified for the last time. Linked to CONTRACT_ALL.CO_MODDATE
  231. */
  232. protected java.sql.Timestamp _modificationDate = NullConversion.TIMESTAMP_NULL_VALUE;
  233.  
  234. /**
  235. * Name of the user, who has modified the contract for the last time. Linked to CONTRACT_ALL.CO_USERLASTMOD
  236. */
  237. protected String _userOfLastModification = NullConversion.STRING_NULL_VALUE;
  238.  
  239. /**
  240. * Internal class holding track of all action necessary to
  241. * send to the GMD. Only needed if a clone is created, because
  242. * only a clone can initiate new GMD actions!
  243. *
  244. * @see com.lhs.Contract.bscs_core.ContractTaskHandler
  245. */
  246. protected transient ContractTaskHandler _contractTaskHandler;
  247.  
  248. /**
  249. * Identifier returned from an external provisioning subsystem. Linked to CONTRACT_ALL.CO_EXT_CSUIN (BSCS v5.x)
  250. */
  251. protected String _externalContractReferenceNo = NullConversion.STRING_NULL_VALUE;
  252.  
  253. /**
  254. * Name of the representative for the contract. Linked to CONTRACT_ALL.CO_REP
  255. */
  256. protected String _nameOfContractRepresentative = NullConversion.STRING_NULL_VALUE;
  257.  
  258. /**
  259. * Identification number of the representative of the contract. Linked to CONTRACT_ALL.CO_REP_IDNO
  260. */
  261. protected String _idOfContractRepresentative = NullConversion.STRING_NULL_VALUE;
  262.  
  263. /**
  264. * Reference to the ContractStatus object which holds
  265. * the current state of the contract
  266. */
  267. protected transient ContractStatus _currentStatus;
  268.  
  269. /**
  270. * Reference to the ContractStatus object which holds
  271. * the pending state for the contract
  272. */
  273. protected transient ContractStatus _pendingStatus;
  274.  
  275. /**
  276. * Flag indicating wether the document for contract confirmation is already generated -> 'X'
  277. * otherwise -> NULL.
  278. * mapped to CONTRACT_ALL.CO_CONFIRM
  279. */
  280. protected String _confirmationGenerated = NullConversion.STRING_NULL_VALUE;
  281.  
  282. /**
  283. * Flag indicating wether the data hasn't been validated by the application -> X,
  284. * otherwise -> NULL.
  285. * An X is only allowed if CURR_CO_STATUS.CH_STATUS="o".
  286. * mapped to CONTRACT_ALL.NOT_VALID
  287. */
  288. protected String _notValidated = NullConversion.STRING_NULL_VALUE;
  289.  
  290. /**
  291. * Flag indicating wether services have been assigned to the contract -> 'Y'
  292. * otherwise -> NULL.
  293. * mapped to CONTRACT_ALL.CO_ASS_SERV
  294. */
  295. protected String _servicesAssigned = NullConversion.STRING_NULL_VALUE;
  296.  
  297. /**
  298. * Reference to the stati of this contract
  299. * Linked via CO_ID
  300. */
  301. protected ValueHolderInterface _contractStati = new ValueHolder(new Vector<ContractStatus>(6));
  302.  
  303. /**
  304. * Type of the contract regarding to be AL, main or regular
  305. * Domain: 'R' - Related,'M' - Main, null - Regular.
  306. * Used by feature 84834 - Alternate Line
  307. * Linked to CONTRACT_ALL.CO_REL_TYPE
  308. */
  309. protected String _relationType = NullConversion.STRING_NULL_VALUE;
  310.  
  311. /**
  312. * Transaction id for the contract creation. Used on install subscriber job.
  313. * Linked to CONTRACT_ALL.TRANSACTION_ID
  314. */
  315. private long _transactionId = NullConversion.LONG_NULL_VALUE;
  316.  
  317. /**
  318. * Constants used to set the type of the relation
  319. * <ul>
  320. * <li>'R' - Related</li>
  321. * <li>'M' - Main</li>
  322. * <li>null - Regular</li>
  323. * </ul>
  324. *
  325. * @since feature 84834 - Alternate Line
  326. */
  327. public final static String REGULAR = NullConversion.STRING_NULL_VALUE;
  328. /**
  329. * Constant for Main contract.
  330. */
  331. public final static String MAIN = "M";
  332. /**
  333. * Constant for Related contract.
  334. */
  335. public final static String RELATED = "R";
  336.  
  337. // --> defect 229631-1 NIJ
  338. // - holder for dependent contract in case of contract takeover
  339. private transient Contract _dependentContract;
  340. // <-- 229631
  341.  
  342. // USc#252804 we need only one indicator
  343. private transient boolean _isTakeoverContract;
  344.  
  345. // --> defect 233846 NIJ
  346. private transient ContractedProductElementLock _contractedProductElementsLock;
  347. // <-- 233846
  348.  
  349. /**
  350. * SB : get modes for balances
  351. */
  352. public final static int GETBAL_ACT_ONLY = 1;
  353. /**
  354. * Constant for balance get mode for onhold services.
  355. */
  356. public final static int GETBAL_ACT_ONHOLD = 2;
  357. /**
  358. * Constant for get mode for all balances.
  359. */
  360. public final static int GETBAL_ALL = 3;
  361.  
  362. /**
  363. * Constant for customer contract type.
  364. */
  365. public final static String CUSTOMER_TYPE = "C";
  366. /**
  367. * Constant for agreement contract type.
  368. */
  369. public final static String AGREEMENT_TYPE = "A";
  370. /**
  371. * Constant for template contract type.
  372. */
  373. public final static String TEMPLATE_TYPE = "T";
  374. /**
  375. * Constant for content provider contract type.
  376. */
  377. public final static String CONTENTPROVIDER_TYPE = "B";
  378.  
  379. /**
  380. * Constant for sales contract type.
  381. */
  382. public final static String SALES_TYPE = "S";
  383.  
  384. /**
  385. * This attribute contains the trial period start date.
  386. */
  387. protected Date _trialPeriodStartDate;
  388.  
  389. /**
  390. * Date, when the trial period of the contract will end.
  391. * Linked to CONTRACT_ALL.TRIAL_END_DATE (CustomerContract)
  392. */
  393. protected Date _trialPeriodEndDate;
  394.  
  395. /**
  396. * This attribute contains the BusinessPartnerOrgNode.
  397. */
  398. protected ValueHolderInterface _dealer = new ValueHolder();
  399.  
  400. /**
  401. * This attribute contains the foreign Network.
  402. */
  403. protected ValueHolderInterface _foreignNetwork = new ValueHolder();
  404.  
  405. // FSP 345205, Interconnect partner, MCH 09.08.2010
  406. // /**
  407. // * This attribute contains the Order limit.
  408. // */
  409. // protected ValueHolderInterface _carrier = new ValueHolder();
  410. // end FSP 345205, Interconnect partner, MCH 09.08.2010
  411.  
  412. /**
  413. * Linked to CONTRACT_ALL.EARLIEST_END_DATE (CustomerContract)
  414. */
  415. protected Date _earliestContractEndDate = NullConversion.DATE_NULL_VALUE;
  416.  
  417. /**
  418. * Reference to the porting request of this contract
  419. * Linked via CO_ID
  420. */
  421. protected ValueHolderInterface _portingRequest = new ValueHolder(new Vector<PortingRequest>(1));
  422.  
  423. /**
  424. * Flag which indicates if this contract is a template for preactivated prepaid cards - see feat. 202820_3 Maps to
  425. * CONTRACT_ALL.CONTRACT_TEMPLATE
  426. */
  427.  
  428. protected String _prepaidContractTemplate = NullConversion.STRING_NULL_VALUE;
  429.  
  430. /**
  431. * indicates if call detail statement should be generated. possible values:
  432. * R: on request
  433. * P: Periodically
  434. * null (CHAR_NULL_VALUE): no call detail statement is to be generated.
  435. */
  436. protected char _callDetail = NullConversion.CHAR_NULL_VALUE;
  437.  
  438. /**
  439. * Constant value whether a call detail statement is created on request.
  440. */
  441. public static final char CALL_DETAIL_STMT_ON_REQUEST = 'R';
  442. /**
  443. * Constant value whether a call detail statement is created periodically.
  444. */
  445. public static final char CALL_DETAIL_STMT_PERIODICALLY = 'P';
  446.  
  447. /**
  448. * indicates if user/installation address should be printed on the call detail instead of bill detail address
  449. */
  450. protected String _useUserInstallationAddress = NullConversion.STRING_NULL_VALUE;
  451.  
  452. /**
  453. * Bill Medium Id
  454. */
  455. protected long _billMediumId = NullConversion.LONG_NULL_VALUE;
  456.  
  457. /**
  458. * Medium for notification messages.
  459. */
  460. protected long _notificationMediumId = NullConversion.LONG_NULL_VALUE;
  461.  
  462. /**
  463. * Charging period adjustment period for services with charging schedule
  464. * set to "Cut off date related".
  465. * Domain:
  466. * 'B' - Billing period reference date
  467. * 'A' - Contract activation date
  468. */
  469. protected char _chargingPeriodAdjustmentReference = NullConversion.CHAR_NULL_VALUE;
  470.  
  471. /**
  472. * Constant for setting the charging period adjustment reference
  473. * to the billing period reference date.
  474. */
  475. public static final char BILLING_PERIOD_REFERENCE_DATE = 'B';
  476.  
  477. /**
  478. * Constant for setting the charging period adjustment reference
  479. * to the contract activation date.
  480. */
  481. public static final char CONTRACT_ACTIVATION_DATE = 'A';
  482.  
  483. /**
  484. * The next charging period is the same for all contracted services
  485. * with charging schedule set to "Cut off date related".
  486. * This attribute defines the next cut off date. Read only!
  487. */
  488. protected Date _nextCutOffDate = NullConversion.DATE_NULL_VALUE;
  489.  
  490. /**
  491. * The last charging period is the same for all contracted services
  492. * with charging schedule set to "Cut off date related".
  493. * This attribute defines the last cut off date. Read only!
  494. */
  495. protected Date _lastCutOffDate = NullConversion.DATE_NULL_VALUE;
  496.  
  497. /**
  498. * The date at which a notification message has been generated.
  499. * Read only!
  500. */
  501. protected Date _lastNotificationDate = NullConversion.DATE_NULL_VALUE;
  502.  
  503. /**
  504. * The charge start date.
  505. * Read only.
  506. */
  507. protected Date _chargeStartDate = NullConversion.DATE_NULL_VALUE;
  508. /**
  509. * Concurrent request handler
  510. * feature 00276491_cms
  511. */
  512. private transient ConcurrentRequestHandler _concurrentRequestHandler;
  513.  
  514. /**
  515. * Indicates if the contract data shall be available on every rating node (is common reference data).
  516. * Mapped to CONTRACT_ALL.COMMON_REF_DATA_IND.
  517. */
  518. protected boolean _isCommonRefData = NullConversion.BOOLEAN_NULL_VALUE;
  519.  
  520. private final ValueHolderInterface _contractedPromotionPlans = new ValueHolder(new Vector<ContractedPromotionPlan>());
  521.  
  522. // FSP 288320, MCH 09.06.2008
  523. protected final static String TICKLER_RERATING_SHORT_DESC = "CO FOR RERATING";
  524. protected final static String TICKLER_CALLDETAIL_SHORT_DESC = "CC CHARGE";
  525. protected final static String TICKLER_RERATING_LONG_DESC_MARK = "Contract is marked for re-rating";
  526. protected final static String TICKLER_RERATING_LONG_DESC_UNMARK = "Contract is unmarked for re-rating";
  527. protected final static String TICKLER_STATUS_NOTE = "NOTE";
  528.  
  529. /**
  530. * Indicates whether the contract is a candidate for re-rating
  531. * Linked to CONTRACT_ALL.RR_CANDIDATE
  532. */
  533. protected boolean _isReratingCandidate = NullConversion.BOOLEAN_NULL_VALUE;
  534.  
  535. /**
  536. * Reference to the BillingContractLock object
  537. */
  538. protected ValueHolderInterface _billingLock = new ValueHolder();
  539.  
  540. /**
  541. * TODO remove the value holder, Reference to the ReratingContractLock object
  542. */
  543. protected ValueHolderInterface _reratingLock = new ValueHolder();
  544. // end 288320, MCH 09.06.2008
  545.  
  546. /** contract template from which this Contract has been created */
  547. //protected ValueHolderInterface _template = new ValueHolder();
  548. protected long _templateId=NullConversion.LONG_NULL_VALUE;
  549. /**
  550. * The current contract state.
  551. * mapped to CONTRACT_ALL.CH_STATUS
  552. */
  553. protected char _state = 'o';
  554.  
  555. // 00377727_E08_U07
  556. /**
  557. * List of the PAM schemes assigned to the contract.
  558. */
  559. protected ValueHolderInterface _pamSchemes = new ValueHolder(new Vector<ContractPamScheme>());
  560. /**
  561. * List of the PAM schemes which are not used any more.
  562. */
  563. protected ValueHolderInterface _pamSchemesFree = new ValueHolder(new Vector<ContractPamScheme>());
  564.  
  565. protected ValueHolderInterface _sharedAccountPackageAssignments = new ValueHolder(new Vector<SharedAccountPackageAssignment>());
  566.  
  567. /**
  568. * Extraction tag of the contract to indicate whether the contract or relevant RDR
  569. * will be loaded into shared memory. This is introduced by PC 13899 (feature 00403569)
  570. * Linked to CONTRACT_ALL.EXTRACTION_TAG
  571. */
  572. protected String _extractionTag = NullConversion.STRING_NULL_VALUE;
  573.  
  574. /**
  575. * Date, when the contract extraction tag has been modified for the last time.
  576. * Introduced by PC 13899 (feature 00403569)
  577. * Linked to CONTRACT_ALL.MODIFIED_TIMESTAMP
  578. */
  579. protected java.sql.Timestamp _extractionTagModifiedDate = NullConversion.TIMESTAMP_NULL_VALUE;
  580.  
  581. /**
  582. * Constant for default value of contract extraction tag.
  583. */
  584. private final static String DEFAULT_EXTRACTION_TAG = "Postpaid";
  585.  
  586. /**
  587. * Default constructor.
  588. * Initializes the ValueHolder used by TOPLink
  589. */
  590. public Contract()
  591. {
  592. super();
  593. }
  594.  
  595. /**
  596. * Returns the expiration date.
  597. */
  598. @Override
  599. public int getExpirationDateI()
  600. {
  601. if (!this.isAgreementContract())
  602. {
  603. return CAASDateConverter.toCAASDate(_expirationDate);
  604. }
  605.  
  606. return NullConversion.INT_NULL_VALUE;
  607. }
  608.  
  609. /**
  610. * Returns the TIMM generation date.
  611. */
  612. @Override
  613. public long getTIMMGenerationDateI()
  614. {
  615. if (this.isAgreementContract())
  616. {
  617. return 0;
  618. }
  619. return CAASTimeConverter.toCAASTime(_timmGenerationDate);
  620. }
  621.  
  622. /**
  623. * Sets the expiration date.
  624. */
  625. @Override
  626. public void setExpirationDateI(int pDate)
  627. {
  628. if (!this.isAgreementContract())
  629. {
  630. _expirationDate = CAASDateConverter.toTimestamp(pDate);
  631. }
  632. }
  633.  
  634. /**
  635. * Set the TIMM generation date.
  636. *
  637. * @param pDate
  638. */
  639. public void setTIMMGenerationDate(long pDate)
  640. {
  641. _timmGenerationDate = CAASTimeConverter.toTimestamp(pDate);
  642. }
  643.  
  644. /**
  645. * Set the date a status is valid from
  646. *
  647. * @param pDate
  648. */
  649. public void setStatusValidFromDate(Timestamp pDate)
  650. {
  651. _statusValidFromDate = pDate;
  652. }
  653.  
  654. /**
  655. * Create and assign a new primary key to this (new) Contract instance. Additionaly creates a public key.
  656. *
  657. * @throws ComponentException
  658. */
  659. public void createUniqueId()
  660. throws ComponentException
  661. {
  662.  
  663. /*
  664. * Retrieve the reference of the PrimaryKeyFactory
  665. */
  666. FWPrimaryKeyFactory pFactory = FWPrimaryKeyFactory.instance();
  667.  
  668. // Create a private key
  669. _id = pFactory.getNewPKeyValue("MAX_CONTRACT_ID");
  670.  
  671. registerPrimaryKeyValues(Long.valueOf(getIDI()));
  672.  
  673. }
  674.  
  675. /**
  676. * Links to the database mapping as described in PContract.
  677. *
  678. * @return the mapping descriptor.
  679. * @throws ComponentException
  680. * @see com.lhs.Contract.bscs_core.persistence.PContract
  681. */
  682.  
  683. public static RelationalDescriptor descriptor()
  684. throws ComponentException
  685. {
  686. return lookupDescriptor(com.lhs.Contract.bscs_core.persistence.PContract.class);
  687. }
  688. /**
  689. * Gets the contract type
  690. *
  691. * @return contract type
  692. */
  693. public ContractType getContractType()
  694. {
  695. return (ContractType) _contractType.getValue();
  696. }
  697. /**
  698. * Sets the contract type
  699. *
  700. * @param pContractType
  701. * @throws ComponentException
  702. * @throws ValidationException
  703. */
  704. public void setContractType(ContractType pContractType) throws ValidationException, ComponentException
  705. {
  706. FWValueHolder.setValue(_contractType, pContractType, this);
  707. if (pContractType == null)
  708. {
  709. _agreementType = NullConversion.STRING_NULL_VALUE;
  710. }
  711. else
  712. {
  713. String lShortName = pContractType.getShortName();
  714. if (ContractType.SHNAME_NORPICIBER.equals(lShortName) ||
  715. ContractType.SHNAME_NORPICIBERCH.equals(lShortName) ||
  716. ContractType.SHNAME_NORPOCIBER.equals(lShortName) ||
  717. ContractType.SHNAME_NORPOCIBERCH.equals(lShortName))
  718. {
  719. _agreementType = "CA";
  720. setTypeI("A");
  721. }
  722. else if (ContractType.SHNAME_NORPITAP.equals(lShortName) ||
  723. ContractType.SHNAME_NORPOTAP.equals(lShortName))
  724. {
  725. _agreementType = "RA";
  726. setTypeI("A");
  727. }
  728. else if (ContractType.SHNAME_NOICI.equals(lShortName) ||
  729. ContractType.SHNAME_NOICO.equals(lShortName))
  730. {
  731. _agreementType = "IC";
  732. setTypeI("A");
  733. }
  734. else if (ContractType.SHNAME_NOECI.equals(lShortName) ||
  735. ContractType.SHNAME_NOECO.equals(lShortName))
  736. {
  737. _agreementType = "EC";
  738. setTypeI("A");
  739. }
  740. else if (ContractType.SHNAME_NOD.equals(lShortName))
  741. {
  742. _agreementType = "DC";
  743. setTypeI("A");
  744. }
  745. else if (ContractType.SHNAME_NOSP.equals(lShortName))
  746. {
  747. _agreementType = "SP";
  748. setTypeI("A");
  749. }
  750. else if (ContractType.SHNAME_NOCP.equals(lShortName))
  751. {
  752. _agreementType = "CP";
  753. setTypeI("A");
  754. }
  755. else if (ContractType.SHNAME_NOMVNO.equals(lShortName))
  756. {
  757. _agreementType = "MO";
  758. setTypeI("A");
  759. }
  760. else if (ContractType.SHNAME_NOST.equals(lShortName))
  761. {
  762. _agreementType = NullConversion.STRING_NULL_VALUE;
  763. // mark this as a template
  764. setPrepaidContractTemplate(true);
  765. setTypeI("T");
  766. }
  767. else
  768. {
  769. if (ContractType.SHNAME_NOS.equals(lShortName))
  770. {
  771. // 390089_E04_U07: reset reference to template if pre-activated contract is converted into a regular contract
  772. setTemplate(null);
  773. }
  774. _agreementType = NullConversion.STRING_NULL_VALUE;
  775. setTypeI("S");
  776. }
  777.  
  778.  
  779. if (this.isNew())
  780. {
  781. // Set the common reference data flag to the default defined at the contract type
  782. setIsCommonReferenceData(pContractType.isCommonReferenceData());
  783. }
  784. }
  785. }
  786.  
  787. /**
  788. * Indicates if it is a customer contract.
  789. *
  790. * @return true if it is a cuatomer contract
  791. */
  792. @Override
  793. public boolean isCustomerContract()
  794. {
  795. ContractType contractType = this.getContractType();
  796. return contractType.isCustomerContractType();
  797. }
  798.  
  799. /**
  800. * Indicates if it is an agreement contract.
  801. *
  802. * @return true if it is an agreement contract
  803. */
  804. @Override
  805. public boolean isAgreementContract()
  806. {
  807. ContractType contractType = this.getContractType();
  808. return contractType.isContractAgreementType();
  809. }
  810.  
  811. /**
  812. * Indicates if it is an MVNO agreement contract.
  813. *
  814. * @return true if it is an MVNO agreement contract
  815. */
  816. public boolean isMVNOAgreementContract()
  817. {
  818. return ContractType.SHNAME_NOMVNO.equals(getContractType().getShortName());
  819. }
  820.  
  821. /**
  822. * Indicates if it is a content provider contract.
  823. *
  824. * @return true if it is content provider contract
  825. */
  826. public boolean isContentProviderContract()
  827. {
  828. ContractType contractType = this.getContractType();
  829. return contractType.isContentProviderType();
  830. }
  831.  
  832. /**
  833. * Retrieve all aggregated objects
  834. *
  835. * @return Vector
  836. */
  837. @Override
  838. public Vector<AbstractDomainObject> getAggregatedObjects()
  839. {
  840. /*
  841. * Retrieve the aggregated objects of the superclass
  842. */
  843. Vector<AbstractDomainObject> vector = super.getAggregatedObjects();
  844.  
  845. /*
  846. * Instantiate the vector if necessary
  847. */
  848. if (vector == null)
  849. {
  850. vector = new Vector<AbstractDomainObject>(1);
  851. }
  852.  
  853. /*
  854. * Check wether the according aggregated objects exist
  855. * and add them to the vector
  856. */
  857. if (_compositeContractSection != null)
  858. {
  859. /*
  860. * Add the aggregated object
  861. */
  862. vector.add(_compositeContractSection);
  863. }
  864.  
  865. return vector;
  866. }
  867.  
  868. /**
  869. * Returns the business unit id of the contract.
  870. * For performance reason only the id and not a valueholder to the object is implemented
  871. *
  872. * @return business unit id
  873. */
  874.  
  875. @Override
  876. public long getBusinessUnitId()
  877. {
  878. return _businessUnitId;
  879. }
  880.  
  881. /**
  882. * Returns the description of the contract.
  883. *
  884. * @return description
  885. */
  886.  
  887. public String getDescription()
  888. {
  889. return _description;
  890. }
  891. /**
  892. * Returns the type of the contract.
  893. *
  894. * @return type
  895. */
  896. @Override
  897. public String getTypeI()
  898. {
  899. return _type;
  900. }
  901.  
  902. /**
  903. * Returns the container instance holding references to all sections of a contract..
  904. * Creation date: (02/15/2001 1:32:16 PM)
  905. *
  906. * @author Ulrich Schaefer
  907. * @return com.lhs.Contract.bscs_core.AbstractCompositeContractSection
  908. */
  909. public CompositeContractSection getCompositeContractSection()
  910. {
  911. /*
  912. * return attribute
  913. */
  914. return _compositeContractSection;
  915. }
  916. /**
  917. * Gets the second party.
  918. *
  919. * @return com.lhs.BusinessPartner.bscs_core.external.OrgNodeI
  920. */
  921.  
  922. @Override
  923. public OrgNodeI getContractHolderI()
  924. {
  925. return FWValueHolder.getValue(_contractHolder);
  926. }
  927. /**
  928. * Gets the first contract holder
  929. *
  930. * @return first party
  931. */
  932. public OrgNodeI getFirstContractHolderI()
  933. {
  934. return FWValueHolder.getValue(_firstContractHolder);
  935. }
  936. /**
  937. * Retrieves all different ContractSections, which are assigned to this Contract.
  938. *
  939. * @return Vector
  940. * @throws ComponentException
  941. * @throws ValidationException
  942. */
  943.  
  944. @Override
  945. public Vector<ContractSectionI> getContractSectionsI()
  946. throws ComponentException, ValidationException
  947. {
  948. /*
  949. * Check whether there is a CompositeContractSection assigned
  950. * to this Contract
  951. */
  952. if (_compositeContractSection == null)
  953. {
  954. throw new IllegalArgumentException("Missing _compositeContractSection");
  955. }
  956.  
  957. /*
  958. * Retrieve the ContractSections from the aggregated CompositeContractSection
  959. */
  960. return _compositeContractSection.getContractSections();
  961. }
  962. /**
  963. * Returns the date, this Contract has been entered.
  964. *
  965. * @return long
  966. */
  967.  
  968. @Override
  969. public int getCreationDateI()
  970. {
  971. return CAASDateConverter.toCAASDate(_creationDate);
  972. }
  973. /**
  974. * Returns the DataExchangeSection of a Contract
  975. *
  976. * @return com.lhs.Contract.bscs_core.external.DataExchangeSectionI
  977. * @throws ComponentException
  978. * @throws ValidationException
  979. */
  980.  
  981. @Override
  982. public DataExchangeSectionI getDataExchangeSectionI()
  983. throws ComponentException
  984. {
  985. /*
  986. * Check whether there is a CompositeContractSection assigned
  987. * to this Contract
  988. */
  989. if (_compositeContractSection == null)
  990. {
  991. throw new ComponentException("Contract.MissingContractSection", "CompositeContractSection");
  992. }
  993.  
  994. /*
  995. * Forward the request to the compositeContractSection
  996. */
  997. return _compositeContractSection.getDataExchangeSection();
  998. }
  999.  
  1000. /**
  1001. * Returns the primary key for the corresponding row in the db.
  1002. *
  1003. * @return long Primary key
  1004. */
  1005.  
  1006. @Override
  1007. public long getIDI()
  1008. {
  1009. return _id;
  1010. }
  1011. /**
  1012. * Returns the date, this Contract has been modified the last time.
  1013. *
  1014. * @return long
  1015. */
  1016.  
  1017. @Override
  1018. public long getModificationDateI()
  1019. {
  1020. return CAASTimeConverter.toCAASTime(_modificationDate);
  1021. }
  1022.  
  1023. /**
  1024. * Returns the user, who has altered this contract for the last time.
  1025. *
  1026. * @return String
  1027. */
  1028.  
  1029. @Override
  1030. public String getUserOfLastModificationI()
  1031. {
  1032. return _userOfLastModification;
  1033. }
  1034. /**
  1035. * Returns the date, this Contract has been activated.
  1036. *
  1037. * @return long
  1038. */
  1039.  
  1040. @Override
  1041. public long getActivationDateI()
  1042. {
  1043. return CAASTimeConverter.toCAASTime(_activationDate);
  1044. }
  1045.  
  1046. // --> defect 286384 NiJ
  1047. /**
  1048. * Returns all active ContractedDNProperties currently assigned to the contract.
  1049. *
  1050. * @return Vector
  1051. * @throws ComponentException
  1052. */
  1053. public List<ContractedDNPropertiesI> getActiveDNProperties()
  1054. throws ComponentException
  1055. {
  1056. List<ContractedDNPropertiesI> lActiveConDNPropertiesList = new ArrayList<ContractedDNPropertiesI>(5);
  1057.  
  1058. ContractedCompositeProduct lCCP = getContractedCompositeProduct();
  1059.  
  1060. // get list of ContractedSimpleProduct's assigned to contract
  1061. Vector<ContractedProductElement> lCPEList = lCCP.getContractedProductElements();
  1062.  
  1063. if (!lCPEList.isEmpty())
  1064. {
  1065. // loop through the ContractedProductElement's, get each active ContractedDNProperties and store it
  1066. Iterator<ContractedProductElement> lIterCPE = lCPEList.iterator();
  1067. while (lIterCPE.hasNext())
  1068. {
  1069. ContractedProductElement lCPE = lIterCPE.next();
  1070. Vector<ContractedDNPropertiesI> lActiveContrDNProps = lCPE.getContractedDNPropertiesNoDeactive();
  1071.  
  1072. if (lActiveContrDNProps.size() > 0)
  1073. {
  1074. // add to result vector
  1075. lActiveConDNPropertiesList.addAll(lActiveContrDNProps);
  1076. }
  1077. }
  1078. }
  1079.  
  1080. return lActiveConDNPropertiesList;
  1081. }
  1082.  
  1083. /**
  1084. * Returns all active ContractedPortProperties currently assigned to the contract.
  1085. *
  1086. * @return Return all active contracted ports.
  1087. * @throws ComponentException
  1088. */
  1089. public List<ContractedPortPropertiesI> getActivePortProperties()
  1090. throws ComponentException
  1091. {
  1092. List<ContractedPortPropertiesI> lActiveConPortPropertiesList = new ArrayList<ContractedPortPropertiesI>(5);
  1093.  
  1094. ContractedCompositeProduct lCCP = getContractedCompositeProduct();
  1095. Vector<ContractedProductElement> lCPEList = lCCP.getContractedProductElements();
  1096. if (!lCPEList.isEmpty())
  1097. {
  1098. // loop through the ContractedProductElement's, get each active ContractedPortProperties and store it
  1099. Iterator<ContractedProductElement> lIterCPE = lCPEList.iterator();
  1100. while (lIterCPE.hasNext())
  1101. {
  1102. ContractedProductElement lCPE = lIterCPE.next();
  1103. Vector<ContractedPortPropertiesI> lAllContrPortProps = lCPE.getContractedPortPropertiesI();
  1104.  
  1105. // its needed to filter the active ports only
  1106. for (int i = 0; i < lAllContrPortProps.size(); i++)
  1107. {
  1108. ContractedPortPropertiesI lContrPortProp = lAllContrPortProps.get(i);
  1109. if (NullConversion.isNull(lContrPortProp.getDeactivationDateI()))
  1110. {
  1111. // this port is active, add to new vector
  1112. lActiveConPortPropertiesList.add(lContrPortProp);
  1113. }
  1114. }
  1115. }
  1116.  
  1117. }
  1118.  
  1119. return lActiveConPortPropertiesList;
  1120. }
  1121. // <-- 286384
  1122.  
  1123. /**
  1124. * Returns the InvoiceSection of a Contract
  1125. *
  1126. * @return com.lhs.Contract.bscs_core.external.InvoiceSectionI
  1127. * @throws ComponentException
  1128. * @throws ValidationException
  1129. */
  1130.  
  1131. @Override
  1132. public InvoiceSectionI getInvoiceSectionI()
  1133. throws ComponentException
  1134. {
  1135. /*
  1136. * Check whether there is a CompositeContractSection assigned
  1137. * to this Contract
  1138. */
  1139. if (_compositeContractSection == null)
  1140. {
  1141. throw new ComponentException("Contract.MissingContractSection", "CompositeContractSection");
  1142. }
  1143.  
  1144. /*
  1145. * Forward the request to the compositeContractSection
  1146. */
  1147. return _compositeContractSection.getInvoiceSection();
  1148. }
  1149. /**
  1150. * getPaymentSectionI. Returns the PaymentSection of a Contract
  1151. *
  1152. * @return com.lhs.Contract.bscs_core.external.PaymentSectionI
  1153. * @throws ComponentException
  1154. * @throws ValidationException
  1155. */
  1156.  
  1157. @Override
  1158. public PaymentSectionI getPaymentSectionI()
  1159. throws ComponentException
  1160. {
  1161. /*
  1162. * Check whether there is a CompositeContractSection assigned
  1163. * to this Contract
  1164. */
  1165. if (_compositeContractSection == null)
  1166. {
  1167. throw new IllegalArgumentException("Missing _compositeContractSection");
  1168. }
  1169.  
  1170. /*
  1171. * Forward the request to the compositeContractSection
  1172. */
  1173. return _compositeContractSection.getPaymentSection();
  1174. }
  1175.  
  1176. /**
  1177. * Returns the ProductSection of a Contract
  1178. *
  1179. * @return com.lhs.Contract.bscs_core.external.ProductSectionI
  1180. * @throws ComponentException
  1181. * @throws ValidationException
  1182. */
  1183.  
  1184. @Override
  1185. public ProductSectionI getProductSectionI()
  1186. throws ComponentException
  1187. {
  1188. /*
  1189. * Check whether there is a CompositeContractSection assigned
  1190. * to this Contract
  1191. */
  1192. if (_compositeContractSection == null)
  1193. {
  1194. throw new IllegalArgumentException("Missing _compositeContractSection");
  1195. }
  1196.  
  1197. /*
  1198. * Forward the request to the compositeContractSection
  1199. */
  1200. return _compositeContractSection.getProductSection();
  1201. }
  1202. /**
  1203. * Returns the date, when this Contract has been signed by the contract holder.
  1204. *
  1205. * @return int
  1206. */
  1207.  
  1208. @Override
  1209. public int getSigningDateI()
  1210. {
  1211. return CAASDateConverter.toCAASDate(_signingDate);
  1212. }
  1213.  
  1214. /**
  1215. * Set the business unit id of the contract
  1216. *
  1217. * @param pBusinessUnitId
  1218. * business unit id
  1219. */
  1220.  
  1221. public void setBusinessUnitId(long pBusinessUnitId)
  1222. {
  1223. checkBusinessUnitAssignment(pBusinessUnitId);
  1224. _businessUnitId = pBusinessUnitId;
  1225. }
  1226.  
  1227. /**
  1228. * Check whether business unit assignment is valid
  1229. *
  1230. * @param pBusinessUnitId
  1231. * business unit id
  1232. * @throws ComponentException
  1233. * if business unit assignment is invalid
  1234. */
  1235. private void checkBusinessUnitAssignment(long pBusinessUnitId)
  1236. {
  1237.  
  1238. boolean hasMvnoLicense = ContractAdministrator.getInstance().getLicenseUtils().checkLicense(LicenseInitializer.LicenseFeature.LHS_BSCS_MVNO_SUPPORT.getName());
  1239.  
  1240. // if MVNO support license not available
  1241. if (!hasMvnoLicense)
  1242. {
  1243. BusinessUnit newBusinessUnit = BusinessUnit.getBusinessUnitById(pBusinessUnitId);
  1244. // new contracts can only be assigned to the first dedicated business unit (representing the operator itself)
  1245. if (isNew())
  1246. {
  1247. if (!newBusinessUnit.isFirstDedicated())
  1248. {
  1249. throw new ComponentException("CMA.CommonDomain.MVNONotSupported");
  1250. }
  1251. }
  1252. // existing contracts cannot be moved from the first dedicated business to another business unit
  1253. else
  1254. {
  1255. BusinessUnit oldBusinessUnit = BusinessUnit.getBusinessUnitById(getBusinessUnitId());
  1256. if (oldBusinessUnit.isFirstDedicated() && !newBusinessUnit.isFirstDedicated())
  1257. {
  1258. throw new ComponentException("CMA.CommonDomain.MVNONotSupported");
  1259. }
  1260. }
  1261. }
  1262.  
  1263. }
  1264.  
  1265. /**
  1266. * Set the description of the contract
  1267. *
  1268. * @param pDescription
  1269. */
  1270.  
  1271. public void setDescription(String pDescription)
  1272. {
  1273. _description = pDescription;
  1274. }
  1275.  
  1276. /**
  1277. * Set the business unit id of the contract to the business unit of the session
  1278. *
  1279. * @throws ComponentException
  1280. * if an error occurs
  1281. */
  1282. public void setBusinessUnitId() throws ComponentException
  1283. {
  1284. long lBusinessUnitId = CMSUser.getCMSUser().checkCurrentBusinessUnit();
  1285. setBusinessUnitId(lBusinessUnitId);
  1286. }
  1287.  
  1288. /**
  1289. * Sets the date, when this contract has been signed by the contract holder
  1290. *
  1291. * @param pDate
  1292. * int
  1293. */
  1294.  
  1295. @Override
  1296. public void setSigningDateI(int pDate)
  1297. {
  1298. _signingDate = CAASDateConverter.toDate(pDate);
  1299. }
  1300.  
  1301. /**
  1302. * Sets the date, when this contract has been activated for the first time
  1303. *
  1304. * @param pDate
  1305. * long
  1306. */
  1307.  
  1308. @Override
  1309. public void setActivationDateI(long pDate)
  1310. {
  1311. _activationDate = CAASTimeConverter.toTimestamp(pDate);
  1312. }
  1313.  
  1314. /**
  1315. * TOPLink hook, called right before the INSERT statement.
  1316. */
  1317. @Override
  1318. public void preInsert() throws ComponentException, ValidationException
  1319. {
  1320. // ensure that public key is always set
  1321. setPublicKey(null);
  1322. super.preInsert();
  1323. }
  1324.  
  1325. /**
  1326. * Returns the public key of this instance.
  1327. *
  1328. * @return The public key.
  1329. */
  1330. public String getPublicKey()
  1331. {
  1332. return _code;
  1333. }
  1334.  
  1335. /**
  1336. * Returns the public key of this instance.
  1337. *
  1338. * @return The public key.
  1339. */
  1340. @Override
  1341. public String getPublicKeyI()
  1342. {
  1343. return _code;
  1344. }
  1345. /**
  1346. * Set the public key value. The public key can be set only once, subsequental calls to this method are just ignored. If pPubKey
  1347. * is null then default value will be taken from the database sequence "MAX_CO_CODE"
  1348. *
  1349. * @param pPubKey
  1350. * a value to set, could be null
  1351. * @throws ComponentException
  1352. */
  1353. public void setPublicKey(String pPubKey)
  1354. throws ComponentException
  1355. {
  1356. if (NullConversion.isNull(_code))
  1357. {
  1358. if (!NullConversion.isNull(pPubKey))
  1359. {
  1360. _code = pPubKey;
  1361. }
  1362. else
  1363. {
  1364. // nothing is set - use default value from the stored procedure
  1365. _code = FWPrimaryKeyFactory.instance().getNewPKeyValueAsString("MAX_CO_CODE");
  1366. }
  1367. }
  1368. else
  1369. {
  1370. // if public key already set - just do nothing
  1371. // public key can be set only once
  1372. }
  1373. }
  1374. // From CustomerContract
  1375.  
  1376. /**
  1377. * Set the dependent contract. Used during a contract takeover operation.
  1378. *
  1379. * @param pContractI
  1380. */
  1381. public void setDependentContract(Contract pContractI)
  1382. {
  1383.  
  1384. if (isCustomerContract())
  1385. {
  1386. _dependentContract = pContractI;
  1387. }
  1388. }
  1389.  
  1390. /**
  1391. * Returns the dependent contract.
  1392. *
  1393. * @return The dependent contract.
  1394. */
  1395. public Contract getDependentContract()
  1396. {
  1397. if (isCustomerContract())
  1398. {
  1399. return _dependentContract;
  1400. }
  1401. return null;
  1402. }
  1403.  
  1404. /**
  1405. * Checks whether this instance has request to be generated or not.
  1406. *
  1407. * @return true if tasks have to be generated.
  1408. * @throws ValidationException
  1409. * @throws ComponentException
  1410. */
  1411. public boolean areTasksGenerated() throws ValidationException, ComponentException
  1412. {
  1413. return getContractTaskHandler().areTaskRegistered();
  1414. }
  1415.  
  1416. /**
  1417. * Return whether this is a takeover contract, that means, result of a takeover operation.
  1418. *
  1419. * @return true if the contract was created as result of takeover.
  1420. */
  1421. public boolean isTakeoverContract()
  1422. {
  1423. return _isTakeoverContract;
  1424. }
  1425.  
  1426. /**
  1427. * Mark this contract as the contract that was taken over or the new contract depending on the
  1428. * input paramter.
  1429. *
  1430. * @param pInd
  1431. */
  1432. public void setIsTakeoverContract(boolean pInd)
  1433. {
  1434. _isTakeoverContract = pInd;
  1435. }
  1436. // <-- 233025
  1437.  
  1438. /**
  1439. * Accept a visitor, call method in visitor depending on type of this instance and pass the visitor to all depending instances.
  1440. *
  1441. * @param pVisitor
  1442. * com.lhs.Contract.bscs_core.ContractVisitor
  1443. * @throws ValidationException
  1444. * @throws ComponentException
  1445. * @throws SystemException
  1446. */
  1447. public void accept(ContractVisitor pVisitor) throws ComponentException, ValidationException
  1448. {
  1449. pVisitor.visitContract(this);
  1450.  
  1451. ProductSection vProductSection = _compositeContractSection.getProductSection();
  1452. if (pVisitor.isDone())
  1453. {
  1454. return;
  1455. }
  1456.  
  1457. if (vProductSection != null)
  1458. {
  1459.  
  1460. /*
  1461. * propagate visitor ...
  1462. */
  1463. if (getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.CONTRACTED_COMPOSITE_PRODUCT))
  1464. {
  1465. /*
  1466. * Retrieve the ContractedCompositeProduct from the ProductSection
  1467. */
  1468. ContractedCustomerProduct contractedCustomerProduct = vProductSection.getContractedCompositeProduct();
  1469. contractedCustomerProduct.accept(pVisitor);
  1470. }
  1471. vProductSection.accept(pVisitor);
  1472. }
  1473.  
  1474. // Visit the customization section
  1475. CustomizationSection customizationSection = _compositeContractSection.getCustomizationSection();
  1476. if (customizationSection != null)
  1477. {
  1478. customizationSection.accept(pVisitor);
  1479. }
  1480. DataExchangeSection dataExchangeSection = _compositeContractSection.getDataExchangeSection();
  1481. if (dataExchangeSection != null)
  1482. {
  1483. dataExchangeSection.accept(pVisitor);
  1484. }
  1485. GeneralContractSection generalContractSection = _compositeContractSection.getGeneralContractSection();
  1486. if (generalContractSection != null)
  1487. {
  1488. generalContractSection.accept(pVisitor);
  1489. }
  1490. InvoiceSection invoiceSection = _compositeContractSection.getInvoiceSection();
  1491. if (invoiceSection != null)
  1492. {
  1493. invoiceSection.accept(pVisitor);
  1494. }
  1495. PaymentSection paymentSection = _compositeContractSection.getPaymentSection();
  1496. if (paymentSection != null)
  1497. {
  1498. paymentSection.accept(pVisitor);
  1499. }
  1500. }
  1501.  
  1502. /**
  1503. * Returns whether the contract has a service assigned
  1504. *
  1505. * @return boolean
  1506. */
  1507.  
  1508. @Override
  1509. public boolean areServicesAssignedI()
  1510. {
  1511. if (this.isAgreementContract())
  1512. {
  1513. return false;
  1514. }
  1515. return "Y".equals(_servicesAssigned) || "y".equals(_servicesAssigned);
  1516. }
  1517.  
  1518. /**
  1519. * changeStatusI. Change the status of the CustomerContract by creating a new ContractStatus, which is marked as pending, using
  1520. * the state given in pNewState and the reason given in pReason.
  1521. *
  1522. * @param pNewState
  1523. * com.lhs.CommonDomain.bscs_core.external.StateI
  1524. * @param pReason
  1525. * @param pValidFromDate
  1526. * the time from which the pending status is valid from. For the time being only one pending state for a contract is
  1527. * possible. This may change in future! If the value is passed as a NullConversion.INT_NULL_VALUE the system time is
  1528. * taken instead.
  1529. * @param pProperties
  1530. * a list of properties which are used for resource retention in case of deactivation
  1531. * @param pInstance
  1532. * the MVNO instance
  1533. * @param pEffectiveDate
  1534. * the effective date of the MVNO instance
  1535. * @param pRequestCode
  1536. * the request code of the MVNO instance
  1537. * @return List of services that have been added and/or activate during initial activation.
  1538. * @precondition There doesn't exist any pending status for that CustomerContract
  1539. * @throws ComponentException
  1540. * @throws ValidationException
  1541. * @see com.lhs.Contract.bscs_core.ContractStatus
  1542. * @see com.lhs.CommonDomain.bscs_core.Reason
  1543. */
  1544. // PN337441 chenf
  1545. public List<ContractedProductElementI> changeStatus(int pNewState, ReasonI pReason, long pValidFromDate,
  1546. KeyValueI[] pProperties, Instance pInstance, Timestamp pEffectiveDate, String pRequestCode)
  1547. throws ComponentException, ValidationException
  1548. {
  1549.  
  1550. /*
  1551. * Check wether the pending and the current status have been already
  1552. * retrieved
  1553. */
  1554. if (_currentStatus == null)
  1555. {
  1556. retrieveCurrentAndPendingStatus();
  1557. }
  1558.  
  1559. /*
  1560. * Check whether a pending status for this contract already exists
  1561. */
  1562. if (_pendingStatus != null)
  1563. {
  1564. throw new ValidationException("Contract.NoStatusChangeWithPendingStatus");
  1565. }
  1566. /*
  1567. * Check whether the requested state is valid for contracts
  1568. */
  1569. ContractStatus currentStatus = _currentStatus;
  1570. if (!currentStatus.isFollowStateI(pNewState))
  1571. {
  1572. throw new ValidationException("Contract.InvalidState");
  1573. }
  1574.  
  1575. /*
  1576. * check whether requested state is 'suspended' and contract is on trial
  1577. */
  1578. if (pNewState == ContractStatusI.Suspended && isOnTrialI())
  1579. {
  1580. throw new ValidationException("Contract.InvalidState", "OnTrial->Suspended");
  1581. }
  1582.  
  1583. /*
  1584. * get old state
  1585. */
  1586. int vOldState = currentStatus.getStateI();
  1587.  
  1588. /*
  1589. * if not validated is set, reset the flag if new state is not 'on hold'
  1590. */
  1591. if (vOldState == ContractStatusI.Onhold && pNewState != ContractStatusI.Onhold)
  1592. {
  1593. setNotValidatedI(false);
  1594. }
  1595.  
  1596. /* check 2: if status change is from onhold to active: Feature 15860 */
  1597. /*
  1598. * introduce something similiar to FC 3/4 in combination with FC 18/19
  1599. */
  1600. if (pNewState == ContractStatusI.Active && vOldState == ContractStatusI.Onhold)
  1601. {
  1602. // this is an initial activation.
  1603. // check whether this is a contract of the MNVO instance and update the valid from date appropriately
  1604. if (!NullConversion.isNull(pEffectiveDate))
  1605. {
  1606. ((ContractStatus) getCurrentStatusI()).setValidFromDate(pEffectiveDate.getTime());
  1607. }
  1608.  
  1609. // #TODO check open amounts of payment responsible -> should be done on the client side!!! semantic of status change is
  1610. // overrule check!
  1611.  
  1612. /*
  1613. * check 3: if status change is from onhold to active: Feature 84834
  1614. * if is an AL contract, check if the main contract is still active and doesn't have pending requests
  1615. */
  1616.  
  1617. if (isALContractI())
  1618. {
  1619. // test if the main contract is active
  1620. Contract mainContract = (Contract) this.getCompositeContractSection().getGeneralContractSection().getMainContract();
  1621. if (mainContract.getCurrentStatusI().getStateI() != ContractStatusI.Active)
  1622. {
  1623. throw new ValidationException("Contract.MainContractIsNotActive",
  1624. Long.valueOf(mainContract.getIDI()), mainContract.getPublicKeyI());
  1625. }
  1626. // test if the main contract has pending requests
  1627. if (mainContract.hasPendingContractRequests())
  1628. {
  1629. throw new ValidationException("Contract.NoStatusChangeWithPendingStatus");
  1630. }
  1631. }
  1632. }
  1633.  
  1634. // begin 236082_cms
  1635. /*
  1636. * Constraints for two-level contracts:
  1637. * 1. child may be activated if parent has been activated (checked above)
  1638. * 2. parent may be suspended if all children are suspended or deactivated
  1639. * 3. parent may be deactivated if children are deactivated
  1640. */
  1641. if (isMainContractI())
  1642. {
  1643. List<ContractI> childList = this.getCompositeContractSection().getGeneralContractSection().getRelatedContracts();
  1644. Iterator<ContractI> childIter = childList.iterator();
  1645. Contract child;
  1646. if (pNewState == ContractStatusI.Suspended && vOldState != ContractStatusI.Suspended)
  1647. {
  1648. while (childIter.hasNext())
  1649. {
  1650. child = (Contract) childIter.next();
  1651. if (child.getCurrentStatusI().getStateI() != ContractStatusI.Suspended
  1652. && child.getCurrentStatusI().getStateI() != ContractStatusI.Deactive)
  1653. {
  1654. throw new ValidationException(
  1655. "CMS.Contract.RelatedContracts.ChildContractIsNeitherSuspendedNorDeactivated", getPublicKey(),
  1656. child.getPublicKey());
  1657. }
  1658. if (child.hasPendingContractRequests())
  1659. {
  1660. throw new ValidationException("Contract.NoStatusChangeWithPendingStatus");
  1661. }
  1662. }
  1663. }
  1664. else if (pNewState == ContractStatusI.Deactive && vOldState != ContractStatusI.Deactive)
  1665. {
  1666. while (childIter.hasNext())
  1667. {
  1668. child = (Contract) childIter.next();
  1669. if (child.getCurrentStatusI().getStateI() != ContractStatusI.Deactive)
  1670. {
  1671. throw new ValidationException("CMS.Contract.RelatedContracts.ChildContractIsNotDeactivated",
  1672. getPublicKey(), child.getPublicKeyI());
  1673. }
  1674. if (child.hasPendingContractRequests())
  1675. {
  1676. throw new ValidationException("CMS.Contract.NoStatusChangeWithPendingStatus");
  1677. }
  1678. }
  1679. }
  1680. }
  1681. // end 236082_cms
  1682.  
  1683. /*
  1684. * Create a new ContractStatus object
  1685. */
  1686. ContractStatus pendingStatus = AbstractFactory.createObject(ContractStatus.class);
  1687.  
  1688. /*
  1689. * add status to list of contract stati
  1690. */
  1691. Vector<ContractStatus> vContractStati = getContractStati();
  1692. vContractStati.add(pendingStatus);
  1693. setContractStati(vContractStati);
  1694.  
  1695. /*
  1696. * set sequence number of status object
  1697. */
  1698. pendingStatus.setID(getNextContractStatusSeqNo());
  1699.  
  1700. /*
  1701. * Set the initial state to the current state
  1702. */
  1703. pendingStatus.setState(vOldState);
  1704.  
  1705. /*
  1706. * set back reference to this contract
  1707. */
  1708. pendingStatus.setContract(this);
  1709.  
  1710. /*
  1711. * Change its state to the requested state
  1712. */
  1713. pendingStatus.changeStateI(pReason, pNewState);
  1714. /*
  1715. * Mark the ContractStatus object to be pending
  1716. * only in the case that it is not a CS contract type
  1717. */
  1718. if (getContractType().isGmdSupported())
  1719. {
  1720. pendingStatus.setIsPendingI(true);
  1721. /*
  1722. * Assign it to the contract
  1723. */
  1724. _pendingStatus = pendingStatus;
  1725. }
  1726. else
  1727. {
  1728. // no GMD support, so directly make the status change effective
  1729. _currentStatus = pendingStatus;
  1730. }
  1731.  
  1732. long vTime;
  1733. int vDate = CAASDateConverter.toCAASDate(pValidFromDate); // PN337441 chenf
  1734. /*
  1735. * if the date specifies today's take the timestamp from today! (To make the tester happy!)
  1736. */
  1737. if (vDate != ServerTime.getCurrentDateAsInt()) // PN337441 chenf
  1738. {
  1739. vTime = pValidFromDate; // PN337441 chenf
  1740. }
  1741. else
  1742. {
  1743. vTime = ServerTime.getCurrentTimeAsLong();
  1744. }
  1745. /*
  1746. * set the time from which the status change is valid from
  1747. */
  1748. pendingStatus.setValidFromDate(vTime);
  1749.  
  1750. /*
  1751. * perform some additional action depending on the new pending state
  1752. * propagate changes to ContractedProductElements!
  1753. */
  1754. if (getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.CONTRACTED_COMPOSITE_PRODUCT))
  1755. {
  1756. ChangeContractStatusVisitor lCreateChangeContractStatusVisitor = VisitorFactory.getInstance()
  1757. .createChangeContractStatusVisitor(this, pNewState, vDate, pProperties);
  1758. accept(lCreateChangeContractStatusVisitor);
  1759. return lCreateChangeContractStatusVisitor.getAddedContractedProductElements();
  1760. }
  1761. return Collections.emptyList();
  1762. }
  1763. /**
  1764. * changeStatusI. Change the status of the CustomerContract by creating a new ContractStatus, which is marked as pending, using
  1765. * the state given in pNewState and the reason given in pReason.
  1766. *
  1767. * @param pNewState
  1768. * com.lhs.CommonDomain.bscs_core.external.StateI
  1769. * @param pReason
  1770. * @param pValidFromDate
  1771. * the time from which the pending status is valid from. For the time being only one pending state for a contract is
  1772. * possible. This may change in future! If the value is passed as a NullConversion.INT_NULL_VALUE the system time is
  1773. * taken instead.
  1774. * @param pProperties
  1775. * a list of properties which are used for resource retention in case of deactivation
  1776. * @param pInstance
  1777. * MVNO instance
  1778. * @param pEffectiveDate
  1779. * the effective date
  1780. * @param pRequestCode
  1781. * the request code
  1782. * @precondition There doesn't exist any pending status for that CustomerContract
  1783. * @throws SystemException
  1784. * @throws ComponentException
  1785. * @throws ValidationException
  1786. * @see com.lhs.Contract.bscs_core.ContractStatus
  1787. * @see com.lhs.CommonDomain.bscs_core.Reason
  1788. */
  1789. // PN337441 chenf
  1790. @Override
  1791. public List<ContractedProductElementI> changeStatusI(int pNewState, ReasonI pReason, long pValidFromDate,
  1792. KeyValueI[] pProperties, Instance pInstance, Timestamp pEffectiveDate, String pRequestCode) throws ComponentException,
  1793. ValidationException
  1794. {
  1795. /*
  1796. * Retrieve the current Status
  1797. */
  1798. ContractStatusI currentStatus = getCurrentStatusI();
  1799.  
  1800. /*
  1801. * get old state
  1802. */
  1803. int vOldState = currentStatus.getStateI();
  1804.  
  1805. // begin defect 254804 CWLEE
  1806. // checks if user has the permission to change the status
  1807. checkPermissionForTransition(vOldState, pNewState);
  1808. // end defect 254804
  1809. /*
  1810. * Retrieve the contract administrator
  1811. */
  1812. ContractAdministrator administrator = ContractAdministrator.getInstance();
  1813.  
  1814. if (isALContractI() && pNewState == ContractStatusI.Deactive && !getContractType().isGmdSupported())
  1815. {
  1816. Contract mainContract = (Contract) getCompositeContractSection().getGeneralContractSection().getMainContract();
  1817. mainContract.getCompositeContractSection().getGeneralContractSection().removeRelatedContract(this);
  1818. }
  1819.  
  1820. // --> defect 234767 NIJ
  1821. // - check for pending requests, in case of contract deactivation or suspension, refuse
  1822. if (vOldState == ContractStatusI.Active && (pNewState == ContractStatusI.Suspended || pNewState == ContractStatusI.Deactive))
  1823. {
  1824. ContractAdministrator.getInstance().checkContractPendingRequests(this);
  1825. }
  1826. // <-- 234767
  1827.  
  1828. // PN 238900
  1829. if (pNewState == ContractStatusI.Deactive && hasPendingBARequest())
  1830. {
  1831. throw new ValidationException("Contract.PendingBARequestOnConDeactivation", Long.valueOf(getIDI()));
  1832. }
  1833.  
  1834. if (pNewState == ContractStatusI.Deactive)
  1835. {
  1836.  
  1837. checkSharedAccountPackageAssignmentsForContractDeactivation(); // check if contract can be deactivated from shared account package perspective
  1838. }
  1839.  
  1840. /*
  1841. * if passed date is null than take the system date
  1842. */
  1843.  
  1844. // Begin PN337441 chenf
  1845. long vDate = pValidFromDate;
  1846. // End PN337441 chenf
  1847. if (NullConversion.isNull(pValidFromDate))
  1848. {
  1849. vDate = ServerTime.getCurrentTimeAsLong(); // PN337441 chenf
  1850. }
  1851. else
  1852. {
  1853. /*
  1854. * check whether date is valid
  1855. */
  1856. if (vDate < ServerTime.getCurrentDate().getTime())
  1857. {
  1858. throw new ValidationException("Contract.InvalidDate");
  1859. }
  1860. }
  1861.  
  1862. // Feature 53406. If this is a VPN Subscriber Contract (Administrator), do not allow to deactivate it if the VPN has members
  1863. // USc#021115 little optimization for the non active case
  1864. if (vOldState == ContractStatusI.Active &&
  1865. (pNewState == ContractStatusI.Deactive || pNewState == ContractStatusI.Suspended) && isVPNSubscriberContractI())
  1866. {
  1867. // - Get the internal and external members co ids. Since the error message cant hold all probably, lets limit both to 5.
  1868. // begin PN 00271021 wongpy
  1869. List<Long> vExtMembers = administrator.getVPNExternalMemberIds(getVPNOwnershipI(), this, ContractSettings.MAXEXTERNALCONTRACTSINVPNERROMESSAGE);
  1870. List<Long> vIntMembers = administrator.getVPNInternalMemberIds(getVPNOwnershipI(), this, ContractSettings.MAXINTERNALCONTRACTSINVPNERROMESSAGE);
  1871.  
  1872. // concat the co ids for the error message
  1873.  
  1874. StringBuilder coIds = new StringBuilder();
  1875.  
  1876. if (vExtMembers.size() > 0)
  1877. {
  1878. coIds.append("external : ");
  1879. }
  1880. for (int i = 0; i < vExtMembers.size(); i++)
  1881. {
  1882. Long value = vExtMembers.get(i);
  1883.  
  1884. if (i > 0)
  1885. {
  1886. coIds.append(",");
  1887. }
  1888.  
  1889. coIds.append(value.longValue());
  1890. }
  1891.  
  1892. if (vIntMembers.size() > 0)
  1893. {
  1894. coIds.append(" internal : ");
  1895. }
  1896. for (int i = 0; i < vIntMembers.size(); i++)
  1897. {
  1898. Long value = vIntMembers.get(i);
  1899. if (i > 0)
  1900. {
  1901. coIds.append(",");
  1902. }
  1903. coIds.append(value.longValue());
  1904. }
  1905. if (coIds.length() > 0)
  1906. {
  1907. throw new ValidationException("CMS.Contract.VPNHasMembers", coIds.toString());
  1908. }
  1909. }
  1910.  
  1911. // Feature 53406. If this is a VPN User Contract (member), do not allow to activate it if the VPN Subscriber contract is not
  1912. // active
  1913. // USc#021115 little optimization for the non active case
  1914. if (pNewState == ContractStatusI.Active && isVPNUserContractI())
  1915. {
  1916. Vector<VirtualPrivateNetworkI> vVPNMemberships = getVPNMembershipsI(); // a contract can hold more than one VPN
  1917. // Membership Service
  1918. Iterator<VirtualPrivateNetworkI> vIter = vVPNMemberships.iterator();
  1919. // Begin PN 00254647/d : Kaiser, CWLEE
  1920. // A VPN owner can have more than one contract. At least one has to be active, but not all of them and not the first one
  1921. // in the list.
  1922. // End PN 00254647/d
  1923. while (vIter.hasNext())
  1924. {
  1925. VirtualPrivateNetworkI vVPN = vIter.next();
  1926. // Begin PN 00254647/d : Kaiser
  1927. // ContractI vVPNSubsContract= (ContractI)(administrator.getVPNAgreementI(vTx,vVPN));
  1928. // if (vVPNSubsContract.getCurrentStatusI(vTx).getStateI()!=ContractStatusI.Active){
  1929. // throw new ValidationException("Contract.VPNSubscriberContractIsNotActive");
  1930. // }
  1931. boolean bActiveVPNOwnerContract = false;
  1932. ContractI[] aVPNSubsContract = administrator.getVPNAgreementsI(vVPN);
  1933. // AV PN 00261964 Begin
  1934. Contract lCustomerContract = null;
  1935. // AV PN 00261964 End
  1936.  
  1937. if (aVPNSubsContract.length > 0)
  1938. {
  1939. for (int i = 0; i < aVPNSubsContract.length; i++)
  1940. {
  1941. // AV PN 00261964 Begin
  1942. // if (((ContractI)aVPNSubsContract[i]).getCurrentStatusI().getStateI()==ContractStatusI.Active)
  1943. lCustomerContract = (Contract) aVPNSubsContract[i];
  1944. if (lCustomerContract.hasPendingRequests())
  1945. {
  1946. lCustomerContract.refreshObject();
  1947. AbstractDomainObject lClone = lCustomerContract.getInstanceForUpdate();
  1948. TransactionContext.getCurrent().getUnitOfWork().revertObject(lClone);
  1949. }
  1950.  
  1951. if (lCustomerContract.getCurrentStatusI().getStateI() == ContractStatusI.Active)
  1952. // AV PN 00261964 End
  1953. {
  1954. bActiveVPNOwnerContract = true;
  1955. break;
  1956. }
  1957. }
  1958. if (!bActiveVPNOwnerContract)
  1959. {
  1960. throw new ValidationException("Contract.VPNSubscriberContractIsNotActive", Long.valueOf(vVPN.getIDI()),
  1961. vVPN.getNameI());
  1962.  
  1963. }
  1964. }
  1965. else
  1966. {
  1967. throw new ValidationException("Contract.VPNSubscriberContractIsNotActive", Long.valueOf(vVPN.getIDI()),
  1968. vVPN.getNameI());
  1969.  
  1970. }
  1971.  
  1972. }
  1973. // End PN 00254647/d
  1974. }
  1975.  
  1976. /*
  1977. * Feature 81481_2. If this is an activation some new port IN checks are required.
  1978. * vParentRequest = zero means there is NO dependent request.
  1979. */
  1980. long vParentRequest = 0;
  1981. if (pNewState == ContractStatusI.Active)
  1982. {
  1983. CheckContractActivationVisitor vVisitor = new CheckContractActivationVisitor();
  1984. this.accept(vVisitor);
  1985. TaskI vTask = vVisitor.getFoundPendingDeactivationRequest();
  1986. if (vTask != null)
  1987. {
  1988. vParentRequest = vTask.getIDI();
  1989. // #TODO check for Alternate line contracts !!!!!
  1990. }
  1991. }
  1992.  
  1993. // feature 84926 - End date of tariff model assignment
  1994. // in the activation of a contract, test if the rate plan is still valid
  1995. if (pNewState == ContractStatusI.Active && vOldState == ContractStatusI.Onhold)
  1996. {
  1997. if (getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.CONTRACTED_COMPOSITE_PRODUCT))
  1998. {
  1999. CompositeProductI cp = (CompositeProductI) getContractedCompositeProductI().getProductI();
  2000. CompositeProductAvailabilityPeriodI period = administrator.getProductAdministrator().getCurrentCompositeProductAvailabilityPeriodI(cp);
  2001. if (period != null)
  2002. {
  2003. int lStatusChangeDate = CAASDateConverter.toCAASDate(vDate);
  2004. int lAvailableFromI = period.getAvailableFromI();
  2005. int lAvailableToI = period.getAvailableToI();
  2006. if (lAvailableFromI != NullConversion.INT_NULL_VALUE && lAvailableFromI > lStatusChangeDate ||
  2007. lAvailableToI != NullConversion.INT_NULL_VALUE && lAvailableToI < lStatusChangeDate)
  2008. // --> defect 230669 NIJ
  2009. {
  2010. long cpId = cp.getIDI();
  2011. Date availDateFrom = CAASDateConverter.toDate(lAvailableFromI);
  2012. Date availDateTo = CAASDateConverter.toDate(lAvailableToI);
  2013. Date compareDate = CAASDateConverter.toDate(lStatusChangeDate);
  2014. String sAvailDateFrom = availDateFrom.toString();
  2015. String sAvailDateTo = availDateTo.toString();
  2016.  
  2017. throw new ValidationException("Contract.ActionValidFromDateDoesNotMatchWithAvailabilityOfCompositeProduct", sAvailDateFrom + "->"
  2018. + sAvailDateTo, Long.valueOf(cpId), compareDate);
  2019. }
  2020. // <-- 230669
  2021. }
  2022. }
  2023. }
  2024. List<ContractedProductElementI> lAdditinalContractedServices;
  2025. // feature 84834 - Alternate Line
  2026. // if the contract takes part in an AL subscription all the contracts in the subscription will be affected
  2027. // when a suspension or reactivation is performed or a deactivation of the main contract
  2028. // USc#021115 little optimization to avoid method call if not necessary
  2029. if (pNewState == ContractStatusI.Deactive && isMainContractI() ||
  2030. (pNewState == ContractStatusI.Suspended
  2031. || pNewState == ContractStatusI.Active
  2032. && vOldState == ContractStatusI.Suspended)
  2033. && isRelatedContract())
  2034. {
  2035. Contract mainContract;
  2036. Vector<ContractI> relatedContracts;
  2037.  
  2038. if (isMainContractI())
  2039. {
  2040. mainContract = this;
  2041. relatedContracts = this.getCompositeContractSection().getGeneralContractSection().getRelatedContracts();
  2042. }
  2043. else
  2044. {
  2045. mainContract = (Contract) this.getCompositeContractSection().getGeneralContractSection().getMainContract();
  2046. relatedContracts = mainContract.getCompositeContractSection().getGeneralContractSection().getRelatedContracts();
  2047. }
  2048.  
  2049. // change the status of each related contract, which is not on hold
  2050. Iterator<ContractI> iter = relatedContracts.iterator();
  2051. while (iter.hasNext())
  2052. {
  2053. Contract current = (Contract) iter.next();
  2054.  
  2055. if (current.getCurrentStatusI().getStateI() != ContractStatusI.Onhold &&
  2056. current.getCurrentStatusI().getStateI() != pNewState)
  2057. {
  2058. current.changeStatus(pNewState, pReason, vDate, pProperties, pInstance, pEffectiveDate, pRequestCode); // PN337441
  2059. // chenf
  2060. }
  2061. }
  2062.  
  2063. // change the status of the main contract
  2064. lAdditinalContractedServices = mainContract.changeStatus(pNewState, pReason, vDate, pProperties, pInstance,
  2065. pEffectiveDate, pRequestCode); // PN337441 chenf
  2066. }
  2067. else
  2068. {
  2069. lAdditinalContractedServices = changeStatus(pNewState, pReason, vDate, pProperties, pInstance, pEffectiveDate,
  2070. pRequestCode); // PN337441 chenf
  2071. }
  2072.  
  2073. if (pNewState == ContractStatusI.Active)
  2074. {
  2075. ContractedResourcesPropertiesI crp = null;
  2076. if (currentStatus.getStateI() != ContractStatusI.Onhold)
  2077. {
  2078. // this is a reactivation
  2079. // --> defect 252780 NIJ/ reimplementing 00247400 DAE, missing in 801
  2080. ContractedCompositeProductI ccp = getContractedCompositeProductI();
  2081. // the resource might not yet assigned
  2082. Vector<ContractedResourcesPropertiesI> lConResourcesProperties = ccp.getContractedResourcesPropertiesI();
  2083. if (!lConResourcesProperties.isEmpty())
  2084. {
  2085. crp = lConResourcesProperties.get(0);
  2086. }
  2087. }
  2088.  
  2089. /*
  2090. * distinguish between inital activation and reactivation
  2091. */
  2092. short vPriority = ContractAdministrator.getInstance().getCommonDomainAdministrator().getUserPriorityI(GMDActionI.ActivateSubscription);
  2093.  
  2094. // - if suspension is not supported then by reactivation write action for activation
  2095. if (currentStatus.getStateI() == ContractStatusI.Onhold || crp == null)
  2096. {
  2097. // PN00235359 Larbig : do not set rating and provisioning flag here
  2098. /*
  2099. * 240721 - IN or not IN ?
  2100. * For the initial activation, the IN trigger must always be set
  2101. */
  2102. if (isINContract())
  2103. {
  2104. getContractTaskHandler().registerAction(ContractSettings.CONTRACT_ACTIVATION,
  2105. new AbstractDomainObjectI[]{this},
  2106. vDate,
  2107. vPriority,
  2108. TaskTypeI.Provisioning,
  2109. null,
  2110. null,
  2111. vParentRequest,
  2112. "S", pInstance, pEffectiveDate, pRequestCode);
  2113. }
  2114. else
  2115. {
  2116. getContractTaskHandler().registerAction(ContractSettings.CONTRACT_ACTIVATION,
  2117. new AbstractDomainObjectI[]{this},
  2118. vDate,
  2119. vPriority,
  2120. TaskTypeI.Provisioning,
  2121. null,
  2122. null,
  2123. vParentRequest,
  2124. "U", pInstance, pEffectiveDate, pRequestCode);
  2125. }
  2126.  
  2127. }
  2128. else
  2129. {
  2130. // PN00235359 Larbig : do not set rating and provisioning flag here
  2131. getContractTaskHandler().registerAction(ContractSettings.CONTRACT_REACTIVATION, new AbstractDomainObjectI[]{this},
  2132. vDate, vPriority, TaskTypeI.Provisioning, null, null, vParentRequest, pInstance, pEffectiveDate, pRequestCode);
  2133. }
  2134.  
  2135. // Begin PN 00302209 huangw
  2136. /* activate an event if the contract is reactivated. */
  2137. if (currentStatus.getStateI() == ContractStatusI.Suspended)
  2138. {
  2139. EventHandler.getInstance().activateEvent(this, ChargeableEventI.REACTIVATION_EVENT_NAME);
  2140. }
  2141. // End PN 00302209
  2142.  
  2143. }
  2144. else if (pNewState == ContractStatusI.Deactive)
  2145. {
  2146. /*
  2147. * distinguish between deactivation from suspension and from other states
  2148. */
  2149. short vPriority = ContractAdministrator.getInstance().getCommonDomainAdministrator().getUserPriorityI(GMDActionI.DeactivateSubscription);
  2150. if (currentStatus.getStateI() == ContractStatusI.Suspended)
  2151. {
  2152. // PN00235359 Larbig : do not set rating and provisioning flag here
  2153. getContractTaskHandler().registerAction(ContractSettings.CONTRACT_TRANSITION, new AbstractDomainObjectI[]{this},
  2154. vDate, vPriority, TaskTypeI.Provisioning, null, null, vParentRequest, pInstance, pEffectiveDate, pRequestCode);
  2155. }
  2156. else
  2157. {
  2158. // PN00235359 Larbig : do not set rating and provisioning flag here
  2159. getContractTaskHandler().registerAction(ContractSettings.CONTRACT_DEACTIVATION, new AbstractDomainObjectI[]{this},
  2160. vDate, vPriority, TaskTypeI.Provisioning, null, null, vParentRequest, pInstance, pEffectiveDate, pRequestCode);
  2161. }
  2162. }
  2163. else if (pNewState == ContractStatusI.Suspended)
  2164. {
  2165. short vPriority = ContractAdministrator.getInstance().getCommonDomainAdministrator().getUserPriorityI(GMDActionI.DeactivateSubscription);
  2166.  
  2167. getContractedCompositeProductI();
  2168. // PN00235359 Larbig : do not set rating and provisioning flag here
  2169. getContractTaskHandler().registerAction(ContractSettings.CONTRACT_SUSPENSION, new AbstractDomainObjectI[]{this},
  2170. vDate, vPriority, TaskTypeI.Provisioning, null, null, vParentRequest, pInstance, pEffectiveDate, pRequestCode);
  2171.  
  2172. // Begin PN 00302209 huangw
  2173. /*
  2174. * activate an event if the contract is suspended.
  2175. */
  2176. EventHandler.getInstance().activateEvent(this, ChargeableEventI.SUSPENSION_EVENT_NAME);
  2177. // End PN 00302209
  2178.  
  2179. }
  2180.  
  2181. /*
  2182. * feature 350656_cms
  2183. */
  2184. if (pNewState == ContractStatusI.Active && vOldState == ContractStatusI.Suspended)
  2185. {
  2186. // if it's a contract reactivation, just check if the pam schedule value changed IF a bill cycle change happened
  2187.  
  2188. configurePamScheduleForBillCycleChange(true, false, this);
  2189.  
  2190. }
  2191. else if (pNewState != ContractStatusI.Suspended && pNewState != ContractStatusI.Deactive)
  2192. {
  2193.  
  2194. configurePamClass(pInstance, pEffectiveDate, pRequestCode, null, false, false);
  2195.  
  2196. }
  2197. return lAdditinalContractedServices;
  2198. }
  2199.  
  2200. /**
  2201. * checkConsistency. Checks the consistency of the contract.
  2202. *
  2203. * @throws ValidationException
  2204. * @throws ComponentException
  2205. * @throws SystemException
  2206. */
  2207. protected void checkConsistency() throws ComponentException, ValidationException
  2208. {
  2209. // begin 236082_cms moved from (removed) CustomerContractTemplate
  2210. if (ContractType.SHNAME_NOST.equals(getContractType().getShortName()))
  2211. {
  2212. /*
  2213. * check whether customer is activ
  2214. */
  2215. int vCustomerState = getContractHolderI().getStatusI().getStateI();
  2216. if (vCustomerState != OrgNodeStatusI.Active)
  2217. {
  2218. throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.StatesOfContractHolderAndContractNotCompatible");
  2219. }
  2220.  
  2221. // check that technology is present
  2222. TechnologyI vTechnology = this.getContractedCompositeProductI().getTechnologyI();
  2223. if (vTechnology == null)
  2224. {
  2225. throw new ValidationException("Contract.MissingTechnology");
  2226. }
  2227.  
  2228. // create a new visitor and check the contract structure
  2229. ContractTemplateConsistencyVisitor lVisitor = VisitorFactory.getInstance().createContractTemplateConsistencyVisitor();
  2230.  
  2231. // visit the contract structure
  2232. this.accept(lVisitor);
  2233.  
  2234. // final check
  2235. lVisitor.finishConsistencyCheck();
  2236.  
  2237. }
  2238. // end 236082_cms
  2239.  
  2240. // 236082_cms removed if (this.isCustomerContract()) {
  2241. /*
  2242. * check whether customer is activ
  2243. */
  2244. int vState = getCurrentStatusI().getStateI();
  2245. int vCustomerState = getContractHolderI().getStatusI().getStateI();
  2246. if (vCustomerState != OrgNodeStatusI.Active && getPendingStatusI() != null && getPendingStatusI().getStateI() == ContractStatusI.Active)
  2247. {
  2248. // in case of an activation or deactivation the customer must be active as well
  2249. throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.StatesOfContractHolderAndContractNotCompatible");
  2250. }
  2251. if (
  2252. // not active customer AND not-de-active contract -not allowed, exception!
  2253. vState != ContractStatusI.Deactive && vCustomerState != OrgNodeStatusI.Active
  2254. &&
  2255. vState != ContractStatusI.Suspended && vCustomerState != OrgNodeStatusI.Suspended)
  2256. {
  2257. throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.StatesOfContractHolderAndContractNotCompatible");
  2258. }
  2259.  
  2260. ContractType contractType = getContractType();
  2261. // 236082_cms
  2262. if (contractType.isSectionSubsectionUsed(ProductSection.NAME, ProductSection.TECHNOLOGY))
  2263. {
  2264. // check that technology is present
  2265. TechnologyI vTechnology = this.getContractedCompositeProductI().getTechnologyI();
  2266. if (vTechnology == null)
  2267. {
  2268. throw new ValidationException("Contract.MissingTechnology");
  2269. }
  2270. }
  2271. // 236082_cms
  2272. if (contractType.isSectionSubsectionUsed(ProductSection.NAME, ProductSection.ALTERNATE_TARIFF))
  2273. {
  2274. // begin defect 262859 CWLEE: Check that alternate rate plan and BOP are not assigned at the same time
  2275. if (getContractedCompositeProductI().getPricingSchemeI(PricingSchemeRoleI.AlternativPricingScheme) != null
  2276. && getCurrentBOPPackageVersion() != null)
  2277. {
  2278. throw new ComponentException("Contract.ConsistencyCheckFailed.AlternateRatePlanAndBOPNotAllowed");
  2279. // end defect 262859
  2280. }
  2281. }
  2282. if (contractType.isSectionSubsectionUsed(ProductSection.NAME, ProductSection.CONTRACTED_COMPOSITE_PRODUCT))
  2283. {
  2284. // level contracts must not be checked than regular subscriber contracts
  2285. if (!this.isLevelContractI())
  2286. {
  2287. // create a new visitor and check the contract structure
  2288. // FSP 345205, PN 358243, MCH: added checking for agreement contract
  2289. if (contractType.isContractAgreementType())
  2290. {
  2291. AgreementContractConsistencyVisitor lVisitor = VisitorFactory.getInstance()
  2292. .createAgreementContractConsistencyVisitor();
  2293. // visit the contract structure
  2294. this.accept(lVisitor);
  2295. // final check
  2296. lVisitor.finishConsistencyCheck();
  2297. }
  2298. else
  2299. {
  2300. ContractConsistencyVisitor lVisitor = VisitorFactory.getInstance().createContractConsistencyVisitor();
  2301. // visit the contract structure
  2302. this.accept(lVisitor);
  2303. // final check
  2304. lVisitor.finishConsistencyCheck();
  2305. }
  2306. // end FSP 345205, PN 358243, MCH
  2307. }
  2308.  
  2309. /*
  2310. * Make the additional checks for free unit services
  2311. */
  2312.  
  2313. OrgNodeI holderI = getContractHolderI();
  2314. if (!holderI.areContractsAllowedI())
  2315. {
  2316. // if contains any non POFUL service an exception should be thrown
  2317. ContractedCompositeProduct vConProduct = getContractedCompositeProduct();
  2318. Iterator<ContractedProductElement> lIter = vConProduct.getContractedProductElements().iterator();
  2319.  
  2320. // it is allowed that the contract hasn't any service at all or all POFUL service set to deactive or onhold
  2321. while (lIter.hasNext())
  2322. {
  2323. ContractedProductElementI cpElementI = lIter.next();
  2324. if (cpElementI.getServiceSubtypeI() != NetworkServiceI.FREE_UNIT_TYPE_POFUL)
  2325. {
  2326. throw new ValidationException("Contract.OrgNodeNotAllowedToHaveContracts");
  2327. }
  2328. }
  2329. }
  2330.  
  2331. } // while hasnext
  2332. // 236082 removed}
  2333. }
  2334. /**
  2335. * checkConsistencyI. check the consistency of a contract. This method is called by the client to validate its input. For
  2336. * validation at commit time an internal, private method is used!
  2337. *
  2338. * @throws ValidationException
  2339. * @throws ComponentException
  2340. * @throws SystemException
  2341. */
  2342. @Override
  2343. public void checkConsistencyI()
  2344. throws ComponentException, ValidationException
  2345. {
  2346. // TODO_Heidi
  2347. // from CustomerContract
  2348. ContractedCompositeProduct vProduct = getContractedCompositeProduct();
  2349. // from AgreementContract
  2350. // ContractedProductI vProductI=getContractedCompositeProductI();
  2351. // ContractedCompositeAgreementProduct vProduct= (ContractedCompositeAgreementProduct) vProductI;
  2352. /*
  2353. * check against the 'build in' rules
  2354. */
  2355. vProduct.validateTechnology();
  2356. vProduct.validateTechnologyFlavour();
  2357. vProduct.validateNetwork();
  2358.  
  2359. /**
  2360. * OK, Ulrich. That time has come !
  2361. * We have normal customer contracts and prepaid contract templates.
  2362. */
  2363. if (this.isCustomerContract())
  2364. {
  2365. checkConsistency();
  2366. }
  2367. else if (this.isAgreementContract())
  2368. {
  2369. checkAgreementConsistency();
  2370. }
  2371.  
  2372. }
  2373. /**
  2374. * checkConsistency. Checks the consistency of the agreement contract.
  2375. *
  2376. * @param pCategory
  2377. * String
  2378. * @throws ValidationException
  2379. * @throws ComponentException
  2380. * @throws SystemException
  2381. */
  2382. protected void checkAgreementConsistency() throws ComponentException, ValidationException
  2383. {
  2384.  
  2385. /*
  2386. * check whether customer is activ
  2387. */
  2388. int vState = getCurrentStatusI().getStateI();
  2389. int vCustomerState = getContractHolderI().getStatusI().getStateI();
  2390. if (vState != ContractStatusI.Deactive && vCustomerState != OrgNodeStatusI.Active)
  2391. {
  2392. throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.StatesOfContractHolderAndContractNotCompatible");
  2393. }
  2394.  
  2395. // check that technology is present
  2396. TechnologyI vTechnology = this.getContractedCompositeProductI().getTechnologyI();
  2397. if (vTechnology == null)
  2398. {
  2399. throw new ValidationException("Contract.MissingTechnology");
  2400. }
  2401.  
  2402. }
  2403. /**
  2404. * Resets the transient references within this instance as long as
  2405. * some objects are not removed properly from the cache
  2406. */
  2407.  
  2408. protected void cleanTransientReferences()
  2409. {
  2410. /*
  2411. * reset some transient values
  2412. * after a merge the refs may refer to objects no longer availabe.
  2413. */
  2414. _currentStatus = null;
  2415. _pendingStatus = null;
  2416.  
  2417. // --> defect 349853 NiJ
  2418. getContractedCompositeProduct().cleanTransientReferences();
  2419. // <-- 349853
  2420. }
  2421. /**
  2422. * Create all aggregated objects like CompositeContractSection
  2423. *
  2424. * @throws ComponentException
  2425. * @throws ValidationException
  2426. */
  2427.  
  2428. @Override
  2429. public void createAggregatedObjects()
  2430. throws ComponentException, ValidationException
  2431. {
  2432. super.createAggregatedObjects();
  2433.  
  2434. /*
  2435. * Invoke the creation of the according aggregated objects and
  2436. * assign it to the Contract
  2437. */
  2438. _compositeContractSection = createCompositeContractSection();
  2439.  
  2440. }
  2441. /**
  2442. * @see com.lhs.ccb.sfw.domain.AbstractDomainObject#initAggregationRelationship()
  2443. */
  2444. @Override
  2445. public void initAggregationRelationship()
  2446. {
  2447. // set the parent in all contract sections
  2448. _compositeContractSection.setAggregatingParent(this);
  2449. }
  2450.  
  2451. /**
  2452. * @return The created composite contract section
  2453. * @throws ComponentException
  2454. */
  2455. protected CompositeContractSection createCompositeContractSection() throws ComponentException
  2456. {
  2457.  
  2458. return AbstractFactory.createAggregatedObject(this, CompositeContractSection.class);
  2459. }
  2460.  
  2461. /**
  2462. * This method is called if a contract should be removed from database.. The
  2463. * assigned resource are freed with respect to the retention mode stored in the
  2464. * passed properties.
  2465. *
  2466. * @param pProperties
  2467. * com.lhs.Topology.bscs_core.external.KeyValueI[]
  2468. */
  2469. protected void delete(KeyValueI... pProperties)
  2470. throws ComponentException, ValidationException
  2471. {
  2472. // 00265683 if (this.isCustomerContract()) {
  2473. /*
  2474. * iterate over contract and execute resource retention according to the parameters passed as properties
  2475. */
  2476. ContractedCompositeProduct vConProduct = getContractedCompositeProduct();
  2477. vConProduct.delete(pProperties);
  2478.  
  2479. // begin 00265683
  2480. CompositeContractSection compContrSection = this.getCompositeContractSection();
  2481. // delete all contract sections, their subsections and histories
  2482. compContrSection.getGeneralContractSection().delete(pProperties);
  2483. compContrSection.getProductSection().delete(pProperties);
  2484. compContrSection.getInvoiceSection().delete(pProperties);
  2485. compContrSection.getDataExchangeSection().delete(pProperties);
  2486. compContrSection.getPaymentSection().delete(pProperties);
  2487. compContrSection.getCustomizationSection().delete(pProperties);
  2488. // end 00265683
  2489.  
  2490. // 377727_E08_U07
  2491. List<ContractPamScheme> pamSchemes = this.getPamSchemes();
  2492. for (ContractPamScheme scheme : pamSchemes)
  2493. {
  2494. scheme.delete();
  2495. }
  2496.  
  2497. List<ContractPamScheme> pamSchemesFree = this.getPamSchemesFree();
  2498. for (ContractPamScheme scheme : pamSchemesFree)
  2499. {
  2500. scheme.delete();
  2501. }
  2502.  
  2503. /*
  2504. * delete all dependend objects from the document section
  2505. */
  2506. // this.getCompositeContractSection().getDocumentSection().delete(pProperties);
  2507.  
  2508. // Begin Defect 281935 Daniel Rezende
  2509. // Propagate the contract deletion to all plugins
  2510. long timestamp = ServerTime.getCurrentTimeAsLong();
  2511. AbstractDomainObjectI[] objects = new AbstractDomainObjectI[]{this};
  2512. PluginEvent cmsEvent = new PluginEvent(PluginEvent.CONTRACT_DELETION, timestamp, objects);
  2513. PluginAdministrator.getInstance().registerCMSEvent(cmsEvent);
  2514. // End Defect 281935 Daniel Rezende
  2515. /*
  2516. * delete the status object from contract
  2517. */
  2518. getCurrentStatusI().delete();
  2519.  
  2520. /*
  2521. * delete tickler records
  2522. */
  2523. Vector<BusinessPartnerEventMessageI> vTicklers = getBusinessPartnerEventMessages();
  2524. Iterator<BusinessPartnerEventMessageI> vIter = vTicklers.iterator();
  2525. AbstractDomainObjectI vADO = null;
  2526. while (vIter.hasNext())
  2527. {
  2528. vADO = vIter.next();
  2529. vADO.<AbstractDomainObject> getInstanceForUpdate().delete();
  2530. }
  2531.  
  2532. // if is an AL contract, delete the reference in CONTRACT_RELATION
  2533. // 00265683if (isALContractI()) {
  2534. if (getContractType().isSectionSubsectionUsed(GeneralContractSection.NAME, GeneralContractSection.CONTRACT_RELATION))
  2535. {
  2536. GeneralContractSection generalContractSection = this.getCompositeContractSection().getGeneralContractSection();
  2537. ContractRelation cRel = generalContractSection.getMainContractRelation();
  2538. if (cRel != null)
  2539. {
  2540. ContractI mainContractI = cRel.getMainContract();
  2541. Contract mainContract = (Contract) mainContractI;
  2542. mainContract.getCompositeContractSection().getGeneralContractSection().removeRelatedContract(this);
  2543.  
  2544. if (!cRel.isCloneForUpdate())
  2545. {
  2546. vADO = cRel.getInstanceForUpdate();
  2547. }
  2548. else
  2549. {
  2550. vADO = cRel;
  2551. }
  2552.  
  2553. vADO.delete();
  2554. }
  2555. }
  2556.  
  2557. // remove the reference to porting request, if exists
  2558. Vector<PortingRequest> requests = getPortingRequests();
  2559. Iterator<PortingRequest> iterator = requests.iterator();
  2560. PortingRequest portingRequest = null;
  2561. while (iterator.hasNext())
  2562. {
  2563. portingRequest = iterator.next();
  2564. if (!portingRequest.isCloneForUpdate())
  2565. {
  2566. portingRequest = portingRequest.getInstanceForUpdate();
  2567. }
  2568.  
  2569. portingRequest.setContract(null);
  2570.  
  2571. HistoricalPortingRequest portingRequestHistory = null;
  2572. List<HistoricalPortingRequest> historyList = portingRequest.getHistoricalPortingRequests();
  2573. if (!historyList.isEmpty())
  2574. {
  2575. int lSize = historyList.size();
  2576. for (int i = 0; i < lSize; i++)
  2577. {
  2578. portingRequestHistory = historyList.get(i);
  2579. if (!portingRequestHistory.isCloneForUpdate())
  2580. {
  2581. portingRequestHistory = portingRequestHistory.getInstanceForUpdate();
  2582. }
  2583.  
  2584. portingRequestHistory.setContractIdI(NullConversion.LONG_NULL_VALUE);
  2585. }
  2586. }
  2587. }
  2588.  
  2589. // PN 312099, MCH 29.08.2008
  2590. // remove the lock objects
  2591. removeLocks();
  2592. // end 312099, MCH 29.08.2008
  2593.  
  2594. /*
  2595. * clean up the instance
  2596. */
  2597. cleanTransientReferences();
  2598. }
  2599.  
  2600. // PN 312099, MCH 29.08.2008
  2601. /**
  2602. * Removes the lock objects.
  2603. */
  2604. protected void removeLocks()
  2605. {
  2606. // billing lock
  2607. BillingContractLock billingLock = getBillingLock();
  2608.  
  2609. if (billingLock != null)
  2610. {
  2611. billingLock.delete();
  2612. }
  2613.  
  2614. // re-rating lock
  2615. ReratingContractLock reratingLock = getReratingLock();
  2616.  
  2617. if (reratingLock != null)
  2618. {
  2619. reratingLock.delete();
  2620. }
  2621. }
  2622. // end 312099, MCH 29.08.2008
  2623.  
  2624. /**
  2625. * Read all BusinessPartnerEventMessages/Tickler from the database related to this contract. Creation date: (03/14/2001 10:18:22
  2626. * AM)
  2627. *
  2628. * @return Vector
  2629. * @throws ComponentException
  2630. */
  2631. @SuppressWarnings({"unchecked", "rawtypes"})
  2632. public Vector<BusinessPartnerEventMessageI> getBusinessPartnerEventMessages()
  2633. throws ComponentException
  2634. {
  2635.  
  2636. ExpressionBuilder vExpressionBuilder = new ExpressionBuilder();
  2637. Expression vExpression = vExpressionBuilder.get("ContractID").equal(getIDI());
  2638.  
  2639. return (Vector) AbstractFactory.readQueryObjects(BusinessPartnerEventMessage.class, vExpression);
  2640. }
  2641. /**
  2642. * convinience method for the TaskManagement component
  2643. *
  2644. * @return com.lhs.Contract.bscs_core.external.ContractedCompositeProductI
  2645. * @throws ValidationException
  2646. * @throws ComponentException
  2647. * @throws SystemException
  2648. */
  2649. @Override
  2650. public ContractedCompositeProductI getContractedCompositeProductI() throws ComponentException, ValidationException
  2651. {
  2652.  
  2653. ProductSectionI vProductSection = getProductSectionI();
  2654.  
  2655. ProductSection lProductSection = (ProductSection) vProductSection;
  2656. /*
  2657. * for the time being exactly one ContractedCompositeProduct is
  2658. * assigned to a contract
  2659. */
  2660. return lProductSection.getContractedCompositeProduct();
  2661. }
  2662.  
  2663. /**
  2664. * Returns the contracted rateplan.
  2665. *
  2666. * @return com.lhs.Contract.bscs_core.ContractedCompositeProduct
  2667. * @throws ValidationException
  2668. * @throws ComponentException
  2669. * @throws SystemException
  2670. */
  2671. public ContractedCompositeProduct getContractedCompositeProduct() throws ComponentException, ValidationException
  2672. {
  2673.  
  2674. ProductSectionI vProductSection = getProductSectionI();
  2675.  
  2676. ProductSection lProductSection = (ProductSection) vProductSection;
  2677. /*
  2678. * for the time being exactly one ContractedCompositeProduct is
  2679. * assigned to a contract
  2680. */
  2681. return lProductSection.getContractedCompositeProduct();
  2682. }
  2683. /**
  2684. * getContractStati. Returns the list of contract stati.
  2685. *
  2686. * @author Ulrich Schaefer
  2687. * @return Vector
  2688. */
  2689. public Vector<ContractStatus> getContractStati()
  2690. {
  2691. return FWValueHolder.getValue(_contractStati);
  2692. }
  2693. /**
  2694. * getCurrentStatusI. Returns the current status of the Contract.
  2695. *
  2696. * @return com.lhs.Contract.bscs_core.external.ContractStatusI
  2697. * @throws SystemException
  2698. * @throws ComponentException
  2699. * @throws ValidationException
  2700. */
  2701.  
  2702. @Override
  2703. public ContractStatusI getCurrentStatusI()
  2704. throws ComponentException, ValidationException
  2705. {
  2706. /*
  2707. * Check whether a currentStatus is assigned
  2708. */
  2709. if (_currentStatus == null)
  2710. {
  2711. retrieveCurrentAndPendingStatus();
  2712. }
  2713. return _currentStatus;
  2714. }
  2715.  
  2716. /**
  2717. * getExternalContractReferenceNoI. Returns the identifier for this contract used by an external application
  2718. *
  2719. * @return String
  2720. */
  2721.  
  2722. @Override
  2723. public String getExternalContractReferenceNoI()
  2724. {
  2725. if (this.isAgreementContract())
  2726. {
  2727. return null;
  2728. }
  2729. return _externalContractReferenceNo;
  2730. }
  2731. /**
  2732. * getHistoryOfI. Returns the history of the contract
  2733. *
  2734. * @return Vector
  2735. */
  2736.  
  2737. @Override
  2738. public Vector getHistoryI()
  2739. {
  2740. return null;
  2741. }
  2742.  
  2743. /**
  2744. * Access to TaskHandler associated to this instance (which must be a clone!)
  2745. *
  2746. * @return com.lhs.Contract.bscs_core.ContractTaskHandler
  2747. * @throws ComponentException
  2748. * @throws ValidationException
  2749. */
  2750. public final ContractTaskHandler getContractTaskHandler()
  2751. throws ComponentException, ValidationException
  2752. {
  2753.  
  2754. if (_contractTaskHandler == null)
  2755. {
  2756. throw new ComponentException("Contract.MissingContractTaskHandler");
  2757. }
  2758.  
  2759. return _contractTaskHandler;
  2760. }
  2761.  
  2762. /**
  2763. * Returns the history of the objects specified by the passed classname assigned to this contract
  2764. *
  2765. * @return Vector
  2766. * @throws SystemException
  2767. * @throws ComponentException
  2768. */
  2769.  
  2770. @Override
  2771. @SuppressWarnings("unchecked")
  2772. public <T extends AbstractDomainObjectI> List<T> getHistoryOfI(Class<T> pClassname)
  2773. throws ComponentException
  2774. {
  2775.  
  2776. /*
  2777. * Select the ValueHolder according to the passed classname
  2778. * (Only ContractStatus / ContractTurnover are valid classnames)
  2779. */
  2780. if (!ContractStatus.class.equals(pClassname))
  2781. {
  2782. throw new ComponentException("CommonDomain.Parameter.IsNull", "Invalid classname");
  2783. }
  2784. return (List<T>) getContractStati();
  2785. }
  2786. /**
  2787. * getIdOfContractRepresentativeI. Returns the id of the contract representative
  2788. *
  2789. * @return String
  2790. */
  2791.  
  2792. @Override
  2793. public String getIdOfContractRepresentativeI()
  2794. {
  2795. if (this.isAgreementContract())
  2796. {
  2797. return null;
  2798. }
  2799. return _idOfContractRepresentative;
  2800. }
  2801.  
  2802. /**
  2803. * Returns the name of the contract representative
  2804. *
  2805. * @return String
  2806. */
  2807.  
  2808. @Override
  2809. public String getNameOfContractRepresentativeI()
  2810. {
  2811. if (this.isAgreementContract())
  2812. {
  2813. return null;
  2814. }
  2815. return _nameOfContractRepresentative;
  2816. }
  2817. /**
  2818. * Returns the pending status of the Contract.
  2819. *
  2820. * @return com.lhs.Contract.bscs_core.external.ContractStatusI
  2821. * @throws SystemException
  2822. * @throws ComponentException
  2823. * @throws ValidationException
  2824. */
  2825.  
  2826. @Override
  2827. public ContractStatusI getPendingStatusI()
  2828. throws ComponentException, ValidationException
  2829. {
  2830.  
  2831. /*
  2832. * Check whether a pendingStatus is assigned
  2833. */
  2834. if (_pendingStatus == null)
  2835. {
  2836. /*
  2837. * Check whether the current Status has already been retrieved
  2838. */
  2839. if (_currentStatus == null)
  2840. {
  2841. retrieveCurrentAndPendingStatus();
  2842. }
  2843. }
  2844.  
  2845. return _pendingStatus;
  2846. }
  2847.  
  2848. /**
  2849. * Returns the VPNs this contract belongs to (as a Member).
  2850. * Creation date: (7/24/01 3:33:51 PM)
  2851. *
  2852. * @return Vector
  2853. */
  2854. @Override
  2855. public Vector<VirtualPrivateNetworkI> getVPNMembershipsI() throws ComponentException, ValidationException
  2856. {
  2857.  
  2858. if (this.isAgreementContract())
  2859. {
  2860. return null;
  2861. }
  2862.  
  2863. /*
  2864. * The only way to know the VPN_IDs is look for
  2865. * the VPN Access Services
  2866. */
  2867.  
  2868. // get the ContractedCompositeProduct
  2869. ContractedCompositeProduct ccp = getContractedCompositeProduct();
  2870.  
  2871. // Cycle through all ContractedProductElements
  2872. Vector<VirtualPrivateNetworkI> vResult = new Vector<VirtualPrivateNetworkI>(3);
  2873.  
  2874. // let's iterate through all ContractedProductElements of this ContractedSimpleProduct
  2875. Vector<ContractedProductElement> listPEs = ccp.getContractedProductElements();
  2876. if (!listPEs.isEmpty())
  2877. {
  2878. Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
  2879. while (iterPEs.hasNext())
  2880. {
  2881. ContractedProductElement contractedPE = iterPEs.next();
  2882.  
  2883. NetworkServiceI vNetworkService = contractedPE.getNetworkService();
  2884. if (vNetworkService == null)
  2885. {
  2886. // skip non network services
  2887. continue;
  2888. }
  2889. if (vNetworkService.isVPNInternalAccessServiceI())
  2890. {
  2891. // get the VPN_NUMBER from the service parameter
  2892. Vector<ParameterValueNodeI> parameterValues = contractedPE.getCurrentParameterValueNodesI();
  2893. if (parameterValues.isEmpty())
  2894. {
  2895. // This should not occur because the parameters need to be checked before!
  2896. throw new ComponentException("Contract.InvalidParameterList", "VPN Number");
  2897. }
  2898. // Search for the VPN_NUMBER parameter
  2899. Iterator<ParameterValueNodeI> paramIterI = parameterValues.iterator();
  2900. ProductAdministratorI vPAdmin = ContractAdministrator.getInstance().getProductAdministrator(); // PN 315262,
  2901. // refactoring,
  2902. // MCH 10.11.2008
  2903. String VPNNumberString = null;
  2904.  
  2905. while (paramIterI.hasNext())
  2906. {
  2907. ParameterValueNodeI paramNodeI = paramIterI.next();
  2908. if (vPAdmin.getParameterIndexI(vNetworkService, paramNodeI.getParameterI()) == 2)
  2909. { // this is the VPN_NUMBER
  2910. ParameterValueNode paramNode = (ParameterValueNode) paramNodeI;
  2911. VPNNumberString = paramNode.getStringValue();
  2912. break;
  2913. }
  2914. }
  2915.  
  2916. if (VPNNumberString == null)
  2917. {
  2918. // A VPN Internal Access Service must have the VPNNumber parameter
  2919. throw new ComponentException("Contract.InvalidParameterList", "VPN Number");
  2920. }
  2921.  
  2922. /* Retrieve the VPNNumber */
  2923. ContractAdministrator vCoAdmin = ContractAdministrator.getInstance();
  2924.  
  2925. // FSP 290812, PN 290812/d, MCH 22.09.2008: replaced ResourceAttributeI[] by HashMap<String,Object>
  2926. long lResourceRegulationId = ((ResourceAdministrator) vCoAdmin.getResourceAdministrator()).getVpnOwnerNumberResourceRegulation();
  2927.  
  2928. HashMap<String, Object> attr = new HashMap<String, Object>();
  2929. attr.put(Attributes.RA_RESOURCE_REGULATION_ID, Long.valueOf(lResourceRegulationId));
  2930. attr.put(Attributes.RA_NUMBER, VPNNumberString);
  2931.  
  2932. Vector<ResourceI> vList = vCoAdmin.getResourceAdministrator().queryResourcesI(ResourceTypeI.vpn_number, QueryModeI.qm_vpn_user_contract,
  2933. getContractedCompositeProductI().getTechnologyFlavourI().getIDI(), attr);
  2934. // end 290812, PN 290812/d, MCH 22.09.2008
  2935.  
  2936. if (!vList.isEmpty())
  2937. {
  2938. VPNNumberI vVPNNumber = (VPNNumberI) vList.firstElement();
  2939. vResult.add(vVPNNumber.getVirtualPrivateNetworkI());
  2940. }
  2941. else
  2942. {
  2943. throw new ComponentException(DomainService.RC_INVALID_PARAMETER_VALUE, "VPN Number");
  2944. }
  2945. }
  2946. else if (vNetworkService.isVPNExternalAccessServiceI())
  2947. { // The VPN_ID is the CONTR_SERVICES_CAP table
  2948. // get the VPN_ID from the ContractedDNproperties
  2949. Vector<ContractedDNPropertiesI> pCDNPList = contractedPE.getContractedDNPropertiesI();
  2950.  
  2951. if (!pCDNPList.isEmpty())
  2952. {
  2953. // we need only the first one
  2954. ContractedDNPropertiesI pCDNProp = pCDNPList.firstElement();
  2955.  
  2956. vResult.add(pCDNProp.getVPNI());
  2957.  
  2958. // --> 246769 LeT
  2959. }
  2960. // <-- 246769
  2961.  
  2962. }
  2963. }
  2964. }
  2965. return vResult;
  2966. }
  2967. /**
  2968. * If the contract is a VPN Administrator(subscriber) Contract, returns the administered VPN
  2969. * This is for feature 53406
  2970. *
  2971. * @author E. Iglesias
  2972. * @return boolean
  2973. */
  2974. @Override
  2975. public VirtualPrivateNetworkI getVPNOwnershipI()
  2976. throws ComponentException, ValidationException
  2977. {
  2978.  
  2979. if (this.isAgreementContract())
  2980. {
  2981. return null;
  2982. }
  2983.  
  2984. // get the ContractedCompositeProduct
  2985. ContractedCompositeProduct ccp = getContractedCompositeProduct();
  2986.  
  2987. Vector<ContractedProductElement> listPEs = ccp.getContractedProductElements();
  2988. if (listPEs.isEmpty())
  2989. {
  2990. // no ContractedProductElements found !
  2991. throw new ValidationException("Contract.InvalidVPNSubscriberContract",
  2992. new Object[]{Long.valueOf(getIDI()), getPublicKey()});
  2993.  
  2994. }
  2995. VirtualPrivateNetworkI ret = null;
  2996.  
  2997. Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
  2998. while (iterPEs.hasNext())
  2999. {
  3000. // Cycle through all ContractedProductElements
  3001. ContractedProductElement contractedPEI = iterPEs.next();
  3002.  
  3003. // if ContractedProductElement is VPN Administrator, the contract is VPN Subscriber Contract
  3004. NetworkServiceI vNetworkService = contractedPEI.getNetworkService();
  3005. if (vNetworkService != null && vNetworkService.isVPNAdministratorI())
  3006. {
  3007. // get the VPN_ID from the ContractedDNproperties
  3008. Vector<ContractedDNPropertiesI> pCDNPList = contractedPEI.getContractedDNPropertiesI();
  3009. // this service has only one resource asigned, the VPNNumber
  3010. ContractedDNPropertiesI pCDNProp = pCDNPList.firstElement();
  3011.  
  3012. ret = pCDNProp.getVPNI();
  3013. break;
  3014. }
  3015.  
  3016. }
  3017.  
  3018. return ret;
  3019. }
  3020. /**
  3021. * If the contract is a VPN Administrator(subscriber) Contract for the pVPN network, returns the VPN Number that identifies this
  3022. * VPN.
  3023. * This is for feature 53406
  3024. *
  3025. * @author E. Iglesias
  3026. * @return VPNNumber
  3027. */
  3028. @Override
  3029. public VPNNumberI getVPNOwnershipVPNNumberI(VirtualPrivateNetworkI pVPN)
  3030. throws ComponentException, ValidationException
  3031. {
  3032.  
  3033. if (isAgreementContract())
  3034. {
  3035. return null;
  3036. }
  3037.  
  3038. // get the ContractedCompositeProduct
  3039. ContractedCompositeProduct ccp = getContractedCompositeProduct();
  3040.  
  3041. Vector<ContractedProductElement> listPEs = ccp.getContractedProductElements();
  3042. if (listPEs.isEmpty())
  3043. {
  3044. // no ContractedProductElements found !
  3045. throw new ValidationException("Contract.InvalidVPNSubscriberContract",
  3046. new Object[]{Long.valueOf(getIDI()), getPublicKey()});
  3047. }
  3048. Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
  3049. VPNNumberI ret = null;
  3050. while (iterPEs.hasNext())
  3051. {
  3052. // cycle through all ContractedProductElements
  3053. ContractedProductElement contractedPEI = iterPEs.next();
  3054.  
  3055. // if ContractedProductElement is VPN Administrator, the contract is VPN Subscriber Contract
  3056. NetworkServiceI vNetworkService = contractedPEI.getNetworkService();
  3057. if (vNetworkService != null && vNetworkService.isVPNAdministratorI())
  3058. {
  3059. // get the VPN_ID from the ContractedDNproperties
  3060. Vector<ContractedDNPropertiesI> pCDNPList = contractedPEI.getContractedDNPropertiesI();
  3061. // this service has only one resource asigned, the VPNNumber
  3062. ContractedDNPropertiesI pCDNProp = pCDNPList.firstElement();
  3063. if (pCDNProp.getVPNI().getIDI() == pVPN.getIDI())
  3064. {
  3065. ret = (VPNNumberI) pCDNProp.getDirectoryNumberI();
  3066. break;
  3067. }
  3068. }
  3069. }
  3070.  
  3071. return ret;
  3072. }
  3073. /**
  3074. * Has this contract any pending subscription requests ? This method checks whether any contract-level entity is pending. It
  3075. * does NOT iterate through the services. Current implementation is based on the information in memory. Therefore this metod can
  3076. * still return true in a situation when SP FinishRequest was called from GMD-side.
  3077. *
  3078. * @return boolean true - there is pending subscription request(s) for this contract false - there is no pending requests
  3079. * @throws ValidationException
  3080. * @throws ComponentException
  3081. * @throws SystemException
  3082. */
  3083. public boolean hasPendingContractRequests() throws ComponentException, ValidationException
  3084. {
  3085.  
  3086. // get status of the Contract
  3087. ContractStatusI status = getCurrentStatusI();
  3088.  
  3089. // get state of the Contract
  3090. int state = status.getStateI();
  3091. // US 00-10-21 if contract is deactivated, no pending requests can exist
  3092. if (state == ContractStatusI.Deactive)
  3093. {
  3094. return false;
  3095. }
  3096.  
  3097. //
  3098. // for onhold contracts and for contract activated in the same transaction
  3099. // always assume as not pending.
  3100. //
  3101. if (state == ContractStatusI.Onhold || isNew())
  3102. {
  3103. return false;
  3104. }
  3105. //
  3106. // check pending contract status
  3107. // if status is pending then contract is also pending
  3108. if (status.isPendingI() || getPendingStatusI() != null)
  3109. {
  3110. return true;
  3111. }
  3112.  
  3113. if (this.isCustomerContract())
  3114. {
  3115. //
  3116. // check pending rate plan change
  3117. //
  3118. ContractedCompositeProduct compositeProduct = getContractedCompositeProduct();
  3119.  
  3120. if (compositeProduct.getPendingCompositeProductI() != null)
  3121. {
  3122. return true;
  3123. }
  3124.  
  3125. //
  3126. // check pending requested carriers
  3127. //
  3128. // check LocalExchangeCarrier
  3129. if (compositeProduct.getRequestedCarrierI(CarrierRoleI.LocalExchangeCarrier) != null)
  3130. {
  3131. return true;
  3132. }
  3133.  
  3134. if (compositeProduct.getRequestedCarrierI(CarrierRoleI.LongDistanceCarrier) != null)
  3135. {
  3136. return true;
  3137. }
  3138.  
  3139. /*
  3140. * check whether a Storage Medium replacement is pending
  3141. */
  3142. // --> defect 233437 NIJ
  3143. Vector<ContractedResourcesPropertiesI> contrResPropListI = compositeProduct.getContractedResourcesPropertiesI();
  3144. Iterator<ContractedResourcesPropertiesI> iterI = contrResPropListI.iterator();
  3145. while (iterI.hasNext())
  3146. {
  3147. ContractedResourcesPropertiesI crpI = iterI.next();
  3148. if (crpI != null && crpI.getRequestedStateI() != ContractedResourcesPropertiesI.Undefined)
  3149. {
  3150. return true;
  3151. }
  3152. }
  3153. // <-- 233437
  3154.  
  3155. /*
  3156. * 240721
  3157. */
  3158. if (compositeProduct.hasPendingTariffOptionsEntry())
  3159. {
  3160. return true;
  3161. }
  3162.  
  3163. // Removed with 351863.
  3164. /*
  3165. * if (isCloneForUpdate())
  3166. * {
  3167. * if (getContractTaskHandler().isINTriggerRequestRegistered())
  3168. * {
  3169. * return true;
  3170. * }
  3171. * }
  3172. */
  3173. }
  3174.  
  3175. return false;
  3176. }
  3177. /**
  3178. * Has this contract any pending requests ? This method iterates throught the whole contract including the services to find any
  3179. * entity that is pending. Current implementation is based on the information in memory. Therefore this metod can still return
  3180. * true in a situation when SP FinishRequest was called from GMD-side.
  3181. *
  3182. * @return boolean true - there is pending request(s) for this contract false - there is no pending requests
  3183. * @throws ValidationException
  3184. * @throws ComponentException
  3185. * @throws SystemException
  3186. */
  3187. public boolean hasPendingRequests() throws ComponentException, ValidationException
  3188. {
  3189. // TODO_Heidi
  3190. // from Contract:
  3191. // return false;
  3192.  
  3193. // fo CustomerContract and AgreementContract:
  3194.  
  3195. // get status of the Contract
  3196. ContractStatusI status = getCurrentStatusI();
  3197.  
  3198. // get state of the Contract
  3199. int state = status.getStateI();
  3200. // US 00-10-21 if contract is deactivated, no pending requests can exist
  3201. if (state == ContractStatusI.Deactive)
  3202. {
  3203. return false;
  3204. }
  3205.  
  3206. //
  3207. // check pending contract status
  3208. //
  3209. if (status.isPendingI() || getPendingStatusI() != null)
  3210. {
  3211. if (_log.isLoggable(Level.FINE))
  3212. {
  3213. _log.fine("Pending contract (status change) for CO_ID=" + getIDI());
  3214. }
  3215. return true;
  3216. }
  3217.  
  3218. //
  3219. // if not contract status is pending and contract is onhold we can
  3220. // stop immediatly
  3221. //
  3222. if (state == ContractStatusI.Onhold)
  3223. {
  3224. return false;
  3225. }
  3226.  
  3227. if (this.isCustomerContract())
  3228. {
  3229. //
  3230. // check pending rate plan change
  3231. //
  3232. ContractedCompositeProduct compProduct = getContractedCompositeProduct();
  3233. if (compProduct.hasPendingRequests())
  3234. {
  3235. return true;
  3236. }
  3237. ProductSection prodSection = (ProductSection) getProductSectionI();
  3238. List<ContractedRatingOptionVersion> contrRatingOptVersions = prodSection.getContractedRatingOptionVersions();
  3239. for (ContractedRatingOptionVersion contrRatingOptVersion : contrRatingOptVersions)
  3240. {
  3241. if (contrRatingOptVersion.isPending())
  3242. {
  3243. return true;
  3244. }
  3245. }
  3246. if (getCompositeContractSection().getGeneralContractSection().hasPendingRequest())
  3247. {
  3248. return true;
  3249. }
  3250.  
  3251. if (this.hasPendingPamScheme()) {
  3252. return true;
  3253. }
  3254. }
  3255. return false;
  3256.  
  3257. }
  3258. /**
  3259. * Initializes the CustomerContract by setting backward
  3260. * references within its aggregated objects.
  3261. */
  3262.  
  3263. protected void initialize() throws ComponentException
  3264. {
  3265. /*
  3266. * Retrieve the ProductSection
  3267. */
  3268. if (_compositeContractSection != null)
  3269. {
  3270. ProductSection productSection = _compositeContractSection.getProductSection();
  3271.  
  3272. if (productSection != null)
  3273. {
  3274. /*
  3275. * set back reference to this instance
  3276. */
  3277. productSection.initialize();
  3278.  
  3279. }
  3280. }
  3281. else
  3282. {
  3283. _log.severe("Contract package internal error during contract initialization: Contract structure corrupted.");
  3284. }
  3285. }
  3286. /**
  3287. * Check if the contract is an AL contract.
  3288. * Feature 84834 - Alternate Line.
  3289. *
  3290. * @author Renata Spencer
  3291. * @return boolean
  3292. */
  3293.  
  3294. @Override
  3295. public boolean isALContractI()
  3296. {
  3297. if (this.isAgreementContract())
  3298. {
  3299. return false;
  3300. }
  3301. return isChildContract();
  3302.  
  3303. }
  3304.  
  3305. /**
  3306. * Check if the contract is child contract.
  3307. * Feature 84834 - Alternate Line.
  3308. *
  3309. * @author Renata Spencer
  3310. * @return boolean
  3311. */
  3312.  
  3313. public boolean isChildContract()
  3314. {
  3315. return "R".equals(_relationType);
  3316. }
  3317. /**
  3318. * returns the relation type of the contracz
  3319. *
  3320. * @author Calin Naghi
  3321. * @return String
  3322. */
  3323.  
  3324. @Override
  3325. public String getRelationType()
  3326. {
  3327. return _relationType;
  3328. }
  3329.  
  3330. /**
  3331. * isConfirmationGeneratedI. Returns whether the confirmation document has been generated
  3332. *
  3333. * @return boolean
  3334. */
  3335.  
  3336. @Override
  3337. public boolean isConfirmationGeneratedI()
  3338. {
  3339. if (this.isAgreementContract())
  3340. {
  3341. return false;
  3342. }
  3343. return "X".equals(_confirmationGenerated);
  3344. }
  3345.  
  3346. /**
  3347. * Check if the contract is a main contract.
  3348. * Feature 84834 - Alternate Line.
  3349. *
  3350. * @author Renata Spencer
  3351. * @return boolean
  3352. */
  3353.  
  3354. @Override
  3355. public boolean isMainContractI()
  3356. {
  3357. return MAIN.equals(_relationType);
  3358. }
  3359.  
  3360. /**
  3361. * Check if the contract is a related contract.
  3362. * Feature 84834 - Alternate Line.
  3363. *
  3364. * @return boolean
  3365. */
  3366. protected boolean isRelatedContract()
  3367. {
  3368. return RELATED.equals(_relationType);
  3369. }
  3370.  
  3371. /**
  3372. * isNotValidatedI. Returns whether the contract has been validated
  3373. *
  3374. * @return boolean
  3375. */
  3376. @Override
  3377. public boolean isNotValidatedI()
  3378. {
  3379. return "X".equals(_notValidated);
  3380. }
  3381.  
  3382. /**
  3383. * isOnTrialI.
  3384. * Return true if contract is on trial that means trial end date is equal or greater than the current date
  3385. *
  3386. * @return boolean
  3387. */
  3388. @Override
  3389. public boolean isOnTrialI() throws ComponentException
  3390. {
  3391. // TODO_Heidi: only for CustomerContract
  3392. return this.getCompositeContractSection().getProductSection().getTrialPeriodEndDate() >= ServerTime.getCurrentDateAsInt();
  3393. // if agreement contract
  3394. // return false;
  3395. }
  3396. /**
  3397. * This method returns true if this contract is preactivated. We can find out this information via the StorageMedium. If it has
  3398. * a PrepaidProfile associated, then return true Creation date: (7/12/01 10:14:22 AM)
  3399. *
  3400. * @return boolean
  3401. * @author Sergiu Burian
  3402. * @throws ComponentException
  3403. * @throws ValidationException
  3404. */
  3405.  
  3406. public boolean isPreactivatedContract() throws ComponentException, ValidationException
  3407. {
  3408. boolean retValue = false;
  3409.  
  3410. // get the ContractedCompositeProduct
  3411. ContractedCompositeProductI ccpI = getContractedCompositeProductI();
  3412. ContractedCompositeProduct ccp = (ContractedCompositeProduct) ccpI;
  3413.  
  3414. // check if the technology is storage medium driven
  3415. TelecomTechnologyI vTechnology = (TelecomTechnologyI) getContractedCompositeProductI().getTechnologyI();
  3416. if (vTechnology != null && vTechnology.isStorageMediumDrivenI())
  3417. {
  3418. // get the storage medium
  3419. Vector<ResourceI> storageMediumList = ccp.getResourcesByTypeI(ResourceTypeI.storage_medium);
  3420.  
  3421. if (!storageMediumList.isEmpty())
  3422. {
  3423. // get the first element
  3424. StorageMediumI stMed = (StorageMediumI) storageMediumList.firstElement();
  3425.  
  3426. // get prepaid profile for that storage medium
  3427. PrepaidProfileI prepaidProfile = stMed.getPrepaidProfileI();
  3428.  
  3429. // if we get something, that means that this is a preactivated contract : return true
  3430. if (prepaidProfile != null)
  3431. {
  3432. retValue = true;
  3433. }
  3434. }
  3435. }
  3436.  
  3437. return retValue;
  3438. }
  3439. /**
  3440. * Returns true if this contract is a prepaid contract template.
  3441. * Creation date: (7/11/01 11:05:35 AM)
  3442. *
  3443. * @return boolean
  3444. * @author : Sergiu Burian
  3445. */
  3446.  
  3447. @Override
  3448. public boolean isPrepaidContractTemplateI()
  3449. {
  3450. if (this.isAgreementContract())
  3451. {
  3452. return false;
  3453. }
  3454. return "X".equals(_prepaidContractTemplate);
  3455.  
  3456. }
  3457. /**
  3458. * Check if the contract is a regular contract.
  3459. * Feature 84834 - Alternate Line.
  3460. *
  3461. * @author Renata Spencer
  3462. * @return boolean
  3463. */
  3464.  
  3465. @Override
  3466. public boolean isRegularContractI()
  3467. {
  3468. if (this.isAgreementContract())
  3469. {
  3470. return false;
  3471. }
  3472. return NullConversion.isNull(_relationType);
  3473.  
  3474. }
  3475. /**
  3476. * Check if the Contract is a VPN Administrator(subscriber) Contract
  3477. * This is for feature 53406
  3478. *
  3479. * @author E. Iglesias
  3480. * @return boolean
  3481. */
  3482. @Override
  3483. public boolean isVPNSubscriberContractI()
  3484. throws ComponentException, ValidationException
  3485. {
  3486.  
  3487. if (this.isAgreementContract())
  3488. {
  3489. return false;
  3490. }
  3491. // get the ContractedCompositeProduct
  3492. ContractedCompositeProduct ccp = getContractedCompositeProduct();
  3493.  
  3494. // get the Contracted ProductElements
  3495. Vector<ContractedProductElement> listPEs = ccp.getContractedProductElements();
  3496. if (!listPEs.isEmpty())
  3497. {
  3498. Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
  3499. while (iterPEs.hasNext())
  3500. {
  3501. // cycle through all ContractedProductElements
  3502. ContractedProductElement contractedPEI = iterPEs.next();
  3503.  
  3504. // if ContractedProductElement is VPN Administrator, the contract is VPN Subscriber Contract
  3505. NetworkServiceI vNetworkService = contractedPEI.getNetworkService();
  3506.  
  3507. if (vNetworkService != null && vNetworkService.isVPNAdministratorI())
  3508. {
  3509. return true;
  3510. }
  3511. }
  3512. }
  3513.  
  3514. return false;
  3515. }
  3516. /**
  3517. * Check if the Contract is a VPN User Contract
  3518. * This is for feature 53406
  3519. *
  3520. * @author E. Iglesias
  3521. * @return boolean
  3522. */
  3523. @Override
  3524. public boolean isVPNUserContractI()
  3525. throws ComponentException, ValidationException
  3526. {
  3527.  
  3528. if (this.isAgreementContract())
  3529. {
  3530. return false;
  3531. }
  3532.  
  3533. /**
  3534. * The only way to know if a contract is a VPN User Contract is check for
  3535. * the existence of one VPN Access Service
  3536. */
  3537.  
  3538. // get the ContractedCompositeProduct
  3539. ContractedCompositeProduct ccp = getContractedCompositeProduct();
  3540.  
  3541. // Cycle through all ContractedProductElements
  3542.  
  3543. Vector<ContractedProductElement> listPEs = ccp.getContractedProductElements();
  3544. if (!listPEs.isEmpty())
  3545. {
  3546. Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
  3547. while (iterPEs.hasNext())
  3548. {
  3549. ContractedProductElement contractedPE = iterPEs.next();
  3550.  
  3551. int state = contractedPE.getStateI();
  3552.  
  3553. if (state != ContractedProductElementI.Deactive)
  3554. {
  3555. // end 00227033 DAE
  3556. // if ContractedProductElement is VPN Access, the contract is VPN User Contract
  3557.  
  3558. NetworkServiceI vService = contractedPE.getNetworkService();
  3559. if (vService != null && vService.isVPNUserI())
  3560. {
  3561. return true;
  3562. }
  3563. }
  3564. }
  3565. }
  3566.  
  3567. return false;
  3568. }
  3569. /**
  3570. * postBuild. Initializes the CustomerContract
  3571. * This method overwrites the generic method of AbstractDomainObject and will
  3572. * always be called whenever a new CustomerContract is created!!!
  3573. */
  3574.  
  3575. @Override
  3576. public void postBuild() throws ComponentException
  3577. {
  3578. // next is called by Toplink:
  3579. /*
  3580. * Invoke the initialization of the ContractedCustomerProduct
  3581. */
  3582. initialize();
  3583.  
  3584. // from CustomerContract
  3585. /*
  3586. * Invoke the initialization of the Contract
  3587. */
  3588.  
  3589. /*
  3590. * Ensure that this is a new object
  3591. */
  3592. if (isNew())
  3593. {
  3594. /*
  3595. * if the contract was created and not loaded from database set creation date
  3596. */
  3597. _creationDate = ServerTime.getCurrentTime();
  3598. /*
  3599. * Create a new primary key an set the creation date
  3600. */
  3601. createUniqueId();
  3602.  
  3603. /*
  3604. * initialize signing date to system date
  3605. */
  3606. setSigningDateI(ServerTime.getCurrentDateAsInt());
  3607.  
  3608. /*
  3609. * set default value for contract extraction tag
  3610. */
  3611. setExtractionTag(Contract.DEFAULT_EXTRACTION_TAG);
  3612. }
  3613.  
  3614. }
  3615. /**
  3616. * postClone.
  3617. * This method is a hook and hopefully called from top link after cloning
  3618. * an instance.
  3619. */
  3620. @Override
  3621. public void postClone() throws ComponentException
  3622. {
  3623. /*
  3624. * Invoke the initialization of the ContractedCustomerProduct
  3625. */
  3626. initialize();
  3627.  
  3628. // from CustomerContract
  3629. /*
  3630. * create mediation instance to a task management system
  3631. */
  3632.  
  3633. if (_contractTaskHandler == null)
  3634. {
  3635. /*
  3636. * create ContractTaskHandler for registering action to the GMD, send at commit time to GMD
  3637. */
  3638. _contractTaskHandler = AbstractFactory.createObject(ContractTaskHandler.class);
  3639.  
  3640. /*
  3641. * set the backward reference to the contract
  3642. */
  3643. _contractTaskHandler.setContract(this);
  3644. }
  3645.  
  3646. /*
  3647. * initialize status if contract is newly created
  3648. * since we don't have a transaction context at initialisation time
  3649. * This code is really ugly, I know, and if somebody could tell how
  3650. * to do it better, I would really appreciate it!!!
  3651. * US 99-07-27
  3652. */
  3653. if (getOriginalObject().isNew())
  3654. {
  3655.  
  3656. /*
  3657. * create ContractStatus, status is set to "onhold" by its constructor!
  3658. */
  3659.  
  3660. ContractStatus vStatus = AbstractFactory.createObject(ContractStatus.class);
  3661. vStatus.setID(1L);
  3662. _currentStatus = vStatus;
  3663.  
  3664. /*
  3665. * add to list
  3666. */
  3667. Vector<ContractStatus> vContractStati = this.getContractStati();
  3668. vContractStati.add(vStatus);
  3669. this.setContractStati(vContractStati);
  3670.  
  3671. /*
  3672. * set back reference in ContractStatus.
  3673. * Status initialisation (state and reason) is done in the ContractStatus instance.
  3674. */
  3675. vStatus.setContract(this);
  3676. }
  3677.  
  3678. // --> defect 233846 NIJ
  3679. // - reset PROFILE_SERVICE lock object
  3680. _contractedProductElementsLock = null;
  3681. // <-- 233846
  3682.  
  3683. // feature 276491_cms
  3684. if (_concurrentRequestHandler == null)
  3685. {
  3686. /*
  3687. * create ConcurrentRequestHandler
  3688. */
  3689. _concurrentRequestHandler = AbstractFactory.createObject(ConcurrentRequestHandler.class);
  3690.  
  3691. /*
  3692. * set the backward reference to the contract
  3693. */
  3694. _concurrentRequestHandler.setContract(this);
  3695. // _concurrentRequestHandler.loadQueuedRequests();
  3696.  
  3697. }
  3698. }
  3699.  
  3700. /**
  3701. * Callback method for AbstractDomainObject. This mehtod is called after the method validateI is invoked for all updatable
  3702. * object in the commitphase of the transaction context. This method calls the TaskManagement/GMD for handling the provisioning
  3703. *
  3704. * @throws ComponentException
  3705. * @throws SystemException
  3706. */
  3707. @Override
  3708. public void postValidate() throws ComponentException
  3709. {
  3710. if (isCloneForUpdate())
  3711. {
  3712. /*
  3713. * initiate GMD action moved from prepareSave to this location. This method is only called at commit time!!!
  3714. */
  3715.  
  3716. /*
  3717. * generate tasks (if no actions are registered the method immediatly returns)
  3718. */
  3719. // disabled till TaskManagement is working! (US 99-08-31)
  3720.  
  3721. // --> defect 283814 NiJ
  3722. // - Because the cloned objects are beeing held in a HashSet in the framework, it happens randomly
  3723. // - that inside one transaction postValidate of CustomerContract is called before CustomerOrgNode.
  3724. // - Since there might be dependent actions (customer activation + contract activation) ensure that
  3725. // - customer request is generated first in order to be able to set the parent customer activation
  3726. // - request in the contract activation request.
  3727. if (_contractTaskHandler.areTaskRegistered())
  3728. {
  3729.  
  3730. // Check if a contract activation was registered
  3731. ActionDetailsI lContrActionDetailsI = _contractTaskHandler.getActionDetails(ContractSettings.CONTRACT_ACTIVATION);
  3732.  
  3733. if (lContrActionDetailsI == null)
  3734. {
  3735. lContrActionDetailsI = _contractTaskHandler.getActionDetails(TaskManagementSettings.CONTRACT_TAKEOVER_ACTIVATION);
  3736. }
  3737.  
  3738. if (lContrActionDetailsI != null)
  3739. {
  3740. // Check if a customer activation was registered (tasks not yet generated)
  3741. OrgNode lContrHolder = (OrgNode) getContractHolderI();
  3742. CustomerTaskHandler lContrHolderTaskHandler = lContrHolder.getCustomerTaskHandler();
  3743. if (lContrHolderTaskHandler.isCustomerActionRegistered(BusinessPartnerSettings.CUSTOMER_ACTIVATION))
  3744. {
  3745. // Make sure the customer tasks are generated
  3746. lContrHolderTaskHandler.generateTasks();
  3747. }
  3748.  
  3749. // Get generated customer tasks
  3750. List<TaskI> lContrHolderTasks = lContrHolderTaskHandler.getGeneratedTasks();
  3751. if (!lContrHolderTasks.isEmpty())
  3752. {
  3753. int lSize = lContrHolderTasks.size();
  3754. for (int i = 0; i < lSize; i++)
  3755. {
  3756. // Grab the customer activation task
  3757. TaskI lContrHolderTask = lContrHolderTasks.get(i);
  3758. if (lContrHolderTask.getActionIDI() == BusinessPartnerSettings.CUSTOMER_ACTIVATION)
  3759. {
  3760. long lParentRequestId = lContrHolderTask.getIDI();
  3761.  
  3762. // Set the parent request id (customer activation) in the contract activation request
  3763. lContrActionDetailsI.ParentRequest = lParentRequestId;
  3764. break;
  3765. }
  3766. }
  3767. }
  3768. }
  3769. }
  3770. // <-- 283814
  3771.  
  3772. // --> defect 229631-1 NIJ
  3773. // - check if there are any dependant contracts which tasks must be generated first
  3774. // _contractTaskHandler.generateTasks();
  3775. if (_dependentContract != null)
  3776. {
  3777. // generate tasks for dependent contracts first
  3778. _dependentContract.getContractTaskHandler().generateTasks();
  3779. }
  3780. _contractTaskHandler.generateTasks();
  3781. // <-- 229631-1
  3782.  
  3783. /*
  3784. * Ensure that the object has been modified or is a new object
  3785. */
  3786.  
  3787. if (getModified())
  3788. {
  3789. /*
  3790. * Set the modification date and the user
  3791. */
  3792. _modificationDate = ServerTime.getCurrentTime();
  3793. _userOfLastModification = ServiceContext.getCurrent().getUser().getUsername();
  3794. }
  3795.  
  3796. // defect 345307_cms/d
  3797. if (isNew())
  3798. {
  3799. ContractAdministrator administrator = ContractAdministrator.getInstance();
  3800. administrator.createContractCreationEventMessage(this);
  3801. }
  3802. // 345307_cms/d
  3803. }
  3804. }
  3805. /**
  3806. * refreshes this object along with the associated ContractedCompositeProduct-object
  3807. *
  3808. * @throws ComponentException
  3809. * if something fails
  3810. */
  3811.  
  3812. @Override
  3813. public void refreshObject() throws ComponentException
  3814. {
  3815. refreshObject(null);
  3816. }
  3817. /**
  3818. * Refreshes this object, but exclude the passed contract from refresh.
  3819. *
  3820. * @param pContractToSkip
  3821. * @throws ComponentException
  3822. */
  3823. protected void refreshObject(Contract pContractToSkip) throws ComponentException
  3824. {
  3825.  
  3826. // check if there is a pending contract request. If so after the contract refresh a refresh of the contract status have to
  3827. // be forced.
  3828. if (getPendingStatusI() != null)
  3829. {
  3830. super.refreshObject();
  3831.  
  3832. // 00339993: the following forces a refresh of the contract status, otherwise it might happen that the contract is
  3833. // refreshed, but the
  3834. // contract status is refreshed much later. But a contract status change might change REC_VERSION (see
  3835. // contract.finish_request), so
  3836. // refresh of CONTRACT_ALL and CONTRACT_HISTORY must happen together
  3837. if (getPendingStatusI() != null)
  3838. {
  3839. return;
  3840. }
  3841. }
  3842. else
  3843. {
  3844. super.refreshObject();
  3845. }
  3846.  
  3847. /*
  3848. * refresh the associated ContractedCompositeProduct-object
  3849. */
  3850. getContractedCompositeProductI().refreshObject();
  3851.  
  3852. /*
  3853. * We have to do a try if there are pending requests exspecially if the contract we are working on
  3854. * is in an alternate line scenario and there might be a refresh of the other contracts necessary
  3855. * If we are currently on an alternate line contract, we have to refresh the corresponding main contract and
  3856. * all its children except the contract we are currently on to avoid endless recursion.
  3857. */
  3858. if (isMainContractI())
  3859. {
  3860. if (getContractType().isSectionSubsectionUsed(GeneralContractSection.NAME, GeneralContractSection.CONTRACT_RELATION))
  3861. {
  3862. GeneralContractSection generalContractSection = this.getCompositeContractSection().getGeneralContractSection();
  3863.  
  3864. Vector<ContractI> relatedContracts = generalContractSection.getRelatedContracts();
  3865. Iterator<ContractI> iter = relatedContracts.iterator();
  3866. while (iter.hasNext())
  3867. {
  3868. Contract contract = (Contract) iter.next();
  3869. if (null != pContractToSkip)
  3870. {
  3871. if (pContractToSkip != contract)
  3872. {
  3873. contract.refreshObject(pContractToSkip);
  3874. }
  3875. }
  3876. else
  3877. {
  3878. contract.refreshObject(this);
  3879. }
  3880.  
  3881. }
  3882. }
  3883. }
  3884. else if (isALContractI() && null == pContractToSkip)
  3885. {
  3886. if (getContractType().isSectionSubsectionUsed(GeneralContractSection.NAME, GeneralContractSection.CONTRACT_RELATION))
  3887. {
  3888. GeneralContractSection generalContractSection = this.getCompositeContractSection().getGeneralContractSection();
  3889.  
  3890. Contract mainContr = (Contract) generalContractSection.getMainContract();
  3891. mainContr.refreshObject(this);
  3892. }
  3893. }
  3894.  
  3895. // refresh PAM schemes (377727_E08_U07)
  3896. refreshPamSchemes();
  3897. }
  3898.  
  3899. /**
  3900. * replaceDealerI. Replace the dealer, this contract is assigned to.
  3901. *
  3902. * @author Ulrich Schaefer
  3903. * @param pDealer
  3904. * com.lhs.BusinessPartner.bscs_core.external.DealerOrgNodeI
  3905. * @throws ValidationException
  3906. * @throws ComponentException
  3907. * @throws SystemException
  3908. */
  3909. @Override
  3910. public void replaceDealerI(DealerOrgNodeI pDealer, boolean pPropagateToResource)
  3911. throws ComponentException, ValidationException
  3912. {
  3913.  
  3914. /*
  3915. * replace dealer, further action (resource related) only needed if flag in parameters is set!
  3916. */
  3917. if (!this.isAgreementContract())
  3918. {
  3919. this.setDealer(pDealer);
  3920.  
  3921. if (pPropagateToResource)
  3922. {
  3923. /*
  3924. * propagate dealer change to resources
  3925. */
  3926. ChangeDealerVisitor vVisitor = new ChangeDealerVisitor(pDealer);
  3927. this.accept(vVisitor);
  3928. }
  3929. }
  3930. }
  3931. /**
  3932. * retrieveCurrentAndPendingStatus. Retrieves the current and the pending ContractStatus from the list of all contract stati.
  3933. *
  3934. * @throws SystemException
  3935. * @throws ComponentException
  3936. * @throws ValidationException
  3937. * @see com.lhs.Contract.bscs_core.ContractStatus
  3938. */
  3939.  
  3940. synchronized public void retrieveCurrentAndPendingStatus()
  3941. throws ComponentException, ValidationException
  3942. {
  3943.  
  3944. /*
  3945. * Check whether the retrieval is already done
  3946. */
  3947. if (_currentStatus == null)
  3948. {
  3949. ContractStatus currentStatus = null;
  3950. ContractStatus pendingStatus = null;
  3951. ContractStatus status;
  3952.  
  3953. {
  3954.  
  3955. /*
  3956. * Retrieve the list of all stati
  3957. */
  3958. Vector<ContractStatus> stati = getContractStati();
  3959.  
  3960. /*
  3961. * Check wether a current status exists
  3962. */
  3963. if (!stati.isEmpty())
  3964. {
  3965. /*
  3966. * Loop over all stati and look for the current one
  3967. */
  3968. Iterator<ContractStatus> iterator = stati.iterator();
  3969. while (iterator.hasNext())
  3970. {
  3971. ContractStatus tmpStatus = iterator.next();
  3972.  
  3973. /*
  3974. * Check wether it is a pending status
  3975. */
  3976. if (tmpStatus.isPendingI())
  3977. {
  3978. status = pendingStatus;
  3979. }
  3980. else
  3981. {
  3982. status = currentStatus;
  3983. }
  3984.  
  3985. /*
  3986. * Check whether the current/pending status is already set
  3987. */
  3988. if (status != null)
  3989. {
  3990. /*
  3991. * Compare the seqNo of both stati and select the one
  3992. * with the higher seqNo
  3993. */
  3994. if (tmpStatus.getIDI() > status.getIDI())
  3995. {
  3996. status = tmpStatus;
  3997. }
  3998. }
  3999. /*
  4000. * Otherwise just assign the status to the current status
  4001. */
  4002. else
  4003. {
  4004. status = tmpStatus;
  4005. }
  4006.  
  4007. /*
  4008. * Check whether it is a pending status and assign status
  4009. */
  4010. if (tmpStatus.isPendingI())
  4011. {
  4012. pendingStatus = status;
  4013. }
  4014. else
  4015. {
  4016. currentStatus = status;
  4017. }
  4018. }
  4019.  
  4020. /*
  4021. * Assign the temporary current/pending status to the class attribute
  4022. */
  4023. if (currentStatus != null)
  4024. {
  4025. _currentStatus = currentStatus;
  4026. }
  4027. if (pendingStatus != null)
  4028. {
  4029. _pendingStatus = pendingStatus;
  4030. }
  4031.  
  4032. /*
  4033. * Check whether at least a current status has been detected
  4034. */
  4035. if (_currentStatus == null)
  4036. {
  4037. throw new ComponentException("Contract.MissingStatus", new Object[]{Long.valueOf(getIDI())});
  4038. }
  4039. }
  4040. else
  4041. {
  4042. throw new ComponentException("Contract.MissingStatus", new Object[]{Long.valueOf(getIDI())});
  4043. }
  4044.  
  4045. }
  4046. }
  4047. }
  4048.  
  4049. /**
  4050. * setConfirmationGenerated. Sets whether the confirmation document has been generated
  4051. *
  4052. * @param pValue
  4053. */
  4054.  
  4055. public void setConfirmationGenerated(boolean pValue)
  4056. {
  4057. if (pValue)
  4058. {
  4059. _confirmationGenerated = "X";
  4060. }
  4061. else
  4062. {
  4063. _confirmationGenerated = NullConversion.STRING_NULL_VALUE;
  4064. }
  4065. }
  4066. /**
  4067. * setFirstContractHolder. Stores the reference of the OrgNode, the contract is assigned to.
  4068. *
  4069. * @param pOrgNode
  4070. * com.lhs.BusinessPartner.bscs_core.external.OrgNodeI
  4071. * @throws ComponentException
  4072. * @throws ComponentException
  4073. */
  4074.  
  4075. public void setFirstContractHolder(OrgNodeI pOrgNode) throws ComponentException
  4076. {
  4077. /*
  4078. * Store the passed OrgNode
  4079. */
  4080. FWValueHolder.setValue(_firstContractHolder, pOrgNode, this);
  4081.  
  4082. }
  4083. /**
  4084. * setContractHolder. Stores the reference of the OrgNode, the contract is assigned to.
  4085. *
  4086. * @param pOrgNode
  4087. * com.lhs.BusinessPartner.bscs_core.external.OrgNodeI
  4088. * @throws ComponentException
  4089. */
  4090.  
  4091. public void setContractHolder(OrgNodeI pOrgNode)
  4092. throws ComponentException
  4093. {
  4094. /*
  4095. * Store the passed OrgNode
  4096. */
  4097. FWValueHolder.setValue(_contractHolder, pOrgNode, this);
  4098.  
  4099. }
  4100. /**
  4101. * This method was created in VisualAge.
  4102. *
  4103. * @param pStati
  4104. * Vector
  4105. * @throws ComponentException
  4106. */
  4107. public void setContractStati(List<ContractStatus> pStati)
  4108. throws ComponentException
  4109. {
  4110. /*
  4111. * Store the passed list of contract stati
  4112. */
  4113. FWValueHolder.setValue(_contractStati, pStati, this);
  4114. }
  4115.  
  4116. /**
  4117. * setExternalContractReferenceNoI. Set the external identifier for this contract.
  4118. *
  4119. * @param pExternalContractReferenceNo
  4120. */
  4121.  
  4122. @Override
  4123. public void setExternalContractReferenceNoI(String pExternalContractReferenceNo)
  4124. {
  4125. if (!this.isAgreementContract())
  4126. {
  4127. _externalContractReferenceNo = pExternalContractReferenceNo;
  4128. }
  4129. }
  4130.  
  4131. /**
  4132. * setIdOfContractRepresentativeI. Set the id of the contract representative
  4133. *
  4134. * @param pIdOfContractRepresentative
  4135. */
  4136.  
  4137. @Override
  4138. public void setIdOfContractRepresentativeI(String pIdOfContractRepresentative)
  4139. {
  4140. if (!this.isAgreementContract())
  4141. {
  4142. _idOfContractRepresentative = pIdOfContractRepresentative;
  4143. }
  4144. }
  4145.  
  4146. /**
  4147. * Set the current status of the contract.
  4148. *
  4149. * @author Renata Spencer
  4150. * @param pStatus
  4151. * ContractStatusI
  4152. */
  4153.  
  4154. public void setCurrentStatus(ContractStatus pStatus)
  4155. {
  4156. _currentStatus = pStatus;
  4157. }
  4158.  
  4159. /**
  4160. * setNameOfContractRepresentativeI. Set the name of the contract representative
  4161. *
  4162. * @param pNameOfContractRepresentative
  4163. */
  4164.  
  4165. @Override
  4166. public void setNameOfContractRepresentativeI(String pNameOfContractRepresentative)
  4167. {
  4168. if (!this.isAgreementContract())
  4169. {
  4170. _nameOfContractRepresentative = pNameOfContractRepresentative;
  4171. }
  4172. }
  4173. /**
  4174. * setNotValidated. Sets whether the contract is validated
  4175. *
  4176. * @param pValue
  4177. * @throws ComponentException
  4178. * @throws SystemException
  4179. * @throws ValidationException
  4180. */
  4181.  
  4182. public void setNotValidatedI(boolean pValue) throws ComponentException, ValidationException
  4183. {
  4184. /*
  4185. * only an onhold contract can be set to 'not validated'
  4186. */
  4187. if (pValue)
  4188. {
  4189.  
  4190. if (getCurrentStatusI().getStateI() == ContractStatusI.Onhold || getCurrentStatusI().getStateI() == ContractStatusI.Deactive)
  4191. {
  4192. _notValidated = "X";
  4193. }
  4194. else
  4195. {
  4196. throw new ValidationException("Contract.ContractStatusOnholdRequired");
  4197. }
  4198. }
  4199. else
  4200. {
  4201. _notValidated = NullConversion.STRING_NULL_VALUE;
  4202. }
  4203. }
  4204. /**
  4205. * Sets this contract as (not) a prepaid contract template - feat. 202820_3. depending on the input boolean parameter. Creation
  4206. * date: (7/12/01 8:33:56 AM)
  4207. *
  4208. * @author Sergiu Burian
  4209. * @param vFlag
  4210. */
  4211.  
  4212. public void setPrepaidContractTemplate(boolean vFlag)
  4213.  
  4214. {
  4215. if (vFlag)
  4216. {
  4217. _prepaidContractTemplate = "X";
  4218. }
  4219. else
  4220. {
  4221. _prepaidContractTemplate = NullConversion.STRING_NULL_VALUE;
  4222. }
  4223. }
  4224. /**
  4225. * Sets the type of the contract regarding AL:
  4226. * M' - Main contract, 'R' - Related contract, null - regular contract
  4227. * Feature 84834 - Alternate Line.
  4228. *
  4229. * @author Renata Spencer
  4230. * @param pRelationType
  4231. * a String
  4232. */
  4233.  
  4234. public void setRelationType(String pRelationType)
  4235.  
  4236. {
  4237. _relationType = pRelationType;
  4238.  
  4239. }
  4240. /**
  4241. * Sets whether the contract has a service assigned
  4242. *
  4243. * @param pValue
  4244. */
  4245.  
  4246. public void setServicesAssigned(boolean pValue)
  4247. {
  4248. if (pValue)
  4249. {
  4250. _servicesAssigned = "Y";
  4251. }
  4252. else
  4253. {
  4254. _servicesAssigned = NullConversion.STRING_NULL_VALUE;
  4255. }
  4256. }
  4257.  
  4258. /**
  4259. * This method should be called at commit time, this instance has to be a clone!. If the contract is an AL contract, it should
  4260. * belong to the same technology and to the same dealer or service provider of the main contract
  4261. *
  4262. * @return boolean
  4263. * @throws ValidationException
  4264. * @throws ComponentException
  4265. */
  4266. public boolean validateALContract() throws ComponentException, ValidationException
  4267. {
  4268. boolean isValid = true;
  4269. /*
  4270. * only validate if data was changed and if is an AL contract
  4271. */
  4272. if (isALContractI() && getModified())
  4273. {
  4274. /*
  4275. * check whether the technology is the same as in the main contract
  4276. */
  4277. if (!getContractedCompositeProductI().getTechnologyI().equals(
  4278. this.getCompositeContractSection().getGeneralContractSection().getMainContract().getContractedCompositeProductI().getTechnologyI()))
  4279. {
  4280. Contract cContr = (Contract) this.getCompositeContractSection().getGeneralContractSection().getMainContract();
  4281. throw new ValidationException("Contract.InvalidMainContract", Long.valueOf(cContr.getIDI()), cContr.getPublicKey());
  4282. }
  4283.  
  4284. /*
  4285. * check whether the dealer is the same as in the main contract
  4286. */
  4287. OrgNodeI dealer = this.getDealer();
  4288. if (dealer != null && !dealer.equals(((Contract) this.getCompositeContractSection().getGeneralContractSection().getMainContract()).getDealer()))
  4289. {
  4290. Contract cContr = (Contract) this.getCompositeContractSection().getGeneralContractSection().getMainContract();
  4291. throw new ValidationException("Contract.InvalidMainContract", Long.valueOf(cContr.getIDI()), cContr.getPublicKey());
  4292. }
  4293.  
  4294. }
  4295.  
  4296. return isValid;
  4297. }
  4298. /**
  4299. * validateContract. This method should be called at commit time, this instance has to be a clone!. The contract is checked
  4300. * against the rule depending on the Technology and the TechnologyFlavour.
  4301. *
  4302. * @return boolean
  4303. * @throws ValidationException
  4304. * @throws ComponentException
  4305. * @throws SystemException
  4306. */
  4307. public boolean validateContract()
  4308. throws ComponentException, ValidationException
  4309. {
  4310. /*
  4311. * only validate if data was changed
  4312. */
  4313. if (isCloneForUpdate())
  4314. {
  4315. /*
  4316. * check if validation should be performed
  4317. */
  4318. if (!isNotValidatedI() && !isTakeoverContract())
  4319. {
  4320.  
  4321. /*
  4322. * replace "VALIDATEONCOMMIT" with Metaapplication string constant
  4323. */
  4324. /*
  4325. * only check if status is not deactive
  4326. */
  4327. if (getCurrentStatusI().getStateI() != ContractStatusI.Deactive)
  4328. {
  4329. // 236082 removed if (this.isCustomerContract())
  4330. checkConsistency();
  4331. /*
  4332. * 236082_cms removed else if (this.isAgreementContract())
  4333. * this.checkConsistency("VALIDATECUSTOMERCONTRACT");
  4334. */
  4335.  
  4336. List<ContractedDNPropertiesI> list = getActiveDNProperties();
  4337. Iterator<ContractedDNPropertiesI> iter = list.iterator();
  4338. while (iter.hasNext())
  4339. {
  4340. ContractedDNProperties dnProperties = (ContractedDNProperties) iter.next();
  4341. if (dnProperties.getDirectoryNumberI() instanceof PhoneNumber)
  4342. {
  4343. PortingRequest portingRequest = dnProperties.getPortingRequest();
  4344. if (portingRequest != null)
  4345. {
  4346. PhoneNumber number = (PhoneNumber) dnProperties.getDirectoryNumberI();
  4347.  
  4348. if (portingRequest.getStatus().getStateI() == PortingRequestStatus.Faild
  4349. || portingRequest.getStatus().getStateI() == PortingRequestStatus.Cancelled)
  4350. {
  4351. if (PortingAction.PORTING_IN.equals(((PortingAction) portingRequest.getRequestActionI())
  4352. .getRequestActionShortDescr()))
  4353. {
  4354. throw new ValidationException("CMS.TaskManagement.NumberIsNotAllowedToBeUsed", number.getNumberI());
  4355. }
  4356. }
  4357. }
  4358. }
  4359. }
  4360. }
  4361. else
  4362. {
  4363. ContractedCompositeProduct lCCP = getContractedCompositeProduct();
  4364. // get list of ContractedSimpleProduct's assigned to contract
  4365. Vector<ContractedProductElement> lCPEList = lCCP.getContractedProductElements();
  4366. if (!lCPEList.isEmpty())
  4367. {
  4368. // loop through the ContractedProductElement's, get each active ContractedDNProperties and store it
  4369. Iterator<ContractedProductElement> lIterCPE = lCPEList.iterator();
  4370. while (lIterCPE.hasNext())
  4371. {
  4372. ContractedProductElement lCPE = lIterCPE.next();
  4373. Vector<ContractedDNProperties> contrDNProps = lCPE.getContractedDNProperties();
  4374.  
  4375. if (!contrDNProps.isEmpty())
  4376. {
  4377. // loop through the ContractedProductElement's
  4378. Iterator<ContractedDNProperties> lIterator = contrDNProps.iterator();
  4379. while (lIterator.hasNext())
  4380. {
  4381. ContractedDNProperties dnProperties = lIterator.next();
  4382. if (dnProperties.getDirectoryNumberI() instanceof PhoneNumber)
  4383. {
  4384. PhoneNumberPortingInformation info = ((PhoneNumber) dnProperties.getDirectoryNumberI()).getPortingInformation();
  4385. if (info != null)
  4386. {
  4387. PortingRequest portingRequest = (PortingRequest) info.getPortingRequest();
  4388. if (portingRequest != null)
  4389. {
  4390. if (PortingAction.PORTING_OUT.equals(((PortingAction) portingRequest
  4391. .getRequestActionI()).getRequestActionShortDescr()))
  4392. {
  4393. return true;
  4394. }
  4395. }
  4396. }
  4397. }
  4398.  
  4399. }
  4400. }
  4401. }
  4402. }
  4403.  
  4404. // allow modifications for such deactive contracts, that are not deactivated via GMD chain, but immediatly set
  4405. // to deactive.
  4406. // If later in a following transaction such a contract is going to be changed, the change is rejected!
  4407. if (getModified() && !getCurrentStatusI().isNew())
  4408. {
  4409. throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.ModificationOfDeactiveContractNotAllowed");
  4410. }
  4411. }
  4412.  
  4413. /*
  4414. * In future the check will return a generic result set, which provides information about the rules which have
  4415. * failed
  4416. * So far it is returned false to be safe
  4417. */
  4418.  
  4419. /*
  4420. * check the return value
  4421. */
  4422.  
  4423. }
  4424. }
  4425. return true;
  4426. }
  4427.  
  4428. /**
  4429. * Checkes whether the re-rating flag is changed.
  4430. *
  4431. * @return true, if changed; otherwise false
  4432. * @throws ComponentException
  4433. */
  4434. protected boolean isReratingFlagChanged() throws ComponentException
  4435. {
  4436. return ((Contract) getOriginalObject())._isReratingCandidate != _isReratingCandidate;
  4437. }
  4438. // end 288320, Re-rating, MCH 30.06.2008
  4439.  
  4440. /**
  4441. * This method should be called at commit time. It checks, whether the contract type requires special billing accounts. The
  4442. * functionality is called when a contract is activated.
  4443. *
  4444. * @return true if the billing account validation was successfull.
  4445. * @throws ValidationException
  4446. * @throws ComponentException
  4447. */
  4448. public boolean validateBillingAccounts() throws ComponentException, ValidationException
  4449. {
  4450. // only when a activation is performed.
  4451. if (getPendingStatusI() != null && getPendingStatusI().getStateI() == ContractStatusI.Active)
  4452. {
  4453. ContractType contractType = getContractType();
  4454. BillingAdministratorI billAdmin = AdministratorFactory.getInstance().getBillingAdministrator(); // PN 314351, MCH
  4455. // 07.10.2008,
  4456. // refactoring
  4457. OrgNode contractHolder = (OrgNode) getContractHolderI();
  4458. List<BillingAccount> billAccList = billAdmin.getOwnedBillingAccounts(contractHolder);
  4459. if (!contractHolder.isPaymentResponsibleI())
  4460. {
  4461. billAccList = billAdmin.getOwnedBillingAccounts(contractHolder.getPaymentResponsibleI());
  4462. }
  4463.  
  4464. Iterator<BillingAccount> billAccIter = billAccList.iterator();
  4465. boolean hasInvoiceBA = false;
  4466. boolean hasReconBA = false;
  4467. boolean hasCreditMemoBA = false;
  4468. while (billAccIter.hasNext())
  4469. {
  4470. BillingAccount billAcc = billAccIter.next();
  4471. if (billAcc.getInvoiceIndicatorI() == BillingAccountI.IndicatorInvoicing)
  4472. {
  4473. hasInvoiceBA = true;
  4474. }
  4475. if (billAcc.getInvoiceIndicatorI() == BillingAccountI.IndicatorReconciliation)
  4476. {
  4477. hasReconBA = true;
  4478. }
  4479. // 254176_cms
  4480. if (billAcc.getInvoiceIndicatorI() == BillingAccountI.IndicatorCreditMemo)
  4481. {
  4482. hasCreditMemoBA = true;
  4483. }
  4484. }
  4485. // In case a contract type is billing relevant there must be invoice billing account
  4486. boolean isLALeaf = contractHolder.isLeafI() && contractHolder.getParentI() != null;
  4487. // preactivated contracts assigned to a operator are billing relevant, but the operator doesn't have invoice BA,
  4488. // therefore they are excluded from the check
  4489. if (contractType.isBillingRelevant() && !hasInvoiceBA && !isLALeaf && !contractHolder.isHomeOperator())
  4490. {
  4491. throw new ValidationException("Billing.BillingAccount.WrongForContractType", getPublicKey());
  4492. }
  4493. // 254176_cms
  4494. // In case a contract type is reconciliation and credit memo relevant then one reconciliation billing account
  4495. // or one credit memo billing account is sufficient.
  4496. // If a contract type is reconciliation relevant and not credit memo relevant, then there must be a reconciliation
  4497. // billing account. Analog if a contract type is credit memo relevant and not reconciliation relevant, then there
  4498. // must be credit memo billing account
  4499. if (!contractType.isCreditMemoRelevant() && contractType.isReconciliationRelevant() && !hasReconBA)
  4500. {
  4501. throw new ValidationException("Billing.BillingAccount.WrongForContractType", getPublicKey());
  4502. }
  4503. if (!contractType.isReconciliationRelevant() && contractType.isCreditMemoRelevant() && !hasCreditMemoBA)
  4504. {
  4505. throw new ValidationException("Billing.BillingAccount.WrongForContractType", getPublicKey());
  4506. }
  4507. }
  4508. return true;
  4509. }
  4510.  
  4511. /**
  4512. * This method should be called at commit time. This method checks if rate plan, alternate rate plan and prepaid profile
  4513. * assigned to the contract are valid for the business unit of th econtract.
  4514. *
  4515. * @return true if the business unit validation was successfull.
  4516. * @throws ValidationException
  4517. * @throws ComponentException
  4518. */
  4519. public boolean validateBusinessUnit()
  4520. throws ComponentException, ValidationException
  4521. {
  4522. if (getCurrentStatusI().getStateI() == ContractStatusI.Deactive)
  4523. {
  4524. return true;
  4525. }
  4526.  
  4527. boolean isValid = true;
  4528. // change of business unit
  4529. if (!isNew() && ((Contract) this.getOriginalObject()).getBusinessUnitId() != getBusinessUnitId())
  4530. {
  4531. if (getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.CONTRACTED_COMPOSITE_PRODUCT))
  4532. {
  4533. // check for the contracted product
  4534. ContractedCompositeProduct contrCompProduct = getContractedCompositeProduct();
  4535. // 00258863 in case a product change was done in the same transaction as the business unit change
  4536. // then check the pending rate plan instead of the current rate plan
  4537. CompositeProductI pendingComProd = contrCompProduct.getPendingCompositeProductI();
  4538. CompositeProductTemplate compProdTemp;
  4539. if (pendingComProd != null)
  4540. {
  4541. compProdTemp = (CompositeProductTemplate) pendingComProd.getCompositeProductTemplateI();
  4542. }
  4543. else
  4544. {
  4545. compProdTemp = (CompositeProductTemplate) contrCompProduct.getCompositeProductI().getCompositeProductTemplateI();
  4546. }
  4547. if (compProdTemp != null)
  4548. {
  4549. if (!compProdTemp.isAssignedToBusinessUnit(getBusinessUnitId()))
  4550. {
  4551. throw new ValidationException("CMS.Contract.WrongBuUnit",
  4552. "CompositeProduct (RP_CODE)", Long.valueOf(compProdTemp.getIDI()), Long.valueOf(getBusinessUnitId()));
  4553. }
  4554. }
  4555. if (getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.ALTERNATE_TARIFF))
  4556. {
  4557. // check the alternate rate plan
  4558. PricingSchemeI psi = contrCompProduct.getPricingSchemeI(PricingSchemeRoleI.AlternativPricingScheme);
  4559. if (psi != null)
  4560. {
  4561. ProductI product = psi.getProductI();
  4562. if (product != null)
  4563. {
  4564. compProdTemp = (CompositeProductTemplate) ((CompositeProductI) product).getCompositeProductTemplateI();
  4565. if (compProdTemp != null)
  4566. {
  4567. if (!compProdTemp.isAssignedToBusinessUnit(getBusinessUnitId()))
  4568. {
  4569. throw new ValidationException("CMS.Contract.WrongBuUnit",
  4570. "Alternate CompositeProduct (ALT_RPCODE)", Long.valueOf(compProdTemp.getIDI()), Long.valueOf(getBusinessUnitId()));
  4571. }
  4572. }
  4573. }
  4574. }
  4575. }
  4576. }
  4577. if (!NullConversion.isNull(getBillMediumId()))
  4578. {
  4579. // bill medium has changed, check whether this is the right one
  4580. BillMedium lBillMedium = BillMedium.getBillMediumById(getBillMediumId());
  4581. if (!lBillMedium.isAssignedToBusinessUnit(getBusinessUnitId()))
  4582. {
  4583. throw new ComponentException("CMS.BillingAccount.BillMediumNotValidForBU", Long.valueOf(lBillMedium.getIDI()),
  4584. lBillMedium.getShortDescription(), Long.valueOf(getBusinessUnitId()), BusinessUnit.getBusinessUnitById(getBusinessUnitId()));
  4585. }
  4586. }
  4587. }
  4588. // begin 236082_cms
  4589. // check whether a parent contract and its child contracts have the same business unit assigned
  4590. CompositeContractSection compConSection = getCompositeContractSection();
  4591. GeneralContractSection genConSection = compConSection.getGeneralContractSection();
  4592. ContractType contractType = this.getContractType();
  4593. ContractSectionType sectionType = contractType.getContractSectionTypeByName("General Contract Section");
  4594. if (sectionType != null)
  4595. {
  4596. List<ContractI> childList = genConSection.getRelatedContracts();
  4597. if (childList != null)
  4598. {
  4599. Iterator<ContractI> childIter = childList.iterator();
  4600. Contract childContract;
  4601. while (childIter.hasNext())
  4602. {
  4603. childContract = (Contract) childIter.next();
  4604. if (childContract.getBusinessUnitId() != getBusinessUnitId())
  4605. {
  4606. throw new ValidationException("CMS.Contract.RelatedContracts.DifferentBusinessUnits", getPublicKey(), childContract.getPublicKey());
  4607. }
  4608. }
  4609. }
  4610. // Check whether the business unit of the second contract holder is the same as the business unit of the contract.
  4611. // If the second contract holder is the home operator then the contract may have assigned a different
  4612. // business unit because the home operator is always assigned to the default business unit and in case of
  4613. // a multi company setup the default business unit cannot be assigned to a contract.
  4614. OrgNode secondContractHolder = (OrgNode) getContractHolderI();
  4615. // second contract holder is not the home operator
  4616. if (!"O".equals(secondContractHolder.getPartyType()))
  4617. {
  4618. if (getBusinessUnitId() != secondContractHolder.getBusinessUnitId())
  4619. {
  4620. throw new ValidationException("CMS.Contract.SecondContractHolder.DifferentBusinessUnits", getPublicKey(),
  4621. secondContractHolder.getPublicKey());
  4622. }
  4623. }
  4624. }
  4625. // end 236082_cms
  4626. return isValid;
  4627. }
  4628.  
  4629. // begin 236082_cms
  4630.  
  4631. /**
  4632. * checks that no balances are shared among business partner contracts
  4633. *
  4634. * @return true if validation successful
  4635. * @throws ComponentException
  4636. * @throws ValidationException
  4637. * validation
  4638. */
  4639. public boolean validateBalances() throws ComponentException, ValidationException
  4640. {
  4641. OrgNodeI secondContractHolder = getContractHolderI();
  4642. if (secondContractHolder.isBusinessPartner())
  4643. {
  4644. String[] targetCoIds = getTargetContracts();
  4645. if (targetCoIds.length > 0)
  4646. {
  4647. throw new ValidationException("CMS.Contract.BalanaceSharingNotAllowedForBusinessPartnerContracts", getPublicKey());
  4648. }
  4649. }
  4650. return true;
  4651. }
  4652. // end 236082_cms
  4653.  
  4654. /**
  4655. * validateContractHolder. This method should be called at commit time, this instance has to be a clone, if it should be
  4656. * validated!. The contract holder is checked, that means if the holder is active.
  4657. *
  4658. * @return boolean
  4659. * @throws ValidationException
  4660. * @throws ComponentException
  4661. * @throws SystemException
  4662. */
  4663. public boolean validateContractHolder() throws ComponentException, ValidationException
  4664. {
  4665. // From CustomerContract:
  4666. boolean isValid = true;
  4667. if (isCloneForUpdate())
  4668. {
  4669. /*
  4670. * check whether customer assigned to this contract is mandatory
  4671. */
  4672. OrgNodeI vContractHolder = getContractHolderI();
  4673.  
  4674. if (vContractHolder == null)
  4675. {
  4676. throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.MissingContractHolder");
  4677. }
  4678.  
  4679. CustomerOrgNodeI vCustomer = (CustomerOrgNodeI) vContractHolder;
  4680.  
  4681. if (this.isCustomerContract())
  4682. {
  4683.  
  4684. // prepaid templates are assignable only to dummy customers
  4685. if (isPrepaidContractTemplateI())
  4686. {
  4687. // check if the contract holder is a dummy customer
  4688. if (!vCustomer.isDummyCustomerI())
  4689. {
  4690. throw new ValidationException("CMS.Contract.DummyCustomerRequiredForTemplate");
  4691. }
  4692. }
  4693. }
  4694.  
  4695. }
  4696. return isValid;
  4697. }
  4698.  
  4699. // --> defect 233846
  4700. /**
  4701. * Create a database lock on PROFILE_SERVICE table
  4702. *
  4703. * @throws ComponentException
  4704. * @throws ValidationException
  4705. */
  4706. public void createContractedProductElementsLock()
  4707. throws ComponentException, ValidationException
  4708. {
  4709. // do only 1 time and only for large accounts contracts
  4710. if (_contractedProductElementsLock == null && (isLevelContractI() || getContractHolderI().hasParentI()))
  4711. {
  4712.  
  4713. // - In case in the MAD the pesimistic locking of PROFILE_SERVICE is turned on
  4714. // - create the DatabaseLock object so the SELECT..FOR UPDATE NOWAIT is executed
  4715. // - on commit time before the updates on PROFILE_SERVICE are performed.
  4716. // - This way the CMS wont stop and wait in case of existing locks on that table
  4717. // - but will throw an exception.
  4718.  
  4719. boolean lockPROFILE_SERVICE = ContractSettings.LOCK_PROFILE_SERVICE_FORUPDATE;
  4720.  
  4721. if (lockPROFILE_SERVICE)
  4722. {
  4723. // create the database lock object
  4724. _contractedProductElementsLock =
  4725. AbstractFactory.createObject(ContractedProductElementLock.class);
  4726.  
  4727. // initialize the database object in order to pessimistic lock the PROFILE_SERVICE table on commit time
  4728. _contractedProductElementsLock.setCoId(Long.toString(getIDI()));
  4729. }
  4730. }
  4731. }
  4732. // <-- 233846
  4733.  
  4734. /**
  4735. * This method checks for pending balance adjustment requests.
  4736. * A request is pending if CRH_REQUEST.STATUS is 2 (Inserted)
  4737. * or 4 (In progress).
  4738. * Only for BSCS 7.01 and later!!!
  4739. *
  4740. * @return boolean
  4741. * @throws ComponentException
  4742. * @throws SystemException
  4743. * @throws ValidationException
  4744. */
  4745. public boolean hasPendingBARequest()
  4746. throws ComponentException
  4747. {
  4748.  
  4749. long lContractId = getIDI();
  4750.  
  4751. ExpressionBuilder lExpressionBuilder = new ExpressionBuilder();
  4752. Expression lExpression = lExpressionBuilder.get("_contract").get("_id").equal(lContractId);
  4753. long lStatus[] = {2, 4}; // 2: Inserted, 4: In progress
  4754. lExpression = lExpression.and(lExpressionBuilder.get("_status").in(lStatus));
  4755. Vector<?> lCommonRequestListI = AbstractFactory.readQueryObjects(com.lhs.TaskManagement.bscs_core.CommonRequest.class, lExpression);
  4756. if (!lCommonRequestListI.isEmpty())
  4757. {
  4758. return true;
  4759. }
  4760.  
  4761. return false;
  4762. }
  4763.  
  4764. /**
  4765. * @return The method returns true if the contract belongs to the IN platform.
  4766. * This can happen if at least one contracted service is marked as prepaid and/or
  4767. * if the Non-explicit services payment type from CONTR_TARIFF_OPTIONS is set as
  4768. * "pRepaid" or "as Defined in rateplan".
  4769. * @throws ComponentException
  4770. * @throws ValidationException
  4771. * @throws SystemException
  4772. */
  4773. public boolean isINContract()
  4774. throws ComponentException, ValidationException
  4775. {
  4776. if (!getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.CONTRACTED_COMPOSITE_PRODUCT))
  4777. {
  4778. return false;
  4779. }
  4780. int contractState = getCurrentStatusI().getStateI();
  4781. /*
  4782. * Check the non-explicit services payment type
  4783. */
  4784.  
  4785. /*
  4786. * Get the contracted composite product
  4787. */
  4788. ContractedCompositeProduct contractedCompositeProd = getContractedCompositeProduct();
  4789.  
  4790. String nonExplPaymType = contractedCompositeProd.getNonexplServPaymentType();
  4791. // 00259948 if (!(nonExplPaymType.equals(ContractInterOperatorTariffHistory.PAYMENT_TYPE_POSTPAID)))
  4792. if (ContractInterOperatorTariffHistory.PAYMENT_TYPE_PREPAID.equals(nonExplPaymType))
  4793. {
  4794. /*
  4795. * OK. That's enough to recognize that the contract is in IN
  4796. */
  4797. return true;
  4798. }
  4799.  
  4800. Vector<ContractedProductElement> listPEs = contractedCompositeProd.getContractedProductElements();
  4801. if (!listPEs.isEmpty())
  4802. {
  4803. Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
  4804. while (iterPEs.hasNext())
  4805. {
  4806. ContractedProductElementI contractedPEI = iterPEs.next();
  4807. if (contractedPEI.isPrepaidI())
  4808. {
  4809.  
  4810. if (contractState == ContractStatusI.Onhold)
  4811. {
  4812. /*
  4813. * in case of on-hold contracts, we do not care about the service status
  4814. */
  4815. return true;
  4816. }
  4817.  
  4818. int lContractServiceState = contractedPEI.getStateI();
  4819. if (lContractServiceState != ContractedProductElementI.Onhold &&
  4820. lContractServiceState != ContractedProductElementI.Deactive)
  4821. {
  4822. /*
  4823. * At least one prepaid contracted service found.
  4824. * This can happen only if this is an IN contract.
  4825. */
  4826. return true;
  4827. }
  4828. }
  4829. } // iterate through contracted product elements
  4830. }
  4831.  
  4832. /*
  4833. * #TODO Iterate through AL contracts if case.
  4834. */
  4835.  
  4836. /*
  4837. * if we got here, this is no IN contract
  4838. */
  4839. return false;
  4840. }
  4841.  
  4842. /**
  4843. * The method returns all balances monitoring the current contract.
  4844. * The return list is filled with ContractedProductElement objects.
  4845. * It can be called for all balances or only for the Money Wallets.
  4846. *
  4847. * @author Sergiu BURIAN
  4848. * PN 246410
  4849. * @param pMoneyWalletsOnly
  4850. * @param pContractOnly
  4851. * @param pGetMode
  4852. * @return The monitored balance.
  4853. * @throws ValidationException
  4854. * @throws ComponentException
  4855. * @throws SystemException
  4856. */
  4857.  
  4858. public List<ContractedProductElement> getMonitoringBalances(boolean pMoneyWalletsOnly, boolean pContractOnly, int pGetMode)
  4859. throws ComponentException, ValidationException
  4860. {
  4861. ArrayList<ContractedProductElement> lBalList = new ArrayList<ContractedProductElement>();
  4862.  
  4863. List<ContractI> lContracts = null;
  4864.  
  4865. if (!pContractOnly)
  4866. {
  4867. /*
  4868. * The "monitoring" relations work only within contracts
  4869. * that belong to customers that belong to the same family.
  4870. * So far, a family can have only one member.
  4871. * !!! This will change in RBP !!!
  4872. */
  4873.  
  4874. OrgNodeI lCustomer = getContractHolderI();
  4875. // check is only executed for non service provider and contract not belonging to the
  4876. // network operator. Contribution list shouldn't be set anyway.
  4877. // Caution: this check prevents the getContractsI() for service provider and home operators, which
  4878. // would result in a huge result set.
  4879. if (lCustomer.isResellerI() || lCustomer.isHomeOperator())
  4880. {
  4881. lContracts = new ArrayList<ContractI>(1);
  4882. lContracts.add(this);
  4883. }
  4884. else
  4885. {
  4886. /*
  4887. * The "monitoring" relations work only within contracts
  4888. * that belong to customers that belong to the same family.
  4889. * So far, a family can have only one member.
  4890. */
  4891.  
  4892. lContracts = ContractAdministrator.getInstance().getMonitoringRelevantContract(lCustomer);
  4893. if (lContracts.isEmpty())
  4894. {
  4895. lContracts = new ArrayList<ContractI>(1);
  4896. lContracts.add(this);
  4897. }
  4898.  
  4899. }
  4900.  
  4901. }
  4902. else
  4903. {
  4904. lContracts = new ArrayList<ContractI>(1);
  4905. lContracts.add(this);
  4906. }
  4907.  
  4908. Iterator<ContractI> lContrIter = lContracts.iterator();
  4909. while (lContrIter.hasNext())
  4910. {
  4911. ContractI lCrtContr = lContrIter.next();
  4912. int lContractStateI = lCrtContr.getCurrentStatusI().getStateI();
  4913. /*
  4914. * Check if the contract is active
  4915. */
  4916. int lContractPendingState = 0;
  4917. ContractStatusI lContractPendingStatus = lCrtContr.getPendingStatusI();
  4918. if (lContractPendingStatus != null)
  4919. {
  4920. lContractPendingState = lContractPendingStatus.getStateI();
  4921. }
  4922. if (lContractStateI == ContractStatusI.Active && lContractPendingStatus == null ||
  4923. lContractStateI == ContractStatusI.Active && lContractPendingStatus != null
  4924. && (pGetMode == GETBAL_ALL || lContractPendingState == ContractStatusI.Deactive) ||
  4925. lContractStateI == ContractStatusI.Onhold && (pGetMode == GETBAL_ACT_ONHOLD || pGetMode == GETBAL_ALL) ||
  4926. lContractStateI == ContractStatusI.Suspended && pGetMode == GETBAL_ALL)
  4927. {
  4928. ContractedCompositeProduct lConCompProduct = (ContractedCompositeProduct) lCrtContr.getContractedCompositeProductI();
  4929. Vector<ContractedProductElement> lConServices = lConCompProduct.getContractedProductElements();
  4930. Iterator<ContractedProductElement> lServicesIter = lConServices.iterator();
  4931. while (lServicesIter.hasNext())
  4932. {
  4933. ContractedProductElement lConProductElem = lServicesIter.next();
  4934. ProductElementTemplateI lPet = lConProductElem.getProductElementI().getProductElementTemplateI();
  4935. if (!lPet.isCostControlServiceI())
  4936. {
  4937. // ignore this service, only cost control services are considered for the following
  4938. continue;
  4939. }
  4940. int lCurrentState = lConProductElem.getStateI();
  4941. int lPendingState = lConProductElem.getRequestedStateI();
  4942. HistoryI lPendingStatus = lConProductElem.getPendingStatusEntryI();
  4943. if (lCurrentState == ContractedProductElementI.Active && lPendingStatus == null ||
  4944. lCurrentState == ContractedProductElementI.Active && lPendingStatus != null
  4945. && (pGetMode == GETBAL_ALL || lContractPendingState == ContractStatusI.Deactive) ||
  4946. (lCurrentState == ContractedProductElementI.Onhold || lCurrentState == ContractedProductElementI.Deactive)
  4947. && lPendingState == ContractedProductElementI.Active ||
  4948. lCurrentState == ContractedProductElementI.Onhold && (pGetMode == GETBAL_ACT_ONHOLD || pGetMode == GETBAL_ALL) ||
  4949. lCurrentState == ContractedProductElementI.Suspended && pGetMode == GETBAL_ALL)
  4950. {
  4951.  
  4952. boolean lToBeAdded = false;
  4953. NetworkServiceI lNWServI = (NetworkServiceI) lPet;
  4954. CostControlPackage ccPack = (CostControlPackage) lNWServI.getCostControlPackageI();
  4955.  
  4956. if (getIDI() == lCrtContr.getIDI() && (ccPack.isSelfMonitoringBalance() || ccPack.isContractBalanceI()))
  4957. {
  4958. /*
  4959. * Special case if we are looking at the same contract
  4960. * We have to take care about the "Contract balance" flag
  4961. * and about the "Self monitoring flag"
  4962. */
  4963. lToBeAdded = true;
  4964. }
  4965. else
  4966. {
  4967. /*
  4968. * we have to look into its parameters (even though it is the same contract!!!)
  4969. * Remember that the monitoring relation is set via the values
  4970. * of a specific parameter with the "Contribution" purpose
  4971. */
  4972.  
  4973. /*
  4974. * get all current value nodes
  4975. */
  4976. Vector<ParameterValueNodeI> lParameters = lConProductElem.getCurrentParameterValueNodesI();
  4977. int lParamSize = lParameters.size();
  4978. for (int i = 0; i < lParamSize; ++i)
  4979. {
  4980. ParameterValueNodeI lParameterValueI = lParameters.get(i);
  4981.  
  4982. /*
  4983. * Check the purpos -> Contribution
  4984. */
  4985. if (lParameterValueI.getParameterI().getPurposeI() == Parameter.PURPOSE_CONTRIBUTION_LIST)
  4986. {
  4987. ParameterValueNode lParameterValue = (ParameterValueNode) lParameterValueI;
  4988. if (!NullConversion.isNull(lParameterValue.getNumericValue())
  4989. && ((long) lParameterValue.getNumericValue()) == getIDI())
  4990. {
  4991. lToBeAdded = true;
  4992. break;
  4993. }
  4994. }
  4995.  
  4996. }
  4997. }
  4998.  
  4999. // has the service qualified?
  5000. if (lToBeAdded)
  5001. {
  5002. /*
  5003. * if it has to be considered, add it to the list
  5004. * according to the input parameter filter
  5005. */
  5006.  
  5007. if (!pMoneyWalletsOnly || ccPack.isMoneyWalletI())
  5008. {
  5009. lBalList.add(lConProductElem);
  5010. }
  5011. }
  5012.  
  5013. } // end - if the contracted service is active
  5014.  
  5015. } // end of loop through all services
  5016.  
  5017. } // end - if current contract is active
  5018.  
  5019. } // end - iterating through all contracts
  5020.  
  5021. return lBalList;
  5022. }
  5023.  
  5024. private static final int LEVEL_CONTRACT_UNKNOWN = 0;
  5025.  
  5026. private static final int LEVEL_CONTRACT_NO = 1;
  5027.  
  5028. private static final int LEVEL_CONTRACT_YES = 2;
  5029.  
  5030. /**
  5031. * Determines whether the contract is a level contract or not, or
  5032. * if this is not yet defined.
  5033. */
  5034. private transient int _levelContractFlag = LEVEL_CONTRACT_UNKNOWN;
  5035.  
  5036. /**
  5037. * Check if the Contract is a level contract or a standard contract.
  5038. * This is for feature 68993.
  5039. *
  5040. * @author M. Rupprecht
  5041. * @return boolean
  5042. */
  5043. @Override
  5044. public boolean isLevelContractI() throws ComponentException, ValidationException
  5045. {
  5046. boolean ret = false;
  5047.  
  5048. if (this.isAgreementContract())
  5049. {
  5050. return false;
  5051. }
  5052.  
  5053. /*
  5054. * Is the state retrieved yet?
  5055. */
  5056.  
  5057. switch (_levelContractFlag)
  5058. {
  5059. case LEVEL_CONTRACT_UNKNOWN :
  5060.  
  5061. /*
  5062. * Get the contract Holder
  5063. */
  5064. OrgNodeI holder = getContractHolderI();
  5065.  
  5066. /*
  5067. * Get the level of the Holder
  5068. */
  5069. long level = holder.getLevelI();
  5070.  
  5071. /*
  5072. * Test, if the level is the subscriber level
  5073. */
  5074. if (NullConversion.isNull(level))
  5075. {
  5076. return false;
  5077. }
  5078. // This is not a level contract
  5079. _levelContractFlag = LEVEL_CONTRACT_NO;
  5080. ret = false;
  5081.  
  5082. break;
  5083. case LEVEL_CONTRACT_NO :
  5084. ret = false;
  5085. break;
  5086. case LEVEL_CONTRACT_YES :
  5087. ret = true;
  5088. break;
  5089. default :
  5090. throw new IllegalArgumentException("Unknown level contract flag " + _levelContractFlag);
  5091. }
  5092.  
  5093. return ret;
  5094. }
  5095.  
  5096. /**
  5097. * setContractHolderI. Sets the contract holder of the contract. This is for feature 68993.
  5098. *
  5099. * @author M. Rupprecht
  5100. * @param pOrgNode
  5101. * a OrgNodeII
  5102. * @throws SystemException
  5103. * @throws ComponentException
  5104. * @throws ValidationException
  5105. */
  5106. @Override
  5107. public void setContractHolderI(OrgNodeI pOrgNode) throws ComponentException, ValidationException
  5108. {
  5109.  
  5110. /*
  5111. * check if original object is already set and different from the passed object
  5112. */
  5113.  
  5114. Contract vOriginalContract = (Contract) getOriginalObject();
  5115. OrgNodeI vOriginalOrgNode = vOriginalContract.getContractHolderI();
  5116.  
  5117. /*
  5118. * Feature 313299
  5119. * For use in single customer care deployment so as to avoid to allow
  5120. * a post paid customer to be non payment responsible.
  5121. */
  5122. if (!pOrgNode.isPaymentResponsibleI() &&
  5123. CorporateAccountManager.getInstance().isCorporateAccountMemberI(pOrgNode) == LogicalI._False
  5124. && pOrgNode.hasRole(PartyRole.SUBSCRIBER))
  5125. {
  5126. throw new ValidationException("CMS.BusinessPartner.MustBePaymentResp", "Contract holder has SUBSCRIBER role");
  5127. }
  5128.  
  5129. if (vOriginalOrgNode != null)
  5130. {
  5131. if (!vOriginalOrgNode.equals(pOrgNode))
  5132. {
  5133. throw new ComponentException("CMS.Contract.ContractHolderAlreadyAssigned", "Use 'takeover' functionality!");
  5134. }
  5135. /*
  5136. * holder is already set, nothing to do!
  5137. */
  5138. return;
  5139. }
  5140.  
  5141. setContractHolder(pOrgNode);
  5142.  
  5143. }
  5144.  
  5145. /**
  5146. * Flag indicating wether the itemized bill shall be archieved -> 'X', otherwise -> NULL Linked to CONTRACT_ALL.CO_ARCHIVE
  5147. */
  5148. protected String _archivingEnabled = NullConversion.STRING_NULL_VALUE;
  5149.  
  5150. /**
  5151. * Returns a boolean value if archiving is enabled
  5152. *
  5153. * @return boolean
  5154. */
  5155. public boolean isArchivingEnabled()
  5156. {
  5157. return "X".equals(_archivingEnabled);
  5158. }
  5159.  
  5160. /**
  5161. * Set the value if archiving is enabled
  5162. *
  5163. * @retrun none
  5164. * @param pValue
  5165. */
  5166. public void setArchivingEnabled(boolean pValue)
  5167. {
  5168.  
  5169. if (pValue)
  5170. {
  5171. _archivingEnabled = "X";
  5172. }
  5173. else
  5174. {
  5175. _archivingEnabled = NullConversion.STRING_NULL_VALUE;
  5176. }
  5177. }
  5178.  
  5179. /**
  5180. * isArchivingEnabled. Returns a boolean value if archiving is enabled
  5181. *
  5182. * @return boolean
  5183. */
  5184. @Override
  5185. public boolean isArchivingEnabledI()
  5186. {
  5187. if (this.isAgreementContract())
  5188. {
  5189. return false;
  5190. }
  5191. return isArchivingEnabled();
  5192. }
  5193.  
  5194. /**
  5195. * setArchivingEnabledI. Set the value if archiving is enabled
  5196. *
  5197. * @retrun none
  5198. * @param pValue
  5199. * @throws ComponentException
  5200. * @throws ValidationException
  5201. * @throws SystemException
  5202. */
  5203. @Override
  5204. public void setArchivingEnabledI(boolean pValue)
  5205. throws ComponentException, ValidationException
  5206. {
  5207.  
  5208. // Forward the call to the aggregated ItemizedBillSettings
  5209. if (!this.isAgreementContract())
  5210. {
  5211. setArchivingEnabled(pValue);
  5212.  
  5213. // Feat. 83597 - changing the archive flag is rating relevant
  5214. // So, rating provisioning required
  5215. // SB 21-Jul-2001
  5216.  
  5217. // get the contract and all data for rating provisioning
  5218. ContractTaskHandler vContractTaskHandler = getContractTaskHandler();
  5219. long vTime = ServerTime.getCurrentTimeAsLong();
  5220. short vPriority = ContractAdministrator.getInstance().getCommonDomainAdministrator().getUserPriorityI(GMDActionI.ChangeMobileSubscription);
  5221.  
  5222. // register the action for provisioning
  5223. vContractTaskHandler.registerAction(ContractSettings.CONTRACT_PARAMETERS_SET,
  5224. new AbstractDomainObjectI[]{this},
  5225. vTime,
  5226. vPriority,
  5227. TaskTypeI.Provisioning,
  5228. "N", "Y");
  5229. }
  5230. // 00270484
  5231. else
  5232. {
  5233. setArchivingEnabled(pValue);
  5234. }
  5235. }
  5236.  
  5237. /**
  5238. * Checks if user has the proper permission to change the contract status.
  5239. *
  5240. * @param pOldState
  5241. * current state
  5242. * @param pNewState
  5243. * follow-up state
  5244. * @throws ComponentException
  5245. * @throws ValidationException
  5246. */
  5247. public void checkPermissionForTransition(int pOldState, int pNewState) throws ComponentException, ValidationException
  5248. {
  5249.  
  5250. // check if state transition is valid
  5251. ContractStatus currentStatus = (ContractStatus) getCurrentStatusI();
  5252. if (!currentStatus.isFollowStateI(pNewState))
  5253. {
  5254. throw new ValidationException("CMS.Contract.InvalidState");
  5255. }
  5256.  
  5257. String permission = NullConversion.STRING_NULL_VALUE;
  5258. switch (pNewState)
  5259. {
  5260. case ContractStatusI.Active : {
  5261. if (pOldState == ContractStatusI.Suspended)
  5262. {
  5263. permission = "PermContractReactivation";
  5264. }
  5265. else
  5266. {
  5267. permission = "PermContractActivation";
  5268. }
  5269. break;
  5270. }
  5271. case ContractStatusI.Suspended : {
  5272. permission = "PermContractSuspension";
  5273. break;
  5274. }
  5275. case ContractStatusI.Deactive : {
  5276. permission = "PermContractDeactivation";
  5277. break;
  5278. }
  5279. default :
  5280. throw new IllegalArgumentException("Unknown new contract state " + pNewState);
  5281. } // switch
  5282.  
  5283. com.lhs.ccb.sfw.security.UserI user = ServiceContext.getCurrent().getUser();
  5284. if (!user.hasPermission(permission))
  5285. {
  5286. // user does not have the permission
  5287. throw new ValidationException("CMS.Contract.NoPermissionGranted.StatusChange", permission);
  5288. }
  5289. }
  5290.  
  5291. /**
  5292. * Returns the contracts for which this contract is contributing to
  5293. *
  5294. * @return contract ids
  5295. */
  5296. public String[] getTargetContracts()
  5297. {
  5298. String sql = "SELECT co.co_code " +
  5299. "from mkt_parameter p, parameter_value pv, contract_all co, " +
  5300. "profile_service ps, service_parameter sp, mpulknxv nxv, " +
  5301. "pr_serv_status_hist pssh " +
  5302. "where p.purpose ='C' and pv.parameter_id=p.parameter_id and prm_value_number=#CO_ID and " +
  5303. "co.co_id=pv.co_id and ps.co_id=pv.co_id and co.ch_status!='d' and " +
  5304. "ps.status_histno=pssh.histno and pssh.status!='D' and " +
  5305. "ps.co_id= pssh.co_id and " +
  5306. "ps.sncode= pssh.sncode and " +
  5307. "ps.profile_id= pssh.profile_id and " +
  5308. "sp.svcode=nxv.sscode and nxv.sncode=ps.sncode and " +
  5309. "pv.prm_seqno=( select max(pv2.prm_seqno) from parameter_value pv2 where " +
  5310. "pv.parameter_id=pv2.parameter_id and " +
  5311. "pv.prm_value_id=pv2.prm_value_id and " +
  5312. "pv.prm_no=pv2.prm_no and pv.prm_seqno=pv2.prm_seqno and pv.complex_seqno=pv2.complex_seqno and " +
  5313. "pv.parent_seqno=pv2.parent_seqno and pv.sibling_seqno=pv2.sibling_seqno and " +
  5314. "pv.value_seqno=pv2.value_seqno) order by co.co_code";
  5315.  
  5316. ArrayList<Long> arguments = new ArrayList<Long>(1);
  5317. DirectReadQuery query = new DirectReadQuery();
  5318. query.setSQLString(sql);
  5319. query.addArgument("CO_ID");
  5320. arguments.add(Long.valueOf(getIDI()));
  5321. List<String> result = (List<String>) TransactionContext.getCurrent().getUnitOfWork().executeQuery(query, arguments);
  5322.  
  5323. int size = result.size();
  5324. return result.toArray(new String[size]);
  5325. }
  5326.  
  5327. /**
  5328. * Returns the current assigned BOPPackage (if available)
  5329. *
  5330. * @return current assigned BOPPackage
  5331. * @throws ComponentException
  5332. * @throws ValidationException
  5333. * more than one active BOP service
  5334. */
  5335. public BOPPackageVersion getCurrentBOPPackageVersion() throws ComponentException, ValidationException
  5336. {
  5337.  
  5338. ContractedCompositeProduct conCompProd = getContractedCompositeProduct();
  5339. List<ContractedProductElement> conProdElems = conCompProd.getContractedProductElements();
  5340. Iterator<ContractedProductElement> iter = conProdElems.iterator();
  5341. BOPPackage bopPkg = null;
  5342. BOPPackageVersion bopPkgVers = null;
  5343.  
  5344. while (iter.hasNext())
  5345. {
  5346. ContractedProductElement conProdElem = iter.next();
  5347. NetworkServiceI networkService = conProdElem.getNetworkService();
  5348. if (networkService != null)
  5349. {
  5350. if (networkService.getSubtypeI() == NetworkServiceI.BOP_SERVICE_SUBTYPE)
  5351. {
  5352. List<ParameterValueNode> paramValNodes = conProdElem.getCurrentParameterValueNodes();
  5353. Iterator<ParameterValueNode> iter2 = paramValNodes.iterator();
  5354.  
  5355. // Is BOP service activated or to be activated?
  5356. CPEStatusHistoryI pendingStatus = conProdElem.getPendingStatusEntryI();
  5357. if (iter2.hasNext()
  5358. &&
  5359. (
  5360. conProdElem.getStateI() == ContractedProductElementI.Onhold && pendingStatus != null
  5361. && pendingStatus.getStateI() == ContractedProductElementI.Active ||
  5362. conProdElem.getStateI() == ContractedProductElementI.Active && pendingStatus == null
  5363. ))
  5364. {
  5365. if (bopPkg != null)
  5366. {
  5367. throw new ValidationException("CMS.Contract.SeveralActiveBOPServices", Long.valueOf(getIDI()), bopPkg.getLongDescription());
  5368. }
  5369. ParameterValueNode paramValNode = iter2.next();
  5370. long bopPkgId = (long) paramValNode.getNumericValue();
  5371.  
  5372. bopPkg = AbstractFactory.getObjectFromID(BOPPackage.class, Long.valueOf(bopPkgId));
  5373. if (bopPkg != null)
  5374. {
  5375. bopPkgVers = bopPkg.getCurrentVersion();
  5376. }
  5377. }
  5378. }
  5379. }
  5380. }
  5381. return bopPkgVers;
  5382. }
  5383.  
  5384. /**
  5385. * validate BOPPackage assignment
  5386. *
  5387. * @return true if valid BOPPackage assignment, ValidationException is thrown if invalid
  5388. * @throws ComponentException
  5389. * @throws ValidationException
  5390. * BOPPackage assignment is invalid
  5391. */
  5392. public boolean validateBOP() throws ComponentException, ValidationException
  5393. {
  5394.  
  5395. List<String[]> errors = checkBOP();
  5396. if (!errors.isEmpty())
  5397. {
  5398. int size = errors.size();
  5399. ComponentException[] compExcs = new ComponentException[size];
  5400. for (int i = 0; i < size; i++)
  5401. {
  5402. String[] elem = errors.get(i);
  5403. Object[] objArr = new Object[elem.length - 1];
  5404. System.arraycopy(elem, 0, objArr, 0, elem.length - 1);
  5405. compExcs[i] = new ComponentException("CMS.BOP_CONFIG_ERROR_" + elem[elem.length - 1], objArr);
  5406. }
  5407. ComponentException e = new ComponentException("CMS.BOP_CONFIG_ERROR");
  5408. e.addNestedExceptions(compExcs);
  5409. throw e;
  5410. }
  5411. return true;
  5412. }
  5413.  
  5414. // --> defect 286384 NiJ
  5415. /**
  5416. * Checks the rateplan limits for resource assignment (DN_LIMIT, DN_BLOCK_LIMIT, PORT_LIMIT).
  5417. * The resources are checked PER contract. DN_LIMIT is related to the amount of active
  5418. * non-block directory numbers assigned to the contract.
  5419. * DN_BLOCK limit is related to the amount of active block directory numbers assigned to
  5420. * the contract.
  5421. *
  5422. * @throws ComponentException
  5423. */
  5424. public void checkAssignResourceLimits()
  5425. throws ComponentException
  5426. {
  5427. ContractedCompositeProduct lCcp = getContractedCompositeProduct();
  5428. // get the dn limits from the ccp template
  5429. int lDnLimit = lCcp.getCompositeProductI().getCompositeProductTemplateI().getDnLimitI();
  5430. int lDnBlockLimit = lCcp.getCompositeProductI().getCompositeProductTemplateI().getDnBlockLimitI();
  5431.  
  5432. if (lDnLimit != NullConversion.INT_NULL_VALUE ||
  5433. lDnBlockLimit != NullConversion.INT_NULL_VALUE)
  5434. {
  5435. List<ContractedDNPropertiesI> lAllActiveConDNProperties = getActiveDNProperties();
  5436. if (lAllActiveConDNProperties.size() > 0)
  5437. {
  5438. int lDnNums = 0;
  5439. int lDnBlocks = 0;
  5440. ArrayList<PhoneNumberI> lDnBlocksConstPart = new ArrayList<PhoneNumberI>();
  5441.  
  5442. for (int i = 0; i < lAllActiveConDNProperties.size(); i++)
  5443. {
  5444. ContractedDNProperties lcDNprop = (ContractedDNProperties) lAllActiveConDNProperties.get(i);
  5445. DirectoryNumberI lDirNum = lcDNprop.getDirectoryNumberI();
  5446. if (lDirNum instanceof PhoneNumberI)
  5447. {
  5448. PhoneNumberI lPhoneNum = (PhoneNumberI) lDirNum;
  5449.  
  5450. if (lPhoneNum.isBlockDirectoryNumberI())
  5451. {
  5452. // first check if the blocks have not been already retrieved for this directory number
  5453. if (!lDnBlocksConstPart.contains(lPhoneNum))
  5454. {
  5455. // remember the constant part for which the blocks have already been retrieved
  5456. lDnBlocksConstPart.add(lPhoneNum);
  5457.  
  5458. // this is a not yet regarded blocked directory number, get the coresponding blocks
  5459. List<DirectoryNumberBlockI> lCurrentlDirnumBlocks = lPhoneNum.getActiveDirectoryNumberBlocksI();
  5460. if (!lCurrentlDirnumBlocks.isEmpty())
  5461. {
  5462. // add to assigned directory number block list
  5463. lDnBlocks += lCurrentlDirnumBlocks.size();
  5464. }
  5465. }
  5466. }
  5467. else
  5468. {
  5469. // add to assigned directory number list (used for PhoneNumber types)
  5470. lDnNums++;
  5471. }
  5472. }
  5473. else
  5474. {
  5475. // add to assigned directory number list (used for any other types derived from DirectoryNumber)
  5476. lDnNums++;
  5477. }
  5478. }
  5479.  
  5480. // check directory number assignment limit
  5481. if (lDnLimit != NullConversion.INT_NULL_VALUE && lDnNums > lDnLimit)
  5482. {
  5483. // error
  5484. throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.ExceededDirnumAssignmentLimit",
  5485. Integer.valueOf(lDnLimit),
  5486. Long.valueOf(lCcp.getCompositeProductI().getIDI()),
  5487. lCcp.getCompositeProductI().getShortNameI());
  5488. }
  5489.  
  5490. // check directory number block assignment limit
  5491. if (lDnBlocks > 0)
  5492. {
  5493. if (lDnBlockLimit != NullConversion.INT_NULL_VALUE && lDnBlocks > lDnBlockLimit)
  5494. {
  5495. throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.ExceededDirnumBlockAssignmentLimit",
  5496. Integer.valueOf(lDnBlockLimit),
  5497. Long.valueOf(lCcp.getCompositeProductI().getIDI()),
  5498. lCcp.getCompositeProductI().getShortNameI());
  5499. }
  5500. }
  5501. }
  5502. }
  5503.  
  5504. // get the port limits from the ccp template
  5505. int lDnPortLimit = lCcp.getCompositeProductI().getCompositeProductTemplateI().getPortLimitI();
  5506.  
  5507. // check PORT_LIMIT, if no port limit exists return immediatly.
  5508. if (lDnPortLimit != NullConversion.INT_NULL_VALUE)
  5509. {
  5510. List<ContractedPortPropertiesI> lAllActiveConPortProperties = getActivePortProperties();
  5511. // check PORT_LIMIT && check if there are any active ports attached to the service
  5512. if (lAllActiveConPortProperties.size() > lDnPortLimit && lDnPortLimit > 0)
  5513. {
  5514.  
  5515. throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.ExceededPortAssignmentLimit",
  5516. Integer.valueOf(lDnPortLimit),
  5517. Long.valueOf(lCcp.getCompositeProductI().getIDI()),
  5518. lCcp.getCompositeProductI().getShortNameI());
  5519. }
  5520. }
  5521. }
  5522. // <-- 286384
  5523.  
  5524. /**
  5525. * For an BOP contract it is not allowed to have billing accounts below the contract-level
  5526. * i.e. profile-, service- or charge-type-level.
  5527. *
  5528. * @return true if billing account assignment is consistent, false otherwise
  5529. * @throws ComponentException
  5530. */
  5531. protected boolean checkBillingAccountsForBOP() throws ComponentException
  5532. {
  5533. BillingAdministratorI billAdmin = AdministratorFactory.getInstance().getBillingAdministrator(); // PN 314351, MCH
  5534. // 07.10.2008, refactoring
  5535. List<BillingAccountAssignment> billAccAssignList = billAdmin.getExplicitBillAccAssignments(getIDI(), ServerTime.getCurrentTime());
  5536. Iterator<BillingAccountAssignment> billAccAssignIter = billAccAssignList.iterator();
  5537. boolean ok = true;
  5538. BillingAccountAssignment billAccAssign;
  5539. while (ok && billAccAssignIter.hasNext())
  5540. {
  5541. billAccAssign = billAccAssignIter.next();
  5542. if (billAccAssign.getBillingAccAssignTemplateVersion() != null)
  5543. {
  5544. List<BillingAccountAssignmentTemplateRule> rules =
  5545. billAccAssign.getBillingAccAssignTemplateVersion().getBillingAccountAssignmentTemplateRules();
  5546. for (BillingAccountAssignmentTemplateRule rule : rules)
  5547. {
  5548. ok = NullConversion.isNull(rule.getChargeTypeId()) &&
  5549. NullConversion.isNull(rule.getProfileId()) &&
  5550. NullConversion.isNull(rule.getService());
  5551. }
  5552. }
  5553. }
  5554. return ok;
  5555. }
  5556.  
  5557. /**
  5558. * check BOPPackage assignment
  5559. *
  5560. * @return list of errors and parameters
  5561. * @throws ComponentException
  5562. * @throws ValidationException
  5563. */
  5564. protected List<String[]> checkBOP() throws ComponentException, ValidationException
  5565. {
  5566. if (!getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.ALTERNATE_TARIFF))
  5567. {
  5568. // no BOP supported for this type of contract
  5569. return new ArrayList<String[]>(0);
  5570. }
  5571. BOPPackageVersion bopPkgVers = getCurrentBOPPackageVersion();
  5572. List<String[]> errors = null;
  5573. if (bopPkgVers != null)
  5574. {
  5575. ContractedCompositeProduct conCompProd = getContractedCompositeProduct();
  5576. CompositeProduct compProd = null;
  5577. if (conCompProd.getPendingCompositeProductI() != null)
  5578. {
  5579. compProd = (CompositeProduct) conCompProd.getPendingCompositeProductI();
  5580. }
  5581. else
  5582. {
  5583. compProd = (CompositeProduct) conCompProd.getCompositeProductI();
  5584. }
  5585.  
  5586. List<ContractedProductElement> conProdElems = conCompProd.getContractedProductElements();
  5587. Iterator<ContractedProductElement> iter = conProdElems.iterator();
  5588. ProductElement[] prodElems = new ProductElement[conProdElems.size()];
  5589. SimpleProduct[] simpleProds = new SimpleProduct[conProdElems.size()];
  5590. int count = 0;
  5591. errors = new ArrayList<String[]>(3);
  5592. // we have a BOP service
  5593. if (conCompProd.getContractedProductElementMap().size() > 1)
  5594. {
  5595. throw new ValidationException("CMS.Contract.InvalidNumberOfProfiles");
  5596. }
  5597. else if (conCompProd.getContractedProductElementMap().get(TopologyAdministrator.getInstance().getDefaultProfileI()) == null)
  5598. {
  5599. throw new ValidationException("CMS.Contract.InvalidProfile");
  5600. }
  5601.  
  5602. while (iter.hasNext())
  5603. {
  5604. ContractedProductElement conProdElem = iter.next();
  5605. CPEStatusHistoryI currStatus = conProdElem.getCurrentStatusEntry();
  5606. CPEStatusHistoryI pendingStatus = conProdElem.getPendingStatusEntryI();
  5607. // only check for activated or to be activated services
  5608. if (currStatus.getStateI() == ContractedProductElementI.Active ||
  5609. pendingStatus != null &&
  5610. pendingStatus.getStateI() == ContractedProductElementI.Active)
  5611. {
  5612. prodElems[count] = (ProductElement) conProdElem.getProductElementI();
  5613. simpleProds[count] = (SimpleProduct) conProdElem.getSimpleProduct();
  5614. NetworkServiceI service = conProdElem.getNetworkService();
  5615. count++;
  5616. if (service != null)
  5617. {
  5618. // check whether it is a free unit service
  5619. if (service.isFreeUnitTypeI())
  5620. {
  5621. // get parameter for free unit package
  5622. List<ParameterValueNode> paramValNodes = conProdElem.getCurrentParameterValueNodes();
  5623. Iterator<ParameterValueNode> iter2 = paramValNodes.iterator();
  5624.  
  5625. // Is FU service activated or to be activated?
  5626. while (iter2.hasNext())
  5627. {
  5628. ParameterValueNode paramValNode = iter2.next();
  5629. // the free unit parameter is the only single entry parameter
  5630. if (paramValNode.isSingleEntryParameterValueNode())
  5631. {
  5632. long fupPkgId = (long) paramValNode.getNumericValue();
  5633.  
  5634. FreeUnitPackageTemplate fuPkg = AbstractFactory.getObjectFromID(FreeUnitPackageTemplate.class, Long.valueOf(fupPkgId));
  5635. if (fuPkg != null && !"B".equals(fuPkg.getApplicationMethodI()))
  5636. {
  5637. errors.add(new String[]{getPublicKey(), fuPkg.getShortDescriptionI(), service.getShortNameI(),
  5638. String.valueOf(BOPPackageVersion.BOP_ERROR_CO_HAS_EXPL_NON_BILLING_TIME_FUP)});
  5639. }
  5640. }
  5641. }
  5642. }
  5643. }
  5644. }
  5645. }
  5646. errors.addAll(bopPkgVers.checkServiceConfiguration(compProd, simpleProds, prodElems));
  5647. String[] coCodes = getTargetContracts();
  5648. if (coCodes.length > 0)
  5649. {
  5650. StringBuilder coCodesStr = new StringBuilder();
  5651. for (int i = 0; i < coCodes.length; i++)
  5652. {
  5653. if (i > 0)
  5654. {
  5655. coCodesStr.append(", ");
  5656. }
  5657. coCodesStr.append(coCodes[i]);
  5658. }
  5659. errors.add(new String[]{getPublicKey(), coCodesStr.toString(), String.valueOf(BOPPackageVersion.BOP_ERROR_BOP_CONTRACT_CONTRIBUTES)});
  5660. }
  5661.  
  5662. if (!checkBillingAccountsForBOP())
  5663. {
  5664. errors.add(new String[]{getPublicKey(), String.valueOf(BOPPackageVersion.BOP_ERROR_BOP_CONTRACT_WRONG_BILLING_ACCOUNT)});
  5665. }
  5666. }
  5667. else
  5668. {
  5669. errors = new ArrayList<String[]>(0);
  5670. }
  5671. return errors;
  5672. }
  5673.  
  5674. /**
  5675. * Set the type of the contract, only type 'S' is allowed for this class.
  5676. */
  5677. @Override
  5678. public void setTypeI(String pType)
  5679. {
  5680. _type = pType;
  5681. }
  5682. /**
  5683. * Indicates if the contract has a BOP service assigned
  5684. *
  5685. * @return true if the contract has a BOP service
  5686. * @throws ComponentException
  5687. * @throws ValidationException
  5688. */
  5689. public boolean hasBOPService() throws ComponentException, ValidationException
  5690. {
  5691.  
  5692. ContractedCompositeProduct conCompProd = getContractedCompositeProduct();
  5693. List<ContractedProductElement> conProdElems = conCompProd.getContractedProductElements();
  5694. Iterator<ContractedProductElement> iter = conProdElems.iterator();
  5695.  
  5696. while (iter.hasNext())
  5697. {
  5698. ContractedProductElement conProdElem = iter.next();
  5699. if (conProdElem.getServiceSubtypeI() == NetworkServiceI.BOP_SERVICE_SUBTYPE)
  5700. {
  5701. return true;
  5702. }
  5703.  
  5704. }
  5705. return false;
  5706. }
  5707.  
  5708. /**
  5709. * @see com.lhs.Contract.bscs_core.external.ContractI#getCustomizationSectionI()
  5710. */
  5711. @Override
  5712. public CustomizationSectionI getCustomizationSectionI()
  5713. {
  5714.  
  5715. return _compositeContractSection.getCustomizationSection();
  5716. }
  5717.  
  5718. /**
  5719. * getTrialPeriodStartDate. Returns the date, when the trial period for this Contract starts.
  5720. *
  5721. * @return int
  5722. */
  5723. public int getTrialPeriodStartDate()
  5724. {
  5725. return CAASDateConverter.toCAASDate(_trialPeriodStartDate);
  5726. }
  5727.  
  5728. /**
  5729. * setTrialPeriodStartDate. Set the date, when the trial period for this Contract starts.
  5730. *
  5731. * @param pTrialStartDate
  5732. */
  5733. public void setTrialPeriodStartDate(int pTrialStartDate)
  5734. {
  5735. _trialPeriodStartDate = CAASDateConverter.toDate(pTrialStartDate);
  5736. }
  5737.  
  5738. /**
  5739. * getTrialPeriodEndDateI. Returns the date, when the trial period for this Contract ends.
  5740. *
  5741. * @return int
  5742. */
  5743. public int getTrialPeriodEndDate()
  5744. {
  5745. return CAASDateConverter.toCAASDate(_trialPeriodEndDate);
  5746. }
  5747.  
  5748. /**
  5749. * setTrialPeriodEndDateI. Sets the date, when the trial period for this contract will end. Behaviour must be as follows in CMS:
  5750. * >> save old trial end date (of contract) #old_trial_date = SELECT TRIAL_END_DATE FROM CONTRACT_ALL WHERE CO_ID =
  5751. * #given_contract_id >> set new trial end date of contract UPDATE CONTRACT_ALL SET TRIAL_END_DATE = #new_trial_date WHERE CO_ID
  5752. * = #given_contract_id >> set trial end date of contracted services which >> - don't have a trial date or >> - whose trial is
  5753. * older than the new trial date >> - whose trial date is equal to the old trial date of the contract UPDATE PROFILE_SERVICE SET
  5754. * TRIAL_END_DATE = #new_trial_date WHERE CO_ID = #given_contract_id AND ((TRIAL_END_DATE IS NULL) OR (TRIAL_END_DATE <
  5755. * #new_trial_date) OR (TRIAL_END_DATE = #old_trial_date)) >> modify contract ( UPDATE CONTRACT_ALL SET TRIAL_END_DATE =
  5756. * #new_trial_end_date, CO_USERLASTMOD = #current_user, CO_MODDATE = sysdate, REC_VERSION = #incremented_rec_version WHERE
  5757. * ((CO_ID = #given_contract) AND (REC_VERSION = #old_rec_version)) >> create rating provisioning request because the trial end
  5758. * date is influences rating INSERT INTO GMD_REQUEST_BASE (REQUEST_ID, ENTRY_DATE) VALUES (#new_request_id, sysdate) INSERT INTO
  5759. * MDSRRTAB (PROVISIONING_FLAG, ACTION_DATE, INSERTED_BY_TARGYS, REQUEST, RATING_FLAG, VMD_RETRY, STATUS, REQUEST_UPDATE,
  5760. * PRIORITY, TS, SWITCH_ID, ERROR_CODE, GMD_MARKET_ID, ERROR_RETRY, ACTION_ID, INSERT_DATE, DATA_1, WORKER_PID, DATA_2,
  5761. * PARENT_REQUEST, DATA_3, SCCODE, PLCODE, CO_ID, CUSTOMER_ID, USERID) VALUES('N', sysdate, 'X', #request_id, 'Y', 0, 2, null,
  5762. * 0, sysdate, #switch_id, 0, #gmd_market_id, 0, #action_id, sysdate, null, 0, null, null, null, #market_id, #network,
  5763. * #given_contract_id, #given_customer_id, #current_user)
  5764. *
  5765. * @param pTrialEndDate
  5766. * new trial period end date
  5767. * @throws SystemException
  5768. * @throws ComponentException
  5769. * @throws ValidationException
  5770. */
  5771. public void setTrialPeriodEndDate(int pTrialEndDate)
  5772. throws ComponentException, ValidationException
  5773. {
  5774. // From CustomerContract
  5775. // ---> begin of defect 242337 (OH)
  5776.  
  5777. // In the following code whether the new trial end date can be set on the contract:
  5778. //
  5779.  
  5780. // check whether technology supports on trial contracts
  5781. ContractedCompositeProduct ccp = getContractedCompositeProduct();
  5782. TelecomTechnologyI technology = (TelecomTechnologyI) ccp.getTechnologyI();
  5783.  
  5784. // 236082_cms exclude agreement contracts
  5785. ContractType contractType = getContractType();
  5786. if (!contractType.isContractAgreementType() && technology != null && !technology.isTrialPeriodSupportedI())
  5787. {
  5788. // in case the end date is a null value, it does not switch on trial contract, therefore just return
  5789. if (NullConversion.isNull(pTrialEndDate))
  5790. {
  5791. return;
  5792. }
  5793. throw new ValidationException("CMS.Contract.TechnologyDoesNotSupportOnTrialContracts");
  5794. }
  5795.  
  5796. // check whether trial end date is not in the future (past days or today)
  5797. int currentDate = ServerTime.getCurrentDateAsInt();
  5798. // DAE 00245602 TrialEndDate must be possible set to NULL
  5799. Date vDate = CAASDateConverter.toDate(pTrialEndDate);
  5800. if (pTrialEndDate != NullConversion.INT_NULL_VALUE && pTrialEndDate <= currentDate)
  5801. {
  5802. throw new ValidationException("CMS.Contract.InvalidTrialEndDate.LessThanCurrent",
  5803. vDate);
  5804. }
  5805.  
  5806. int expirationDate = getExpirationDateI();
  5807. // check whether contract is still on trial (old trial end date is set and still in the future)
  5808. if (isOnTrialI())
  5809. {
  5810. // check whether contract expires before new trial end date
  5811. if (!NullConversion.isNull(expirationDate) && pTrialEndDate > expirationDate)
  5812. {
  5813. // defect 00254807/d APO
  5814. // throw new ValidationException( "Contract.InvalidTrialEndDate.GreaterThanExpiration");
  5815. throw new ValidationException("CMS.Contract.InvalidTrialEndDate.GreaterThanExpiration",
  5816. vDate, CAASDateConverter.toDate(expirationDate));
  5817. // end 00254807/d
  5818. }
  5819. }
  5820. else
  5821. {
  5822. // check whether contract (that is not on trial) is in state onhold
  5823. if (getCurrentStatusI().getStateI() == ContractStatusI.Onhold)
  5824. {
  5825. // check whether new trial end date is less or equal to contract expiration date
  5826.  
  5827. if (!NullConversion.isNull(expirationDate))
  5828. {
  5829. // defect 00254807/d APO
  5830. // throw new ValidationException( "Contract.InvalidTrialEndDate.GreaterThanExpiration");
  5831. if (NullConversion.INT_NULL_VALUE == pTrialEndDate)
  5832. {
  5833. throw new ValidationException("CMS.Contract.InvalidTrialEndDate.GreaterThanExpiration",
  5834. "", CAASDateConverter.toDate(expirationDate));
  5835. }
  5836. throw new ValidationException("Contract.InvalidTrialEndDate.GreaterThanExpiration",
  5837. vDate, CAASDateConverter.toDate(expirationDate));
  5838.  
  5839. }
  5840. // End 00254807/d
  5841. }
  5842. else
  5843. {
  5844. // an active, deactive or suspended contract can not be set to 'on trial'!
  5845. throw new ValidationException("Contract.ContractStatusOnholdRequired");
  5846. }
  5847. }
  5848.  
  5849. // save old trial end date
  5850. int oldTrialPeriodEndDate = CAASDateConverter.toCAASDate(_trialPeriodEndDate);
  5851.  
  5852. // set new trial end date
  5853. _trialPeriodEndDate = CAASDateConverter.toDate(pTrialEndDate);
  5854.  
  5855. // create rating provisioning request for changing the trial end date on the contract
  5856. short priority = ContractAdministrator.getInstance().getCommonDomainAdministrator().
  5857. getUserPriorityI(GMDActionI.ChangeMobileSubscription);
  5858. getContractTaskHandler().registerAction(
  5859. ContractSettings.CONTRACT_PARAMETERS_SET,
  5860. new AbstractDomainObjectI[]{this},
  5861. currentDate, priority, TaskTypeI.Provisioning, "N", "Y");
  5862.  
  5863. // iterate through all contracted services / contracted product elements and set the trial end date
  5864. ContractTaskHandler vTaskHandler = getContractTaskHandler();
  5865. priority = ContractAdministrator.getInstance().getCommonDomainAdministrator().
  5866. getUserPriorityI(GMDActionI.ServiceControl);
  5867. String provFlag = "N";
  5868. String ratingFlag = "Y";
  5869.  
  5870. Vector<ContractedProductElement> cpeList = ccp.getContractedProductElements();
  5871. Iterator<ContractedProductElement> lIter = cpeList.iterator();
  5872. while (lIter.hasNext())
  5873. {
  5874. ContractedProductElement cpe = lIter.next();
  5875. final int lTrialPeriodEndDateI = cpe.getTrialPeriodEndDateI();
  5876. // check whether:
  5877. // (trial end date of contracted service is not set) OR
  5878. // (trial end date of contracted service is less than new trial end date of contract) OR
  5879. // (trial end date of contracted service is equal to old trial end date of contract)
  5880. if (NullConversion.isNull(lTrialPeriodEndDateI) ||
  5881. lTrialPeriodEndDateI < pTrialEndDate ||
  5882. lTrialPeriodEndDateI == oldTrialPeriodEndDate)
  5883. {
  5884. // create rating provisioning request for the changing trial end date on the contracted service
  5885. vTaskHandler.registerAction(ContractSettings.SL_CHANGE_TRIAL_DATE,
  5886. new AbstractDomainObjectI[]{this, cpe},
  5887. currentDate, priority, TaskTypeI.Provisioning, provFlag, ratingFlag);
  5888. // trial end date on service
  5889. cpe.setTrialPeriodEndDate(pTrialEndDate);
  5890. }
  5891. }
  5892. // ---> end of defect 242337 (OH)
  5893. }
  5894.  
  5895. /**
  5896. * setDealer. Stores the reference of the DealerOrgNode, the contract is assigned to. This method does not perform any checks.
  5897. *
  5898. * @param pDealerOrgNode
  5899. * com.lhs.BusinessPartner.bscs_core.external.DealerOrgNodeI
  5900. * @throws ComponentException
  5901. */
  5902. public void setDealer(OrgNodeI pDealerOrgNode) throws ComponentException
  5903. {
  5904.  
  5905. if (!isAgreementContract())
  5906. {
  5907. /*
  5908. * Store the passed DealerOrgNode
  5909. */
  5910. FWValueHolder.setValue(_dealer, pDealerOrgNode, this);
  5911. }
  5912. }
  5913.  
  5914. /**
  5915. * getDealerI. Returns the dealer, this Contract is assigned to.
  5916. *
  5917. * @return com.lhs.BusinessPartner.bscs_core.external.OrgNodeI
  5918. */
  5919. public OrgNodeI getDealer()
  5920. {
  5921. if (isAgreementContract())
  5922. {
  5923. return null;
  5924. }
  5925.  
  5926. // might be a dealer or a service provider!
  5927. return FWValueHolder.getValue(_dealer);
  5928. }
  5929.  
  5930. /**
  5931. * Gets the Foreign Network.
  5932. *
  5933. * @return _foreignNetwork
  5934. */
  5935. public Network getForeignNetwork()
  5936. {
  5937. return FWValueHolder.getValue(_foreignNetwork);
  5938. }
  5939.  
  5940. /**
  5941. * Sets the Foreign Network.
  5942. *
  5943. * @param pNetwork
  5944. * @throws ComponentException
  5945. */
  5946. public void setForeignNetwork(Network pNetwork) throws ComponentException
  5947. {
  5948. FWValueHolder.setValue(_foreignNetwork, pNetwork, this);
  5949. }
  5950. // begin 236082_cms
  5951. /**
  5952. * checks whether a party role and party type combination of the current user matches the party type and the party role of the
  5953. * second contract holder.
  5954. *
  5955. * @throws ComponentException
  5956. * @return true if user has sufficient permissions, false otherwise.
  5957. */
  5958. public boolean hasPartyTypeAndRolePermission() throws ComponentException
  5959. {
  5960. com.lhs.CommonDomain.bscs_core.CMSUserI user = CMSUser.getCMSUser();
  5961. ContractType contractType = getContractType();
  5962.  
  5963. OrgNode secondContractHolder = (OrgNode) getContractHolderI();
  5964. long secondPartyRoleId = contractType.getSecondPartyRole().getId();
  5965. char secondPartyTypeId = secondContractHolder.getPartyType().charAt(0);
  5966. return user.isAuthorizedForPartyRoleConfig(secondPartyTypeId, secondPartyRoleId);
  5967.  
  5968. }
  5969.  
  5970. /**
  5971. * checks whether a party role and party type combination of the current user matches the party type and the party role of the
  5972. * second contract holder.
  5973. *
  5974. * @throws ComponentException
  5975. * in case the user has not sufficient rights (party role and party type combinations do not match)
  5976. */
  5977. public void checkPartyTypeAndRolePermission() throws ComponentException
  5978. {
  5979. if (!hasPartyTypeAndRolePermission())
  5980. {
  5981. com.lhs.CommonDomain.bscs_core.CMSUserI user = CMSUser.getCMSUser();
  5982. ContractType contractType = getContractType();
  5983. throw new ComponentException("CMS.Contract.UserNotAllowed", user.getName(), getPublicKey(), contractType.getShortName());
  5984. }
  5985. }
  5986. // end 236082_cms
  5987.  
  5988. /**
  5989. * set type of call detail generation. Possible values: P, R, null
  5990. */
  5991. @Override
  5992. public void setCallDetail(char pCallDetailFlag)
  5993. {
  5994. if (!NullConversion.isNull(pCallDetailFlag) && pCallDetailFlag != 'R' && pCallDetailFlag != 'P')
  5995. {
  5996. throw new ComponentException(DomainService.RC_INVALID_PARAMETER_VALUE, "CALL_DETAIL", "P,R,NULL");
  5997. }
  5998. if (!isNew() && pCallDetailFlag != _callDetail)
  5999. {
  6000. createCallDetailChangeTickler(pCallDetailFlag);
  6001. }
  6002. _callDetail = pCallDetailFlag;
  6003. }
  6004. /**
  6005. * Create a tickler for a call detail change.
  6006. *
  6007. * @param pCallDetailFlag
  6008. */
  6009. protected void createCallDetailChangeTickler(char pCallDetailFlag)
  6010. {
  6011. // create a tickler
  6012. SystemEventMessageDefinitionI definition = new SystemEventMessageDefinitionI();
  6013.  
  6014. definition.OrgNode = this.getContractHolderI();
  6015. definition.Contract = this;
  6016. definition.ShortDescription = TICKLER_CALLDETAIL_SHORT_DESC;
  6017. if (NullConversion.isNull(pCallDetailFlag))
  6018. {
  6019. definition.LongDescription = NLSAdministrator.getInstance().translate("nlsCallDetailDisabled");
  6020. }
  6021. else
  6022. {
  6023. // - Enhance long description by adding the P (periodically) or R (on request) flag in order to see which option was
  6024. // choosen when enabling the
  6025. // - call detail statement.
  6026. definition.LongDescription = NLSAdministrator.getInstance().translate("nlsCallDetailEnabled", Character.valueOf(pCallDetailFlag));
  6027. }
  6028. definition.Status = TICKLER_STATUS_NOTE;
  6029. definition.Priority = 4;
  6030. BusinessPartnerEventManagementAdministrator.getInstance().createSystemEventMessageI(definition);
  6031.  
  6032. }
  6033.  
  6034. /**
  6035. * indicates which address shoudl be used.
  6036. *
  6037. * @param pFlag
  6038. */
  6039. @Override
  6040. public void setUseUserInstallationAddress(boolean pFlag)
  6041. {
  6042. if (pFlag)
  6043. {
  6044. _useUserInstallationAddress = "X";
  6045. }
  6046. else
  6047. {
  6048. _useUserInstallationAddress = NullConversion.STRING_NULL_VALUE;
  6049. }
  6050. }
  6051.  
  6052. /**
  6053. * sets the bill medium id
  6054. *
  6055. * @param pBillMediumId
  6056. */
  6057. @Override
  6058. public void setBillMedium(long pBillMediumId)
  6059. {
  6060. _billMediumId = pBillMediumId;
  6061. }
  6062.  
  6063. /**
  6064. * returns the call detail flag
  6065. *
  6066. * @return The call detail setup.
  6067. */
  6068. @Override
  6069. public char getCallDetail()
  6070. {
  6071. return _callDetail;
  6072. }
  6073.  
  6074. /**
  6075. * returns is the call detail statement should be printed
  6076. *
  6077. * @return boolean
  6078. */
  6079. @Override
  6080. public boolean isCallDetailEnabled()
  6081. {
  6082. return _callDetail == CALL_DETAIL_STMT_ON_REQUEST || _callDetail == CALL_DETAIL_STMT_PERIODICALLY;
  6083. }
  6084.  
  6085. /**
  6086. * returns true if user/installation address should be printed on call detail statement
  6087. *
  6088. * @return boolean
  6089. */
  6090. @Override
  6091. public boolean useUserInstallationAddress()
  6092. {
  6093. return "X".equals(_useUserInstallationAddress);
  6094. }
  6095.  
  6096. /**
  6097. * returns the contracted bill medium id
  6098. *
  6099. * @return long
  6100. */
  6101. @Override
  6102. public long getBillMediumId()
  6103. {
  6104. return _billMediumId;
  6105. }
  6106.  
  6107. /**
  6108. * Hook called when instance is refreshed.
  6109. */
  6110. @Override
  6111. public void postRefresh() throws ComponentException, ValidationException
  6112. {
  6113. // update the transient smart refs as well since the data might have changed on the database
  6114. cleanTransientReferences();
  6115. }
  6116.  
  6117. /**
  6118. * Optional callback method, invoked after the clone object has merged
  6119. * with the original object (this happens after commit).
  6120. * Defect 00266184
  6121. */
  6122. @Override
  6123. public void postMerge()
  6124. {
  6125. // reset transient field, will be filled with next access
  6126. cleanTransientReferences();
  6127. }
  6128.  
  6129. /**
  6130. * @return The method returns true if the contract has post- and pre-paid services. *
  6131. * @throws ComponentException
  6132. * @throws ValidationException
  6133. */
  6134. public boolean isMixedContract() throws ValidationException, ComponentException
  6135.  
  6136. {
  6137. /*
  6138. * Get the contracted composite product
  6139. */
  6140. ContractedCompositeProduct contractedCompositeProd = getContractedCompositeProduct();
  6141. Vector<ContractedProductElement> listPEs = contractedCompositeProd.getContractedProductElements();
  6142. if (!listPEs.isEmpty())
  6143. {
  6144. Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
  6145. while (iterPEs.hasNext())
  6146. {
  6147. ContractedProductElementI contractedPEI = iterPEs.next();
  6148.  
  6149. if (contractedPEI.isPrepaidI() && contractedPEI.getPrepaidTimePackageI() != null)
  6150. {
  6151. return true;
  6152. }
  6153.  
  6154. if (!contractedPEI.isPrepaidI())
  6155. {
  6156. ProductElementTemplateI vTemplate = contractedPEI.getProductElementI().getProductElementTemplateI();
  6157. if (vTemplate instanceof NetworkServiceI)
  6158. {
  6159. NetworkService lNetworkService = (NetworkService) vTemplate;
  6160.  
  6161. if (!contractedPEI.isValueAddedServiceI() && lNetworkService.isRatingRelevant())
  6162. {
  6163. return true;
  6164. }
  6165. }
  6166. }
  6167. // in case access and subscription charges are postpaid, return immediatly.
  6168. if (!contractedPEI.hasPrepaidAccessAndSubscriptionCharges())
  6169. {
  6170. return true;
  6171. }
  6172.  
  6173. }
  6174. }
  6175.  
  6176. return false;
  6177. }
  6178. // APO 00260533_cms
  6179. /**
  6180. * check product change request
  6181. *
  6182. * @return true if there is a pending rate plan or service package request.
  6183. * @throws ComponentException
  6184. * @throws ValidationException
  6185. */
  6186.  
  6187. public boolean hasProductChangeRequest() throws ComponentException, ValidationException
  6188. {
  6189. // check pending rate plan change
  6190. ContractedCompositeProduct compositeProduct = getContractedCompositeProduct();
  6191.  
  6192. if (compositeProduct.getPendingCompositeProductI() != null)
  6193. {
  6194. return true;
  6195. }
  6196. // check pending service package change
  6197. if (compositeProduct.hasPendingSPchangeRequest())
  6198. {
  6199. return true;
  6200. }
  6201.  
  6202. return false;
  6203. }
  6204. /**
  6205. * Get the contract next status sequence number.
  6206. *
  6207. * @return The next contract status sequence number.
  6208. */
  6209. public long getNextContractStatusSeqNo()
  6210. {
  6211. if (_currentStatus == null)
  6212. {
  6213. retrieveCurrentAndPendingStatus();
  6214. }
  6215. if (_pendingStatus != null)
  6216. {
  6217. return _pendingStatus.getIDI() + 1;
  6218. }
  6219. if (_currentStatus != null)
  6220. {
  6221. return _currentStatus.getIDI() + 1;
  6222. }
  6223. return 1L;
  6224. }
  6225.  
  6226. /**
  6227. * Returns the charging period adjustment reference.
  6228. * For services with charging schedule
  6229. * set to "Cut off date related".
  6230. * Domain:
  6231. * 'B' - Billing period reference date
  6232. * 'A' - Contract activation date
  6233. *
  6234. * @return Returns the charging period adjustment reference.
  6235. */
  6236. public char getChargingPeriodAdjustmentReference()
  6237. {
  6238. return _chargingPeriodAdjustmentReference;
  6239. }
  6240.  
  6241. /**
  6242. * Sets the charging period adjustment reference.
  6243. * For services with charging schedule
  6244. * set to "Cut off date related".
  6245. * Domain:
  6246. * 'B' - Billing period reference date
  6247. * 'A' - Contract activation date
  6248. *
  6249. * @param pChargingPeriodAdjustmentReference
  6250. * The charging period adjustment reference to set.
  6251. */
  6252. public void setChargingPeriodAdjustmentReference(
  6253. char pChargingPeriodAdjustmentReference)
  6254. {
  6255. _chargingPeriodAdjustmentReference = pChargingPeriodAdjustmentReference;
  6256. }
  6257.  
  6258. /**
  6259. * Returns the identifier of the medium for notification messages.
  6260. *
  6261. * @return Returns the notification medium identifier.
  6262. */
  6263. public long getNotificationMediumId()
  6264. {
  6265. return _notificationMediumId;
  6266. }
  6267.  
  6268. /**
  6269. * Sets the identifier of the medium for notification messages.
  6270. *
  6271. * @param pNotificationMediumId
  6272. * The notification medium identifier to set.
  6273. */
  6274. public void setNotificationMediumId(long pNotificationMediumId)
  6275. {
  6276. _notificationMediumId = pNotificationMediumId;
  6277. }
  6278.  
  6279. /**
  6280. * Returns the charge start date.
  6281. *
  6282. * @return Returns the charge start date.
  6283. */
  6284. public Date getChargeStartDate()
  6285. {
  6286. return _chargeStartDate;
  6287. }
  6288.  
  6289. /**
  6290. * Sets the charge start date.
  6291. *
  6292. * @param pStartDate
  6293. */
  6294. public void setChargeStartDate(Date pStartDate)
  6295. {
  6296. _chargeStartDate = pStartDate;
  6297. }
  6298. /**
  6299. * Returns the last cust off date.
  6300. * The last charging period is the same for all contracted services
  6301. * with charging schedule set to "Cut off date related".
  6302. * This attribute defines the next cut off date. Read only!
  6303. *
  6304. * @return Returns the last cut off date.
  6305. */
  6306. public Date getLastCutOffDate()
  6307. {
  6308. return _lastCutOffDate;
  6309. }
  6310.  
  6311. /**
  6312. * Returns the last notification date.
  6313. *
  6314. * @return Returns the last notification dDate.
  6315. */
  6316. public Date getLastNotificationDate()
  6317. {
  6318. return _lastNotificationDate;
  6319. }
  6320.  
  6321. /**
  6322. * Returns the next cut off date.
  6323. * The next charging period is the same for all contracted services
  6324. * with charging schedule set to "Cut off date related".
  6325. * This attribute defines the next cut off date. Read only!
  6326. *
  6327. * @return Returns the next cut off date.
  6328. */
  6329. public Date getNextCutOffDate()
  6330. {
  6331. return _nextCutOffDate;
  6332. }
  6333.  
  6334. /**
  6335. * @return _recVersion
  6336. */
  6337. public BigDecimal getRecVersion()
  6338. {
  6339. // feature 00276491_cms
  6340. return _recordVersion;
  6341. }
  6342.  
  6343. /**
  6344. * return ConcurrentRequestHandler associated with this Contract
  6345. *
  6346. * @return ConcurrentRequestHandler
  6347. * @throws ComponentException
  6348. * ConcurrentRequestHandler is not set
  6349. */
  6350. public ConcurrentRequestHandler getConcurrentRequestHandler() throws ComponentException
  6351. {
  6352. // feature 00276491_cms
  6353. if (_concurrentRequestHandler == null)
  6354. {
  6355. throw new ComponentException("Contract.ConcurrentRequestHandlerMissing");
  6356. }
  6357. return _concurrentRequestHandler;
  6358. }
  6359.  
  6360. // B: 00280461_cms
  6361. /**
  6362. * Sets the earliest contract end date.
  6363. *
  6364. * @param pEarliestContractEndDate
  6365. * Date
  6366. */
  6367. public void setEarliestContractEndDate(Date pEarliestContractEndDate)
  6368. {
  6369. _earliestContractEndDate = pEarliestContractEndDate;
  6370. }
  6371.  
  6372. /**
  6373. * Returns the earliest contract end date.
  6374. *
  6375. * @return Date
  6376. */
  6377. public Date getEarliestContractEndDate()
  6378. {
  6379. return _earliestContractEndDate;
  6380. }
  6381. // E: 00280461_cms
  6382.  
  6383. /**
  6384. * Returns true if the contract data shall be available on every rating node (is common reference data).
  6385. *
  6386. * @return boolean
  6387. */
  6388. public boolean isCommonReferenceData()
  6389. {
  6390. return _isCommonRefData;
  6391. }
  6392.  
  6393. /**
  6394. * Sets the flag that indicates if the contract data shall be available
  6395. * on every rating node (is common reference data).
  6396. *
  6397. * @param pIsCommonRefData
  6398. * @throws ComponentException
  6399. * @throws ValidationException
  6400. */
  6401. public void setIsCommonReferenceData(boolean pIsCommonRefData) throws ValidationException, ComponentException
  6402. {
  6403. if (_isCommonRefData != pIsCommonRefData)
  6404. {
  6405. _isCommonRefData = pIsCommonRefData;
  6406.  
  6407. if (!this.isNew())
  6408. {
  6409. // Rating needs to be informed about the change
  6410. ContractTaskHandler contractTaskHandler = getContractTaskHandler();
  6411. long time = ServerTime.getCurrentTimeAsLong();
  6412. short priority = ContractAdministrator.getInstance().getCommonDomainAdministrator().getUserPriorityI(GMDActionI.ChangeMobileSubscription);
  6413.  
  6414. contractTaskHandler.registerAction(TaskManagementSettings.CONTRACT_SNAPSHOT,
  6415. new AbstractDomainObjectI[]{this},
  6416. time,
  6417. priority,
  6418. TaskTypeI.Provisioning,
  6419. "N", "Y");
  6420. }
  6421. }
  6422. }
  6423.  
  6424. /**
  6425. * Returns the porting requests of contract.
  6426. *
  6427. * @return Vector
  6428. */
  6429. public Vector<PortingRequest> getPortingRequests()
  6430. {
  6431. return FWValueHolder.getValue(_portingRequest);
  6432. }
  6433.  
  6434. /**
  6435. * Adds another PortingRequest to this Contract resp.
  6436. *
  6437. * @param pPortingRequest
  6438. * PortingRequest
  6439. * @throws ComponentException
  6440. * @throws ValidationException
  6441. */
  6442. public void addPortingRequest(PortingRequest pPortingRequest) throws ComponentException, ValidationException
  6443. {
  6444. // Retrieve the list of all ContractedProductElements
  6445. Vector<PortingRequest> elementList = getPortingRequests();
  6446. elementList.add(pPortingRequest);
  6447.  
  6448. // in case of a deactive contract, avoid that the contract is marked as modified.
  6449. if (getCurrentStatusI().getStateI() == ContractStatusI.Deactive)
  6450. {
  6451. _portingRequest.setValue(elementList);
  6452. }
  6453. else
  6454. {
  6455. FWValueHolder.setDirectValue(_portingRequest, elementList, this);
  6456. }
  6457. }
  6458.  
  6459. // FSP 288320, Re-rating, MCH 26.06.2008
  6460. /**
  6461. * Checks whether the contract is marked as candidate for re-rating.
  6462. */
  6463. @Override
  6464. public boolean isReratingCandidate()
  6465. {
  6466. return _isReratingCandidate;
  6467. }
  6468.  
  6469. /**
  6470. * Marks the subscriber contract as candidate for re-rating or removes the mark.
  6471. * Deactivated contracts can be marked or unmarked as long as the deactivation isn't passed longer than _pDays_.
  6472. *
  6473. * @param pMark
  6474. * true - mark as candidate, false - remove the mark
  6475. * @param pDays
  6476. * @throws ComponentException
  6477. * @throws ValidationException
  6478. */
  6479. @Override
  6480. public void markForRerating(boolean pMark, int pDays) throws ComponentException, ValidationException
  6481. {
  6482. validateCandidateForRerating(pDays);
  6483.  
  6484. _isReratingCandidate = pMark;
  6485. createReratingTickler(pMark); // PN 312791_cms, MCH 02.12.2008, 09.02.2009
  6486. }
  6487.  
  6488. /**
  6489. * Checks whether the contract can be marked for re-rating.
  6490. * Deactivated contracts can be marked or unmarked as long as the deactivation isn't passed longer than _pDays_.
  6491. *
  6492. * @param pDays
  6493. * - days number will be checked, if greater than 0
  6494. * @throws ComponentException
  6495. * @throws ValidationException
  6496. */
  6497. protected void validateCandidateForRerating(int pDays) throws ComponentException, ValidationException
  6498. {
  6499. // only subscriber contracts are allowed
  6500. if (!getContractHolderI().isCustomer())
  6501. {
  6502. throw new ValidationException("CMS.Contract.MarkCandidateForRerating.NotAllowedForNonSubscriberContract",
  6503. Long.valueOf(getIDI()), getPublicKeyI());
  6504. }
  6505.  
  6506. // check contract state
  6507. int status = getCurrentStatusI().getStateI();
  6508.  
  6509. if (status == ContractStatusI.Deactive && pDays > 0)
  6510. {
  6511. // Timestamp date = CAASTimeConverter.toTimestamp( getCurrentStatusI().getCreationDateI());
  6512. // Timestamp now = ServerTime.getCurrentTime();
  6513. long date = getCurrentStatusI().getCreationDateI();
  6514. long now = ServerTime.getCurrentTimeAsLong();
  6515.  
  6516. if (date + pDays * ServerTime.MILLISECONDS_IN_DAY < now)
  6517. {
  6518. throw new ValidationException("CMS.Contract.MarkCandidateForRerating.Status.Timeout",
  6519. Long.valueOf(getIDI()), getPublicKeyI());
  6520. }
  6521. }
  6522. // only state 'active' and 'suspended' are allowed
  6523. else if (status != ContractStatusI.Active && status != ContractStatusI.Suspended)
  6524. {
  6525. throw new ValidationException("CMS.Contract.MarkCandidateForRerating.Status.Invalid",
  6526. Long.valueOf(getIDI()), getPublicKeyI());
  6527. }
  6528. }
  6529.  
  6530. /**
  6531. * Check whether the contract is a subscriber contract
  6532. */
  6533. @Override
  6534. public boolean isSubscriberContract()
  6535. {
  6536. String shName = getContractType().getShortName();
  6537. if (ContractType.SHNAME_NOS.equals(shName) || ContractType.SHNAME_NOST.equals(shName)
  6538. || ContractType.SHNAME_NOPAS.equals(shName))
  6539. {
  6540. return true;
  6541. }
  6542.  
  6543. return false;
  6544. }
  6545.  
  6546. /**
  6547. * @see com.lhs.ccb.sfw.domain.AbstractDomainObject#validateI()
  6548. */
  6549. @Override
  6550. public boolean validateI()
  6551. throws ValidationException, ComponentException
  6552. {
  6553. // omit other validations, if the re-rating flag of the deactivated contract is changed
  6554. // and is the only changed attribute.
  6555. if (checkReratingFlag())
  6556. {
  6557. return true;
  6558. }
  6559.  
  6560. return super.validateI();
  6561. }
  6562.  
  6563. /**
  6564. * Checkes whether the re-rating flag of the deactivated contract is changed
  6565. * and is the only changed attribute.
  6566. *
  6567. * @return true, if re-rating flag of the deactivated customer is changed and is the only changed attribute;
  6568. * otherwise false
  6569. * @throws ComponentException
  6570. */
  6571. protected boolean checkReratingFlag() throws ComponentException
  6572. {
  6573. if (getCurrentStatusI().getStateI() == ContractStatusI.Deactive && !_valueHolderChanged)
  6574. {
  6575. String[] names = getModifiedCompareableAttributesNames();
  6576.  
  6577. if (names.length == 1 && "_isReratingCandidate".equals(names[0]))
  6578. {
  6579. return true;
  6580. }
  6581. }
  6582.  
  6583. return false;
  6584. }
  6585.  
  6586. /**
  6587. * @return the billing lock object
  6588. */
  6589. @Override
  6590. public BillingContractLock getBillingLock()
  6591. {
  6592. return FWValueHolder.getValue(_billingLock);
  6593. }
  6594.  
  6595. /**
  6596. * @return the re-rating lock object
  6597. */
  6598. @Override
  6599. public ReratingContractLock getReratingLock()
  6600. {
  6601. return FWValueHolder.getValue(_reratingLock);
  6602. }
  6603.  
  6604. /* public Contract getTemplate()
  6605. {
  6606. return FWValueHolder.getValue(_template);
  6607. }
  6608.  
  6609. public void setTemplate(Contract pContract)
  6610. {
  6611. FWValueHolder.setValue(_template, pContract, this);
  6612. }
  6613. */
  6614. public long getTemplateId()
  6615. {
  6616. return _templateId;
  6617. }
  6618.  
  6619. public void setTemplateId(long pId)
  6620. {
  6621. _templateId=pId;
  6622. }
  6623.  
  6624. /** convenience method to set the template id, input parameter can be null */
  6625. public void setTemplate(Contract pContract)
  6626. {
  6627. _templateId=(null==pContract)?NullConversion.LONG_NULL_VALUE:pContract.getIDI();
  6628. }
  6629.  
  6630. /**
  6631. * @see com.lhs.ccb.sfw.domain.AbstractDomainObject#preValidate()
  6632. */
  6633. @Override
  6634. public void preValidate() throws ValidationException, ComponentException
  6635. {
  6636. super.preValidate();
  6637.  
  6638. if (isNew())
  6639. {
  6640. // create entries for billing and re-rating locks
  6641. BillingContractLock bLock = AbstractFactory.createObject(BillingContractLock.class);
  6642. bLock.setContract(this);
  6643. FWValueHolder.setValue(_billingLock, bLock, this);
  6644.  
  6645. ReratingContractLock rLock = AbstractFactory.createObject(ReratingContractLock.class);
  6646. rLock.setContract(this);
  6647. FWValueHolder.setValue(_reratingLock, rLock, this);
  6648. }
  6649. }
  6650.  
  6651. // PN 312791_cms, MCH 02.12.2008, 09.02.2009
  6652. /**
  6653. * Creates a re-rating tickler.
  6654. */
  6655. protected void createReratingTickler(boolean pIsMarked)
  6656. {
  6657. NLSSystemEventMessageDefinitionI definition = new NLSSystemEventMessageDefinitionI();
  6658.  
  6659. definition.OrgNode = this.getContractHolderI();
  6660. definition.Contract = this;
  6661. definition.ShortDescription = TICKLER_RERATING_SHORT_DESC;
  6662. definition.LongDescription = pIsMarked ? TICKLER_RERATING_LONG_DESC_MARK : TICKLER_RERATING_LONG_DESC_UNMARK;
  6663. definition.Status = TICKLER_STATUS_NOTE;
  6664. definition.Priority = 4;
  6665.  
  6666. BusinessPartnerEventManagementAdministrator.getInstance().createNLSSystemEventMessageI(definition);
  6667. }
  6668. // end 312791_cms, MCH 02.12.2008, 09.02.2009
  6669.  
  6670. // end 288320, Re-rating, MCH 30.06.2008
  6671.  
  6672. /**
  6673. * @return the state, see {@link ContractStatusI}
  6674. */
  6675. public int getState()
  6676. {
  6677. return ContractStatus.charToState(_state);
  6678. }
  6679.  
  6680. /**
  6681. * Set the state of the contract and set the date this is valid from, normally set only by PL/SQL. But under some conditions
  6682. * (if a contract status change is <b>not</b> provisioned to rating or the network) it might be necessary to set the value
  6683. * directly.
  6684. *
  6685. * @param pState
  6686. * the state to set {@link ContractStatusI}
  6687. */
  6688. public void setState(int pState)
  6689. {
  6690. _state = ContractStatus.stateToChar(pState);
  6691. _statusValidFromDate = new Timestamp(getCurrentStatusI().getValidFromDateI());
  6692. }
  6693.  
  6694. // FSP 313297, Contracted Product Handling, MCH 12.01.2009
  6695. /**
  6696. * Gets the first contract status.
  6697. *
  6698. * @return The first contract status object.
  6699. * @throws ComponentException
  6700. * @throws ValidationException
  6701. * @see com.lhs.Contract.bscs_core.ContractStatus
  6702. */
  6703. public ContractStatusI getFirstStatus()
  6704. throws ComponentException, ValidationException
  6705. {
  6706. Vector<ContractStatus> stati = getContractStati();
  6707.  
  6708. Iterator<ContractStatus> iterator = stati.iterator();
  6709. while (iterator.hasNext())
  6710. {
  6711. ContractStatus tmpStatus = iterator.next();
  6712.  
  6713. if (tmpStatus.getIDI() == 1)
  6714. {
  6715. return tmpStatus;
  6716. }
  6717. }
  6718.  
  6719. return null;
  6720. }
  6721. // end 313297, Contracted Product Handling, MCH 12.01.2009
  6722.  
  6723. /**
  6724. * @return
  6725. */
  6726. public Vector<ContractedPromotionPlan> getContractedPromotionPlans()
  6727. {
  6728. return FWValueHolder.getValue(_contractedPromotionPlans);
  6729. }
  6730.  
  6731. /**
  6732. * @param pContractedPromotionPlan
  6733. */
  6734. public void addContractedPromotionPlan(ContractedPromotionPlan pContractedPromotionPlan)
  6735. {
  6736. Vector<ContractedPromotionPlan> contractedPromotionPlans = (Vector<ContractedPromotionPlan>) _contractedPromotionPlans.getValue();
  6737. contractedPromotionPlans.add(pContractedPromotionPlan);
  6738. FWValueHolder.setDirectValue(_contractedPromotionPlans, contractedPromotionPlans, this);
  6739. }
  6740.  
  6741. /**
  6742. * @param pContractedPromotionPlan
  6743. */
  6744. public void removeContractedPromotionPlan(ContractedPromotionPlan pContractedPromotionPlan)
  6745. {
  6746. Vector<ContractedPromotionPlan> contractedPromotionPlans = (Vector<ContractedPromotionPlan>) _contractedPromotionPlans.getValue();
  6747. contractedPromotionPlans.remove(pContractedPromotionPlan);
  6748. FWValueHolder.setDirectValue(_contractedPromotionPlans, contractedPromotionPlans, this);
  6749. }
  6750.  
  6751. /**
  6752. * @return true if this is a contract defined for the Ericsson charging system. false if this is a BSCS contract or a ECMS
  6753. * contract.
  6754. */
  6755. @Override
  6756. public boolean isChargingSystemContract()
  6757. {
  6758. if (this.isAgreementContract())
  6759. {
  6760. return false;
  6761. }
  6762.  
  6763. CompositeProductI lCompositeProductI = getContractedCompositeProduct().getCompositeProductI();
  6764. return lCompositeProductI != null && lCompositeProductI.isChargingSystemTypeI();
  6765. }
  6766.  
  6767. /**
  6768. * Gets the ProductElement for MainAccount (for CS contracts)
  6769. *
  6770. * @return the service representing the CS main account.
  6771. */
  6772. public ProductElement getProductElementForMainAccount()
  6773. {
  6774. Vector<ProductElementI> productElements = getContractedCompositeProduct().getCompositeProductI().getProductElementsI();
  6775. for (ProductElementI productElement : productElements)
  6776. {
  6777. ProductElementTemplateI productElementTemplate = productElement.getProductElementTemplateI();
  6778. if (productElementTemplate instanceof NetworkService)
  6779. {
  6780. NetworkService networkService = (NetworkService) productElementTemplate;
  6781. if (networkService.isCSMainAccount())
  6782. {
  6783. return (ProductElement) productElement;
  6784. }
  6785. }
  6786. }
  6787.  
  6788. return null;
  6789. }
  6790.  
  6791. /**
  6792. * Retrieves the last deactivated MSISDN
  6793. *
  6794. * @return MSISDN
  6795. */
  6796. public String getLastDeactivatedMSISDN()
  6797. {
  6798. List<ContractedProductElement> lContractedProductElements = getContractedCompositeProduct().getContractedProductElements();
  6799. if (lContractedProductElements.isEmpty())
  6800. {
  6801. throw new ComponentException("CMS.Contract.Invalid", Long.valueOf(getIDI()), getPublicKey());
  6802. }
  6803.  
  6804. for (ContractedProductElement lContractedProductElement : lContractedProductElements)
  6805. {
  6806. Vector<ContractedDNPropertiesI> lContractedDNPropertiesI = lContractedProductElement.getContractedDNPropertiesI();
  6807. if (!lContractedDNPropertiesI.isEmpty())
  6808. {
  6809. // We only want to return the main number of the contract
  6810. DirectoryNumberI lDirectoryNumber = lContractedDNPropertiesI.get(lContractedDNPropertiesI.size() - 1).getDirectoryNumberI();
  6811. return lDirectoryNumber.getNumberI();
  6812. }
  6813. }
  6814.  
  6815. throw new ComponentException("CMS.Contract.NoMSISDN", Long.valueOf(getIDI()), getPublicKey());
  6816. }
  6817.  
  6818. /**
  6819. * 350656_cms
  6820. *
  6821. * @param pInstance
  6822. * - Instance
  6823. * @param pEffectiveDate
  6824. * @param pRequestCode
  6825. * @param pCompositeProduct
  6826. * @param isRpChange
  6827. * - true if the method is being called for a rateplan change
  6828. * @param isContrTO
  6829. * - true if the method is being called for a contract takeover
  6830. */
  6831. public void configurePamClass(Instance pInstance, Timestamp pEffectiveDate,
  6832. String pRequestCode,
  6833. CompositeProductI pCompositeProduct,
  6834. boolean isRpChange,
  6835. boolean isContrTO)
  6836. {
  6837. if (isChargingSystemContract() && !this.getContractType().isCustomerContractTemplateType())
  6838. {
  6839. Vector<ContractedProductElementI> elements = getContractedCompositeProductI().getContractedProductElementsI();
  6840.  
  6841. for (ContractedProductElementI element : elements)
  6842. {
  6843. if (element.getServiceSubtypeI() == NetworkServiceI.PAM_INFO_SERVICE_SUBTYPE)
  6844. {
  6845. // register PAM Scheme ( FSP 369277, Multiple PAM, MCH)
  6846. if (isRpChange || isContrTO)
  6847. {
  6848. // 377727_E08_U15: PAM class and schedule are no longer stored in service parameter.
  6849. // Take the PAM class from PAM Info Service and the schedule from bill cycle
  6850. PamClass myPamClass = element.getProductElementI().getPamConfig().getPamClass();
  6851. PamSchedule pamSchedule = getPamScheduleFromBillCycle();
  6852.  
  6853. registerPamSchemeBillCycle(myPamClass, pamSchedule, (ContractedProductElement) element);
  6854. }
  6855.  
  6856. break;
  6857. }
  6858. }
  6859. }
  6860. }
  6861.  
  6862. /**
  6863. * feature 350656_cms / rework done with 377727_E08_U16
  6864. *
  6865. * @param pIsContractReactivation
  6866. * @param pIsContractTakeover
  6867. * @param pCurrentContract
  6868. */
  6869. public void configurePamScheduleForBillCycleChange(boolean pIsContractReactivation, boolean pIsContractTakeover, Contract pCurrentContract)
  6870. {
  6871. if (!(pIsContractReactivation || pIsContractTakeover
  6872. || (isChargingSystemContract() && getState() == ContractStatusI.Active && !hasPendingRequests())))
  6873. {
  6874. throw new ComponentException("CMS.CustomerContractWithPendingRequest");
  6875. }
  6876.  
  6877. boolean isPamScheduleChanged = false;
  6878. Timestamp effectiveDate = ServerTime.getCurrentTime();
  6879.  
  6880. Vector<ContractedProductElementI> elements = getContractedCompositeProductI().getContractedProductElementsI();
  6881.  
  6882. // gets the billcycle in order to discover if the customer has a pam schedule set
  6883. PamSchedule newPamSchedule = getPamScheduleFromBillCycle();
  6884.  
  6885. // get the existing (old) PAM Info Service Schedule from CONTRACT_PAM_SCHEME
  6886. PamSchedule oldPamSchedule = pCurrentContract.getPamScheduleFromBillCycleScheme();
  6887.  
  6888. if ((null == oldPamSchedule && null != newPamSchedule)
  6889. || (null != oldPamSchedule && null == newPamSchedule)
  6890. || (null != oldPamSchedule && null != newPamSchedule && (newPamSchedule.getExternalKey() != oldPamSchedule.getExternalKey())))
  6891. {
  6892. isPamScheduleChanged = true;
  6893. }
  6894.  
  6895. if (!isPamScheduleChanged)
  6896. {
  6897. return;
  6898. }
  6899.  
  6900. ContractedProductElementI cpePamInfoService = null; // PN 397120, MCH
  6901.  
  6902. // trigger new action id
  6903. registerActionForBillCycleChange(pIsContractTakeover, effectiveDate); // PN 397120, MCH
  6904.  
  6905. // check for services which might be affected by the Change of the Default PAM Schedule
  6906. for (ContractedProductElementI element : elements)
  6907. {
  6908. // remember PAM Info Service (PN 397120, MCH)
  6909. if (element.getServiceSubtypeI() == NetworkServiceI.PAM_INFO_SERVICE_SUBTYPE)
  6910. {
  6911. cpePamInfoService = element;
  6912. }
  6913.  
  6914. NetworkService networkService = (NetworkService) ((ContractedProductElement) element).getNetworkService();
  6915.  
  6916. if (networkService != null && networkService.isCostControlServiceI())
  6917. {
  6918. CostControlPackage ccPackage = (CostControlPackage) networkService.getCostControlPackageI();
  6919.  
  6920. if (ccPackage.getPamConfig() != null && ccPackage.getPamConfig().getPamSchedule() == null)
  6921. {
  6922. countPamScheduleChange(ccPackage.getPamConfig().getPamClass(), oldPamSchedule, newPamSchedule,
  6923. (ContractedProductElement) element);
  6924. }
  6925. }
  6926.  
  6927. ProductElementI pe = element.getProductElementI();
  6928.  
  6929. if (pe.getPamConfig() != null && pe.getPamConfig().getPamSchedule() == null)
  6930. {
  6931. countPamScheduleChange(pe.getPamConfig().getPamClass(), oldPamSchedule, newPamSchedule,
  6932. (ContractedProductElement) element);
  6933. }
  6934.  
  6935. if (pe.getPamConfigRecCharge() != null && pe.getPamConfigRecCharge().getPamSchedule() == null)
  6936. {
  6937. countPamScheduleChange(pe.getPamConfigRecCharge().getPamClass(), oldPamSchedule, newPamSchedule,
  6938. (ContractedProductElement) element);
  6939. }
  6940.  
  6941. if (networkService != null && networkService.isPamSpecialService())
  6942. {
  6943. long pamClassExternalKey = NullConversion.LONG_NULL_VALUE;
  6944. long pamScheduleExternalKey = NullConversion.LONG_NULL_VALUE;
  6945.  
  6946. Vector<ParameterValueNodeI> paramValues = element.getCurrentParameterValueNodesI();
  6947.  
  6948. Iterator<ParameterValueNodeI> iter = paramValues.iterator();
  6949. while (iter.hasNext())
  6950. {
  6951. ParameterValueNode value = (ParameterValueNode) iter.next();
  6952. String parameterPublicKey = ((Parameter) value.getParameterI()).getPublicKey();
  6953.  
  6954. if ("PAM_CLASM".equals(parameterPublicKey))
  6955. {
  6956. pamClassExternalKey = (long) value.getNumericValue();
  6957. continue;
  6958. }
  6959.  
  6960. // there are 2 parameters for PAM schedule
  6961. if ("PAM_SCHED".equals(parameterPublicKey))
  6962. {
  6963. pamScheduleExternalKey = (long) value.getNumericValue();
  6964. }
  6965. }
  6966.  
  6967. PamClass pamClass = null;
  6968. if (!NullConversion.isNull(pamClassExternalKey))
  6969. {
  6970. pamClass = PPamClass.readObjectByExternalKey(pamClassExternalKey);
  6971. }
  6972.  
  6973. PamSchedule pamSchedule = null;
  6974. if (!NullConversion.isNull(pamScheduleExternalKey))
  6975. {
  6976. pamSchedule = AbstractFactory.getObjectFromPublicKey(PamSchedule.class, pamScheduleExternalKey);
  6977. }
  6978.  
  6979. if (pamClass != null && pamSchedule == null)
  6980. {
  6981. countPamScheduleChange(pamClass, oldPamSchedule, newPamSchedule, (ContractedProductElement) element);
  6982. }
  6983. }
  6984. }
  6985.  
  6986. // finally evaluate the settings done via 'countPamScheduleChange'.
  6987. // For provisioning the modified scheme has to be linked to any product element.
  6988. registerPamScheduleChanges(newPamSchedule, (ContractedProductElement) cpePamInfoService); // instead of elements.lastElement() (PN 397120, MCH)
  6989.  
  6990. }
  6991.  
  6992. // PN 397120, MCH
  6993. /**
  6994. * Registers action for bill cycle change.
  6995. *
  6996. * @param pIsTakeover
  6997. * @param pEffectiveDate
  6998. */
  6999. private void registerActionForBillCycleChange(boolean pIsTakeover, Timestamp pEffectiveDate)
  7000. {
  7001. if (pIsTakeover)
  7002. {
  7003. // the new request must be a child of the contract takeover activation request
  7004. ActionDetailsI details = getContractTaskHandler().getActionDetails(TaskManagementSettings.CONTRACT_TAKEOVER_ACTIVATION);
  7005.  
  7006. long parentRequestId = details.PreallocatedRequestId;
  7007. details = getContractTaskHandler().registerAction(
  7008. TaskManagementSettings.PAM_SCHEME_CHANGE,
  7009. new AbstractDomainObjectI[] { this }, pEffectiveDate.getTime(),
  7010. details.Priority, // the same priority as for contract takeover activation
  7011. TaskTypeI.Provisioning, "Y", null,
  7012. parentRequestId);
  7013. details.PreallocatedRequestId = TaskManagementAdministrator.getInstance().getNewRequestIdI();
  7014. }
  7015. else
  7016. {
  7017. getContractTaskHandler().registerAction(
  7018. TaskManagementSettings.PAM_SCHEME_CHANGE,
  7019. new AbstractDomainObjectI[] { this },
  7020. pEffectiveDate.getTime(),
  7021. ContractAdministrator.getInstance().getCommonDomainAdministrator()
  7022. .getUserPriorityI(GMDActionI.ActivateSubscription),
  7023. TaskTypeI.Provisioning, "Y", null, 0, null, pEffectiveDate, null);
  7024. }
  7025. }
  7026.  
  7027. /**
  7028. * Set the batch transaction identifier of the batch job, that touched last the contract.
  7029. *
  7030. * @param pTransactionId
  7031. * the _transactionId to set
  7032. */
  7033. public void setTransactionId(long pTransactionId)
  7034. {
  7035. _transactionId = pTransactionId;
  7036. }
  7037. /**
  7038. * The batch transaction identifier of the batch job, that touched last the contract.
  7039. *
  7040. * @return the _transactionId
  7041. */
  7042. public long getTransactionId()
  7043. {
  7044. return _transactionId;
  7045. }
  7046.  
  7047. // 377727_E08_U07
  7048. /**
  7049. * Returns the PAM schemes of contract.
  7050. */
  7051. public Vector<ContractPamScheme> getPamSchemes()
  7052. {
  7053. return FWValueHolder.getValue(_pamSchemes);
  7054. }
  7055.  
  7056. /**
  7057. * Returns the free PAM schemes of contract.
  7058. */
  7059. public Vector<ContractPamScheme> getPamSchemesFree()
  7060. {
  7061. return FWValueHolder.getValue(_pamSchemesFree);
  7062. }
  7063.  
  7064. /**
  7065. * Searches for the assigned PAM scheme with the given PAM service id.
  7066. *
  7067. * @param pPamServiceId
  7068. * @return
  7069. */
  7070. public ContractPamScheme getPamScheme(long pPamServiceId)
  7071. {
  7072. if (NullConversion.isNull(pPamServiceId))
  7073. {
  7074. return null;
  7075. }
  7076.  
  7077. List<ContractPamScheme> pamSchemes = getPamSchemes();
  7078.  
  7079. for (ContractPamScheme pamScheme : pamSchemes)
  7080. {
  7081. if (pamScheme.getPamServiceId() == pPamServiceId)
  7082. {
  7083. return pamScheme;
  7084. }
  7085. }
  7086.  
  7087. return null;
  7088. }
  7089.  
  7090. /**
  7091. * Searches for the assigned PAM scheme (except PAM purpose 'BillCycle') with the given PAM class and PAM schedule.
  7092. * First checkes the pending values, than the current values.
  7093. *
  7094. * @param pPamClass
  7095. * @param pPamSchedule
  7096. * @return ContractPamScheme or null if not found.
  7097. */
  7098. public ContractPamScheme getPamScheme(PamClass pPamClass, PamSchedule pPamSchedule)
  7099. {
  7100. if (pPamClass == null) // 00377727_E08: Only Pam Class is mandatory
  7101. {
  7102. return null;
  7103. }
  7104.  
  7105. Vector<ContractPamScheme> pamSchemes = getPamSchemes();
  7106.  
  7107. long pamClassId = pPamClass.getIDI();
  7108. long pamScheduleId = NullConversion.LONG_NULL_VALUE;
  7109.  
  7110. if (pPamSchedule != null)
  7111. {
  7112. pamScheduleId = pPamSchedule.getIDI();
  7113. }
  7114.  
  7115. for (ContractPamScheme pamScheme : pamSchemes)
  7116. {
  7117. if ((// Check if pPamClass can be found as pending OR current value in CONTRACT_PAM_SCHEME
  7118. pamScheme.getPamClassPending() != null && pamScheme.getPamClassPending().getIDI() == pamClassId
  7119. || pamScheme.getPamClass() != null && pamScheme.getPamClassPending() == null && pamScheme.getPamClass().getIDI() == pamClassId)
  7120. // AND Check if pPamSchedule is null and so are pending and current values
  7121. // OR if pPamSchedule is not null and can be found as pending OR current value
  7122. && (pamScheme.getPamSchedulePending() == null && pamScheme.getPamSchedule() == null && pPamSchedule == null
  7123. || pamScheme.getPamSchedulePending() != null && pamScheme.getPamSchedulePending().getIDI() == pamScheduleId
  7124. || pamScheme.getPamSchedule() != null && pamScheme.getPamSchedulePending() == null
  7125. && pamScheme.getPamSchedule().getIDI() == pamScheduleId))
  7126. {
  7127. return pamScheme;
  7128. }
  7129. }
  7130.  
  7131. return null;
  7132. }
  7133.  
  7134. /**
  7135. * Searches for a PAM scheme with the current PAM Class and PAM Schedule corresponded to the given parameters.
  7136. *
  7137. * @param pPamClass
  7138. * @param pPamSchedule
  7139. * @return PAM Scheme or null
  7140. */
  7141. public ContractPamScheme getPamSchemeCurrent(PamClass pPamClass, PamSchedule pPamSchedule)
  7142. {
  7143. if (pPamClass == null)
  7144. {
  7145. return null;
  7146. }
  7147.  
  7148. Vector<ContractPamScheme> pamSchemes = getPamSchemes();
  7149.  
  7150. for (ContractPamScheme pamScheme : pamSchemes)
  7151. {
  7152. if (pamScheme.getPamClass() != null && pamScheme.getPamClass().getIDI() == pPamClass.getIDI()
  7153. && (pamScheme.getPamSchedule() == null && pPamSchedule == null
  7154. || pamScheme.getPamSchedule() != null && pPamSchedule != null
  7155. && pamScheme.getPamSchedule().getIDI() == pPamSchedule.getIDI()))
  7156. {
  7157. return pamScheme;
  7158. }
  7159. }
  7160.  
  7161. return null;
  7162. }
  7163.  
  7164. /**
  7165. * Searches for a PAM scheme with the pending PAM Class and PAM Schedule corresponded to the given parameters.
  7166. *
  7167. * @param pPamClass
  7168. * @param pPamSchedule
  7169. * @return PAM Scheme or null
  7170. */
  7171. public ContractPamScheme getPamSchemePending(PamClass pPamClass, PamSchedule pPamSchedule)
  7172. {
  7173. if (pPamClass == null)
  7174. {
  7175. return null;
  7176. }
  7177.  
  7178. Vector<ContractPamScheme> pamSchemes = getPamSchemes();
  7179.  
  7180. for (ContractPamScheme pamScheme : pamSchemes)
  7181. {
  7182. if (pamScheme.getPamClassPending() != null && pamScheme.getPamClassPending().getIDI() == pPamClass.getIDI()
  7183. && (pamScheme.getPamSchedulePending() == null && pPamSchedule == null
  7184. || pamScheme.getPamSchedulePending() != null && pPamSchedule != null
  7185. && pamScheme.getPamSchedulePending().getIDI() == pPamSchedule.getIDI()))
  7186. {
  7187. return pamScheme;
  7188. }
  7189. }
  7190.  
  7191. return null;
  7192. }
  7193.  
  7194. /**
  7195. * Gets the first PAM service id in the range 0-99 which is not used (any more) in the assigned PAM schemes.
  7196. *
  7197. * @return free PAM scheme
  7198. */
  7199. protected ContractPamScheme getFreePamScheme()
  7200. {
  7201. Vector<ContractPamScheme> pamSchemes = getPamSchemes();
  7202. int size = pamSchemes.size();
  7203.  
  7204. if (size == 100)
  7205. {
  7206. // no free PAM service id exists
  7207. throw new ComponentException("CMS.Contract.NoFreePAMServiceIdAwailable", getIDI(), getPublicKeyI());
  7208. }
  7209.  
  7210. ContractPamScheme newPamScheme = null;
  7211.  
  7212. Vector<ContractPamScheme> pamSchemesFree = getPamSchemesFree();
  7213. int sizeFree = pamSchemesFree.size();
  7214.  
  7215. if (sizeFree == 0)
  7216. {
  7217. newPamScheme = AbstractFactory.createObject(ContractPamScheme.class);
  7218. newPamScheme.setContract(this);
  7219. newPamScheme.setPamServiceId(size);
  7220. }
  7221. else
  7222. {
  7223. newPamScheme = pamSchemesFree.remove(0);
  7224. FWValueHolder.setValue(_pamSchemesFree, pamSchemesFree, this);
  7225. }
  7226.  
  7227. pamSchemes.add(newPamScheme);
  7228. FWValueHolder.setValue(_pamSchemes, pamSchemes, this);
  7229.  
  7230. return newPamScheme;
  7231. }
  7232.  
  7233. /**
  7234. * Registers or unregisters a PAM scheme.
  7235. *
  7236. * @param pPamClass
  7237. * @param pPamSchedule
  7238. * @param pDelete
  7239. * @return
  7240. */
  7241. public ContractPamScheme registerPamScheme(PamClass pPamClass, PamSchedule pPamSchedule, boolean pDelete)
  7242. {
  7243. int number = pDelete ? -1 : 1;
  7244.  
  7245. if (null == pPamSchedule)
  7246. {
  7247. pPamSchedule = getPamScheduleFromBillCycle();
  7248. }
  7249.  
  7250. ContractPamScheme pamScheme = getPamScheme(pPamClass, pPamSchedule);
  7251.  
  7252. if (pamScheme == null)
  7253. {
  7254. if (pDelete)
  7255. {
  7256. return null;
  7257. }
  7258.  
  7259. pamScheme = getFreePamScheme();
  7260. }
  7261. else if (!pamScheme.isCloneForUpdate())
  7262. {
  7263. pamScheme = pamScheme.getInstanceForUpdate();
  7264. }
  7265.  
  7266. pamScheme.setPamClassPending(pPamClass);
  7267. pamScheme.setPamSchedulePending(pPamSchedule);
  7268.  
  7269. int counter = pamScheme.getCounter();
  7270. int counterPending = pamScheme.getCounterPending();
  7271.  
  7272. if (!NullConversion.isNull(counterPending))
  7273. {
  7274. pamScheme.setCounterPending(counterPending + number);
  7275. }
  7276. else if (!NullConversion.isNull(counter))
  7277. {
  7278. pamScheme.setCounterPending(counter + number);
  7279. }
  7280. else
  7281. {
  7282. pamScheme.setCounterPending(number);
  7283. }
  7284.  
  7285. pamScheme.setTaskI(null);
  7286. return pamScheme;
  7287. }
  7288.  
  7289. /**
  7290. * Registers the PAM scheme for the purpose 'BillCycle'.
  7291. *
  7292. * @param pPamClass
  7293. * @param pPamSchedule
  7294. * @param pCpe
  7295. */
  7296. private ContractPamScheme registerPamSchemeBillCycle(PamClass pPamClass, PamSchedule pPamSchedule, boolean pDelete)
  7297. {
  7298. boolean isChanged = false;
  7299. ContractPamScheme pamScheme = getPamSchemeBillCycle();
  7300.  
  7301. if (pamScheme == null)
  7302. {
  7303. if (!pDelete)
  7304. {
  7305. pamScheme = getFreePamScheme();
  7306. pamScheme.setCounterPending(1);
  7307. pamScheme.setPamClassPending(pPamClass);
  7308. pamScheme.setPamSchedulePending(pPamSchedule);
  7309. isChanged = true;
  7310. }
  7311. }
  7312. else
  7313. {
  7314. if (pDelete
  7315. || pamScheme.getPamClass() == null || pamScheme.getPamClass().getIDI() != pPamClass.getIDI()
  7316. || pPamSchedule == null && pamScheme.getPamSchedule() != null
  7317. || pPamSchedule != null && (pamScheme.getPamSchedule() == null
  7318. || pamScheme.getPamSchedule().getIDI() != pPamSchedule.getIDI()))
  7319. {
  7320. if (!pamScheme.isCloneForUpdate())
  7321. {
  7322. pamScheme = pamScheme.getInstanceForUpdate();
  7323. }
  7324.  
  7325. pamScheme.setPamClassPending(pPamClass);
  7326. pamScheme.setPamSchedulePending(pPamSchedule);
  7327. pamScheme.setCounterPending(pDelete ? 0 : 1);
  7328. isChanged = true;
  7329. }
  7330. }
  7331.  
  7332. if (isChanged)
  7333. {
  7334. pamScheme.setTaskI(null);
  7335. return pamScheme;
  7336. }
  7337.  
  7338. return null;
  7339. }
  7340.  
  7341. /**
  7342. * 377727_E08_U16
  7343. * Register all schemes which are affected by a PAM default Schedule change
  7344. *
  7345. * @param pPamClass
  7346. * @param pPamSchedule
  7347. * @param pCpe
  7348. */
  7349. protected void registerPamScheduleChanges(PamSchedule pNewPamSchedule, ContractedProductElement pCpe)
  7350. {
  7351.  
  7352. Vector<ContractPamScheme> pamSchemes = getPamSchemes();
  7353.  
  7354. for (ContractPamScheme pamScheme : pamSchemes)
  7355. {
  7356. int pendingCounter = pamScheme.getCounterPending();
  7357. int currentCounter = pamScheme.getCounter();
  7358.  
  7359. if (pamScheme.getPamClassPending() != null)
  7360. {
  7361. if (pendingCounter == 0)
  7362. {
  7363. // check if another PAM scheme exists with the new PAM schedule ...
  7364. ContractPamScheme existingPamScheme = getPamSchemeCurrent(pamScheme.getPamClass(), pNewPamSchedule);
  7365. if (null == existingPamScheme)
  7366. {
  7367. // .. if not, the complete scheme has changed e.g. in case of the PAM info service
  7368. // to indicate this to GMD, reset pending to current counter and set new PAM schedule pending
  7369. pamScheme.setCounterPending(currentCounter);
  7370. pamScheme.setPamSchedulePending(pNewPamSchedule);
  7371. }
  7372. }
  7373. else if (pendingCounter < currentCounter)
  7374. {
  7375. // new PAM scheme might be created ...
  7376. ContractPamScheme newPamScheme = registerPamScheme(pamScheme.getPamClass(), pNewPamSchedule, false);
  7377. int newPendingCounter = newPamScheme.getCounterPending();
  7378. // ... if the scheme already exists it contains the correct counterPending value
  7379. // but if it is new its counter is '0'. In this case the new scheme gets services the old scheme has lost.
  7380. if (newPendingCounter == 0)
  7381. {
  7382. newPamScheme.setCounterPending(currentCounter - pendingCounter);
  7383. }
  7384.  
  7385. pCpe.getProvisionableChildrenList().add(newPamScheme);
  7386. }
  7387.  
  7388. pamScheme.setTaskI(null);
  7389. }
  7390. }
  7391. }
  7392.  
  7393. /**
  7394. * 377727_E08_U16
  7395. * Count Schemes which are affected by the PAM Schedule Change
  7396. *
  7397. * @param pPamClass
  7398. * @param pPamSchedule
  7399. * @param pCpe
  7400. */
  7401. protected void countPamScheduleChange(PamClass pPamClass, PamSchedule pOldPamSchedule, PamSchedule pNewPamSchedule, ContractedProductElement pCpe)
  7402. {
  7403. // check for an existing PAM scheme and decrease its pending counter if the new PAM Schedule is different from the old one
  7404. if ((pOldPamSchedule != null && pNewPamSchedule == null) || (pOldPamSchedule == null && pNewPamSchedule != null)
  7405. || (pOldPamSchedule != null && pNewPamSchedule != null && (pOldPamSchedule.getIDI() != pNewPamSchedule.getIDI())))
  7406. {
  7407. ContractPamScheme pamOldScheme = getPamSchemeCurrent(pPamClass, pOldPamSchedule);
  7408.  
  7409. if (pamOldScheme != null)
  7410. {
  7411. // this scheme is affected -> set the pending values
  7412. pamOldScheme.setPamClassPending(pPamClass);
  7413. pamOldScheme.setPamSchedulePending(pOldPamSchedule);
  7414.  
  7415. // decrease and set new pending counter
  7416. int counterPending = pamOldScheme.getCounterPending();
  7417. if (NullConversion.isNull(counterPending))
  7418. {
  7419. counterPending = pamOldScheme.getCounter();
  7420. }
  7421. counterPending -= 1;
  7422. pamOldScheme.setCounterPending(counterPending);
  7423.  
  7424. pCpe.getProvisionableChildrenList().add(pamOldScheme);
  7425. }
  7426. }
  7427.  
  7428. // increase the pending counter for existing schemes
  7429. ContractPamScheme pamNewScheme = getPamSchemeCurrent(pPamClass, pNewPamSchedule);
  7430.  
  7431. if (pamNewScheme != null)
  7432. {
  7433. // scheme is affected
  7434. pamNewScheme.setPamClassPending(pPamClass);
  7435. pamNewScheme.setPamSchedulePending(pNewPamSchedule);
  7436.  
  7437. int newCounterPending = pamNewScheme.getCounterPending();
  7438. if (NullConversion.isNull(newCounterPending))
  7439. {
  7440. if (pamNewScheme.getPamClass() == null)
  7441. {
  7442. newCounterPending = 0; // this is a real new PAM Scheme
  7443. }
  7444. else {
  7445. newCounterPending = pamNewScheme.getCounter(); // the Scheme already exists
  7446. }
  7447. }
  7448. newCounterPending += 1;
  7449. pamNewScheme.setCounterPending(newCounterPending);
  7450.  
  7451. pCpe.getProvisionableChildrenList().add(pamNewScheme);
  7452. }
  7453. }
  7454.  
  7455. /**
  7456. * Registers the PAM scheme for the purpose 'BillCycle'.
  7457. *
  7458. * @param pPamClass
  7459. * @param pPamSchedule
  7460. * @param pCpe
  7461. */
  7462. protected void registerPamSchemeBillCycle(PamClass pPamClass, PamSchedule pPamSchedule, ContractedProductElement pCpe)
  7463. {
  7464. ContractPamScheme pamScheme = null;
  7465.  
  7466. if (pPamClass == null)
  7467. {
  7468. // PAM Info service is being removed. The PAM scheme must be removed, too.
  7469. pamScheme = registerPamSchemeBillCycle(null, null, true);
  7470. }
  7471. else
  7472. {
  7473. pamScheme = registerPamSchemeBillCycle(pPamClass, pPamSchedule, false);
  7474. }
  7475.  
  7476. if (pamScheme != null)
  7477. {
  7478. pCpe.getProvisionableChildrenList().add(pamScheme);
  7479. }
  7480. }
  7481.  
  7482. /**
  7483. * Searches for the assigned PAM scheme with PAM purpose 'BillCycle'.
  7484. *
  7485. * @return
  7486. */
  7487. public ContractPamScheme getPamSchemeBillCycle()
  7488. {
  7489. Vector<ContractPamScheme> pamSchemes = getPamSchemes();
  7490.  
  7491. for (ContractPamScheme pamScheme : pamSchemes)
  7492. {
  7493. if (pamScheme.getPamClass() != null && pamScheme.getPamClass().getPamPurpose().isBillCycle()
  7494. || pamScheme.getPamClass() == null
  7495. && pamScheme.getPamClassPending() != null && pamScheme.getPamClassPending().getPamPurpose().isBillCycle())
  7496. {
  7497. return pamScheme;
  7498. }
  7499. }
  7500.  
  7501. return null;
  7502. }
  7503.  
  7504. /**
  7505. * Refreshes the contract's PAM schemes.
  7506. */
  7507. protected void refreshPamSchemes()
  7508. {
  7509. List<ContractPamScheme> pamSchemes = this.getPamSchemes();
  7510. for (ContractPamScheme pam : pamSchemes)
  7511. {
  7512. if (pam.isPending())
  7513. {
  7514. pam.refreshObject();
  7515. }
  7516. }
  7517.  
  7518. ArrayList<Long> lParams = new ArrayList<Long>(1);
  7519. lParams.add(Long.valueOf(_id));
  7520. Vector<ContractPamScheme> pamSchemesFree = AbstractFactory.readObjectsByQueryI(
  7521. ContractPamScheme.class, PContractPamScheme.READ_CONTRACT_PAM_SCHEMES_FREE, lParams);
  7522. // FWValueHolder.setValue( _pamSchemesFree, pamSchemesFree, this );
  7523. _pamSchemesFree.setValue(pamSchemesFree);
  7524. }
  7525.  
  7526. /**
  7527. * Checks whether the contract has pending PAM schemes.
  7528. */
  7529. protected boolean hasPendingPamScheme()
  7530. {
  7531. Vector<ContractPamScheme> pamSchemes = getPamSchemes();
  7532.  
  7533. for (ContractPamScheme pamScheme : pamSchemes)
  7534. {
  7535. if (pamScheme.isPending())
  7536. {
  7537. return true;
  7538. }
  7539. }
  7540.  
  7541. return false;
  7542. }
  7543.  
  7544. /**
  7545. * Gets the PAM Schedule from the contract holder's bill cycle.
  7546. *
  7547. */
  7548. public PamSchedule getPamScheduleFromBillCycle()
  7549. {
  7550. return getContractHolderI().getCustomerAccountI().getBillSpecificationI().getBillCycleI().getPamSchedule();
  7551. }
  7552.  
  7553. /**
  7554. * 377727_E08_U16
  7555. *
  7556. * @return Pam Schedule of Pam Info service if exists otherwise null
  7557. */
  7558. private PamSchedule getPamScheduleFromBillCycleScheme()
  7559. {
  7560. PamSchedule pamSchedule = null;
  7561. ContractPamScheme pamSchemeBillCycle = getPamSchemeBillCycle();
  7562.  
  7563. if (pamSchemeBillCycle != null)
  7564. {
  7565. pamSchedule = pamSchemeBillCycle.getPamSchedule();
  7566.  
  7567. if (null == pamSchedule)
  7568. {
  7569. pamSchedule = pamSchemeBillCycle.getPamSchedulePending();
  7570. }
  7571. }
  7572.  
  7573. return pamSchedule;
  7574. }
  7575.  
  7576. /**
  7577. * Returns shared account package assigments for a contract.
  7578. *
  7579. * @return list of shared account package assignments for a contract
  7580. */
  7581. public List<SharedAccountPackageAssignment> getSharedAccountPackageAssignments()
  7582. {
  7583. return FWValueHolder.getValue(_sharedAccountPackageAssignments);
  7584. }
  7585.  
  7586. /**
  7587. * Returns the list of current and future shared account package assignments.
  7588. * @return list of current and future shared account package assignments
  7589. */
  7590.  
  7591. public List<SharedAccountPackageAssignment> getActiveSharedAccountPackageAssignments()
  7592. {
  7593. return getActiveSharedAccountPackageAssignmentsFiltered(null);
  7594. }
  7595.  
  7596. /**
  7597. * Returns the list of current and future shared account package assignments.
  7598. * @param pFilter - defines if assignemnt of a specified role should be returned, null - no filtering
  7599. * @return list of current and future shared account package assignments matching the filter
  7600. */
  7601. public List<SharedAccountPackageAssignment> getActiveSharedAccountPackageAssignmentsFiltered(Role pFilter)
  7602. {
  7603. List<SharedAccountPackageAssignment> lActiveSharedAccountPackageAssignments = new ArrayList<SharedAccountPackageAssignment>();
  7604. List<SharedAccountPackageAssignment> lSharedAccountPackageAssignments = getSharedAccountPackageAssignments();
  7605.  
  7606. for (SharedAccountPackageAssignment sharedAccountAssignment : lSharedAccountPackageAssignments)
  7607. {
  7608. if (sharedAccountAssignment.isExpired())
  7609. {
  7610. continue;
  7611. }
  7612.  
  7613. if (pFilter != null)
  7614. {
  7615. if (pFilter.isOwner() && !sharedAccountAssignment.isOwner())
  7616. {
  7617. continue;
  7618. }
  7619. if (pFilter.isParticipant() && !sharedAccountAssignment.isParticipation())
  7620. {
  7621. continue;
  7622. }
  7623. }
  7624. lActiveSharedAccountPackageAssignments.add(sharedAccountAssignment);
  7625. }
  7626. return lActiveSharedAccountPackageAssignments;
  7627. }
  7628.  
  7629. /**
  7630. * Returns shared account package assigments for a contract.
  7631. * I.e. ownership assignments and participation assignemts for this contract.
  7632. * @param pSharedAccountPackageAssignments
  7633. */
  7634. public void setSharedAccountPackageAssignments(List<SharedAccountPackageAssignment> pSharedAccountPackageAssignments)
  7635. {
  7636. FWValueHolder.setValue(_sharedAccountPackageAssignments, pSharedAccountPackageAssignments, this);
  7637. }
  7638.  
  7639.  
  7640. /**
  7641. * Checks whether the contract is a shared account owner.
  7642. *
  7643. * @return <code>true</code> if the contract is a shared account owner; otherwise <code>false</code>
  7644. */
  7645. public boolean isSharedAccountPackageOwner()
  7646. {
  7647. List<SharedAccountPackageAssignment> lSharedAccountPackageAssignments = getActiveSharedAccountPackageAssignmentsFiltered(Role.OWNER);
  7648. return !lSharedAccountPackageAssignments.isEmpty();
  7649. }
  7650.  
  7651. /**
  7652. * Checks if contract can be deactivated from shared account package perspective
  7653. * If not, throws a ComponentException
  7654. */
  7655. private void checkSharedAccountPackageAssignmentsForContractDeactivation()
  7656. {
  7657. List<SharedAccountPackageAssignment> sharedAccountPackageAssignments = getActiveSharedAccountPackageAssignmentsFiltered(Role.OWNER);
  7658. for (SharedAccountPackageAssignment assignment : sharedAccountPackageAssignments)
  7659. {
  7660. if (assignment.hasParticipants())
  7661. {
  7662. throw new ComponentException( "CMS.Contract.DeactivationOfSharedAccountOwner", assignment.getSharedAccountPackage().getShdes());
  7663. }
  7664. }
  7665. }
  7666. /**
  7667. * Get contract extraction tag value, e.g. "Postpaid", "Prepaid".
  7668. *
  7669. * @param pExtractionIndicator
  7670. * the input contract extraction tag.
  7671. * @return String _extractionTag
  7672. */
  7673. public String getExtractionTag()
  7674. {
  7675. return _extractionTag;
  7676. }
  7677. /**
  7678. * Set contract extraction tag value, e.g. "Postpaid", "Prepaid". This extraction tag value will be maintained by operator, and
  7679. * will be used in TEH and GMD to decide whether the contract and relevent RDR should be extracted/generated and loaded into
  7680. * shared memory or not.
  7681. *
  7682. * @param pExtractionTag
  7683. * - the input contract extraction tag.
  7684. */
  7685. public void setExtractionTag(String pExtractionTag)
  7686. {
  7687. if (LicenseUtilsFacade.checkLicense(LicenseFeature.LHS_BSCS_DYNAMIC_CONFIGURATION_IN_TEH.getName()))
  7688. {
  7689. _extractionTag = pExtractionTag;
  7690. _extractionTagModifiedDate = ServerTime.getCurrentTime();
  7691. }
  7692. }
  7693.  
  7694. } // end of class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement