Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.lhs.Contract.bscs_core;
- ///////////////////////////////////////////////////////////////////////////////
- //Copyright (c) 2004 LHS Telekom GmbH & Co. KG
- //
- //The copyright in this work is vested in LHS. The information contained in
- //this work (either in whole or in part) is confidential and must not be
- //modified, reproduced, disclosed or disseminated to others or used for
- //purposes other than that for which it is supplied, without the prior
- //written permission of LHS. If this work or any part hereof is furnished to
- //a third party by virtue of a contract with that party, use of this work by
- //such party shall be governed by the express contractual terms between LHS,
- //which is party to that contract and the said party.
- //
- //The information in this document is subject to change without notice and
- //should not be construed as a commitment by LHS. LHS assumes no
- //responsibility for any errors that may appear in this document. With the
- //appearance of a new version of this document all older versions become
- //invalid.
- //
- //All rights reserved.
- ///////////////////////////////////////////////////////////////////////////////
- import java.math.BigDecimal;
- import java.sql.Timestamp;
- import java.util.*;
- import java.util.logging.Level;
- import org.eclipse.persistence.descriptors.RelationalDescriptor;
- import org.eclipse.persistence.expressions.Expression;
- import org.eclipse.persistence.expressions.ExpressionBuilder;
- import org.eclipse.persistence.indirection.ValueHolder;
- import org.eclipse.persistence.indirection.ValueHolderInterface;
- import org.eclipse.persistence.queries.DirectReadQuery;
- import com.lhs.ccb.func.ect.ComponentException;
- import com.lhs.ccb.func.ect.SystemException;
- import com.lhs.ccb.func.ect.ValidationException;
- import com.lhs.ccb.sfw.application.AbstractFactory;
- import com.lhs.ccb.sfw.application.ServiceContext;
- import com.lhs.ccb.sfw.domain.AbstractDomainObject;
- import com.lhs.ccb.sfw.domain.AbstractDomainObjectI;
- import com.lhs.ccb.sfw.domain.TransactionContext;
- import com.lhs.ccb.sfw.license.LicenseInitializer;
- import com.lhs.ccb.sfw.license.LicenseInitializer.LicenseFeature;
- import com.lhs.ccb.sfw.license.LicenseUtilsFacade;
- import com.lhs.ccb.sfw.persistence.FWPrimaryKeyFactory;
- import com.lhs.ccb.sfw.persistence.FWValueHolder;
- import com.lhs.ccb.sfw.utilities.CAASDateConverter;
- import com.lhs.ccb.sfw.utilities.CAASTimeConverter;
- import com.lhs.ccb.sfw.utilities.NullConversion;
- import com.lhs.ccb.sfw.utilities.ServerTime;
- import com.lhs.Billing.bscs_core.BillMedium;
- import com.lhs.Billing.bscs_core.BillingAccount;
- import com.lhs.Billing.bscs_core.BillingAccountAssignment;
- import com.lhs.Billing.bscs_core.external.BillingAccountI;
- import com.lhs.Billing.bscs_core.external.BillingAdministratorI;
- import com.lhs.BusinessPartner.bscs_core.*;
- import com.lhs.BusinessPartner.bscs_core.external.CustomerOrgNodeI;
- import com.lhs.BusinessPartner.bscs_core.external.DealerOrgNodeI;
- import com.lhs.BusinessPartner.bscs_core.external.OrgNodeI;
- import com.lhs.BusinessPartner.bscs_core.external.OrgNodeStatusI;
- import com.lhs.BusinessPartnerEventManagement.bscs_core.BusinessPartnerEventManagementAdministrator;
- import com.lhs.BusinessPartnerEventManagement.bscs_core.BusinessPartnerEventMessage;
- import com.lhs.BusinessPartnerEventManagement.bscs_core.external.BusinessPartnerEventMessageI;
- import com.lhs.BusinessPartnerEventManagement.bscs_core.external.NLSSystemEventMessageDefinitionI;
- import com.lhs.BusinessPartnerEventManagement.bscs_core.external.SystemEventMessageDefinitionI;
- import com.lhs.CommonDomain.Parameter.bscs_core.Parameter;
- import com.lhs.CommonDomain.Parameter.bscs_core.ParameterValueNode;
- import com.lhs.CommonDomain.Parameter.bscs_core.external.ParameterValueNodeI;
- import com.lhs.CommonDomain.bscs_core.BusinessUnit;
- import com.lhs.CommonDomain.bscs_core.CMSUser;
- import com.lhs.CommonDomain.bscs_core.DomainService;
- import com.lhs.CommonDomain.bscs_core.external.GMDActionI;
- import com.lhs.CommonDomain.bscs_core.external.KeyValueI;
- import com.lhs.CommonDomain.bscs_core.external.LogicalI;
- import com.lhs.CommonDomain.bscs_core.external.ReasonI;
- import com.lhs.Contract.bscs_core.SharedAccountPackageAssignment.Role;
- import com.lhs.Contract.bscs_core.external.*;
- import com.lhs.Contract.bscs_core.persistence.PContractPamScheme;
- import com.lhs.FrameworkExtension.bscs_core.NLSAdministrator;
- import com.lhs.FrameworkExtension.bscs_core.PluginAdministrator;
- import com.lhs.FrameworkExtension.bscs_core.PluginEvent;
- import com.lhs.Pricing.bscs_core.external.PricingSchemeI;
- import com.lhs.Product.bscs_core.*;
- import com.lhs.Product.bscs_core.external.*;
- import com.lhs.Product.bscs_core.persistence.PPamClass;
- import com.lhs.Resource.bscs_core.Attributes;
- import com.lhs.Resource.bscs_core.PhoneNumber;
- import com.lhs.Resource.bscs_core.PhoneNumberPortingInformation;
- import com.lhs.Resource.bscs_core.ResourceAdministrator;
- import com.lhs.Resource.bscs_core.external.*;
- import com.lhs.TaskManagement.bscs_core.*;
- import com.lhs.TaskManagement.bscs_core.external.ActionDetailsI;
- import com.lhs.TaskManagement.bscs_core.external.TaskI;
- import com.lhs.TaskManagement.bscs_core.external.TaskTypeI;
- import com.lhs.Topology.bscs_core.Instance;
- import com.lhs.Topology.bscs_core.Network;
- import com.lhs.Topology.bscs_core.TopologyAdministrator;
- import com.lhs.Topology.bscs_core.external.PrepaidProfileI;
- import com.lhs.Topology.bscs_core.external.TechnologyI;
- import com.lhs.Topology.bscs_core.external.TelecomTechnologyI;
- import com.lhs.cms.AdministratorFactory;
- import com.lhs.cms.billing.domain.BillingAccountAssignmentTemplateRule;
- /**
- * File : Contract.java
- * Classes : Contract
- * Interfaces : None
- *
- * @author C.Kaiser
- */
- public class Contract extends AbstractDomainObject implements ContractI
- {
- /**
- * Constant for the jWhat tool, do not delete or modify.
- */
- @SuppressWarnings("hiding")
- public final static String WHAT_ID = "%Z%%W%, %I%, %E%";
- /**
- * Reference to the contract type.
- * CONTRACT_ALL.CONTRACT_TYPE_ID
- */
- ValueHolderInterface _contractType = new ValueHolder();
- /**
- * Date, the TIMM has been generated. Linked to CONTRACT_ALL.PRODUCT_HISTORY_DATE
- */
- protected java.sql.Timestamp _timmGenerationDate = NullConversion.TIMESTAMP_NULL_VALUE;
- /**
- * Date, when the contract will be canceled prospectivly. Linked to CONTRACT_ALL.CO_EXPIR_DATE
- */
- protected java.sql.Timestamp _expirationDate = NullConversion.TIMESTAMP_NULL_VALUE;
- /**
- * PrimaryKey of the contract.
- * Linked to CONTRACT_ALL.CO_ID (CustomerContract)
- */
- public long _id = NullConversion.LONG_NULL_VALUE;
- /**
- * Counter for multiuser access Linked to CONTRACT_ALL.REC_VERSION
- */
- protected java.math.BigDecimal _recordVersion = INIT_REC_VERSION;
- /**
- * External key of the contract
- * Linked to CONTRACT_ALL.CO_CODE
- */
- protected String _code = NullConversion.STRING_NULL_VALUE;
- /**
- * Type of Contract: 'S' -> sales contract (normal customer contract) 'A' -> Agreement contract Linked to CONTRACT_ALL.TYPE
- */
- protected String _type = NullConversion.STRING_NULL_VALUE;
- /**
- * agreement type
- * "SP": Service Provider Agreement
- * "IC": Inter-exchange Carrier Agreement
- * "EC": Exchange Carrier Agreement
- * "RA": Roaming Agreement
- * "CA": CIBER Roaming Agreement
- * "DC": Dealer agreement (new value because dealer contract do not exist in previous releases)
- * "MO": MVNO agreement
- * "CP": content provider
- * "": other kind of contract
- * Linked to CONTRACT_ALL.AGREEMENT_TYPE (still needed on db level but not exposed through the SOI)
- */
- protected String _agreementType = NullConversion.STRING_NULL_VALUE;
- /**
- * Date, the contract has been signed.
- * Linked to CONTRACT_ALL.CO_SIGNED (CustomerContract)
- */
- protected Date _signingDate = NullConversion.DATE_NULL_VALUE;
- /**
- * Date, when the contract has been entered.
- * Linked to CONTRACT_ALL.CO_ENTDATE (CustomerContract)
- */
- protected Date _creationDate = NullConversion.DATE_NULL_VALUE;
- /**
- * _statusValidFromDate
- * Date, when the status change will be valid
- * Linked to CONTRACT_ALL.CH_STATUS_VALIDFROM
- */
- protected Timestamp _statusValidFromDate = NullConversion.TIMESTAMP_NULL_VALUE;
- /**
- * _contractHolder- used as second party
- * Business partner, to which this contract is assigned
- * Linked to CONTRACT_ALL.CUSTOMER_ID (CustomerContract)
- *
- * @see com.lhs.BusinessPartner.bscs_core.OrgNode
- */
- protected ValueHolderInterface _contractHolder = new ValueHolder();
- /**
- * The first contract holder
- */
- protected ValueHolderInterface _firstContractHolder = new ValueHolder();
- /**
- * Internal class holding references to all ContractSections
- * assigned to the contract.
- *
- * @see com.lhs.Contract.bscs_core.CompositeContractSection
- */
- protected CompositeContractSection _compositeContractSection;
- /**
- * the id of the business unit the contract is assigned to
- */
- protected long _businessUnitId = NullConversion.LONG_NULL_VALUE;
- /**
- * description of the contract
- */
- protected String _description = NullConversion.STRING_NULL_VALUE;
- /**
- * Date, the contract has been activated for the first time. Linked to CONTRACT_ALL.CO_ACTIVATED
- */
- protected java.sql.Timestamp _activationDate = NullConversion.TIMESTAMP_NULL_VALUE;
- /**
- * Date, when the contract has been modified for the last time. Linked to CONTRACT_ALL.CO_MODDATE
- */
- protected java.sql.Timestamp _modificationDate = NullConversion.TIMESTAMP_NULL_VALUE;
- /**
- * Name of the user, who has modified the contract for the last time. Linked to CONTRACT_ALL.CO_USERLASTMOD
- */
- protected String _userOfLastModification = NullConversion.STRING_NULL_VALUE;
- /**
- * Internal class holding track of all action necessary to
- * send to the GMD. Only needed if a clone is created, because
- * only a clone can initiate new GMD actions!
- *
- * @see com.lhs.Contract.bscs_core.ContractTaskHandler
- */
- protected transient ContractTaskHandler _contractTaskHandler;
- /**
- * Identifier returned from an external provisioning subsystem. Linked to CONTRACT_ALL.CO_EXT_CSUIN (BSCS v5.x)
- */
- protected String _externalContractReferenceNo = NullConversion.STRING_NULL_VALUE;
- /**
- * Name of the representative for the contract. Linked to CONTRACT_ALL.CO_REP
- */
- protected String _nameOfContractRepresentative = NullConversion.STRING_NULL_VALUE;
- /**
- * Identification number of the representative of the contract. Linked to CONTRACT_ALL.CO_REP_IDNO
- */
- protected String _idOfContractRepresentative = NullConversion.STRING_NULL_VALUE;
- /**
- * Reference to the ContractStatus object which holds
- * the current state of the contract
- */
- protected transient ContractStatus _currentStatus;
- /**
- * Reference to the ContractStatus object which holds
- * the pending state for the contract
- */
- protected transient ContractStatus _pendingStatus;
- /**
- * Flag indicating wether the document for contract confirmation is already generated -> 'X'
- * otherwise -> NULL.
- * mapped to CONTRACT_ALL.CO_CONFIRM
- */
- protected String _confirmationGenerated = NullConversion.STRING_NULL_VALUE;
- /**
- * Flag indicating wether the data hasn't been validated by the application -> X,
- * otherwise -> NULL.
- * An X is only allowed if CURR_CO_STATUS.CH_STATUS="o".
- * mapped to CONTRACT_ALL.NOT_VALID
- */
- protected String _notValidated = NullConversion.STRING_NULL_VALUE;
- /**
- * Flag indicating wether services have been assigned to the contract -> 'Y'
- * otherwise -> NULL.
- * mapped to CONTRACT_ALL.CO_ASS_SERV
- */
- protected String _servicesAssigned = NullConversion.STRING_NULL_VALUE;
- /**
- * Reference to the stati of this contract
- * Linked via CO_ID
- */
- protected ValueHolderInterface _contractStati = new ValueHolder(new Vector<ContractStatus>(6));
- /**
- * Type of the contract regarding to be AL, main or regular
- * Domain: 'R' - Related,'M' - Main, null - Regular.
- * Used by feature 84834 - Alternate Line
- * Linked to CONTRACT_ALL.CO_REL_TYPE
- */
- protected String _relationType = NullConversion.STRING_NULL_VALUE;
- /**
- * Transaction id for the contract creation. Used on install subscriber job.
- * Linked to CONTRACT_ALL.TRANSACTION_ID
- */
- private long _transactionId = NullConversion.LONG_NULL_VALUE;
- /**
- * Constants used to set the type of the relation
- * <ul>
- * <li>'R' - Related</li>
- * <li>'M' - Main</li>
- * <li>null - Regular</li>
- * </ul>
- *
- * @since feature 84834 - Alternate Line
- */
- public final static String REGULAR = NullConversion.STRING_NULL_VALUE;
- /**
- * Constant for Main contract.
- */
- public final static String MAIN = "M";
- /**
- * Constant for Related contract.
- */
- public final static String RELATED = "R";
- // --> defect 229631-1 NIJ
- // - holder for dependent contract in case of contract takeover
- private transient Contract _dependentContract;
- // <-- 229631
- // USc#252804 we need only one indicator
- private transient boolean _isTakeoverContract;
- // --> defect 233846 NIJ
- private transient ContractedProductElementLock _contractedProductElementsLock;
- // <-- 233846
- /**
- * SB : get modes for balances
- */
- public final static int GETBAL_ACT_ONLY = 1;
- /**
- * Constant for balance get mode for onhold services.
- */
- public final static int GETBAL_ACT_ONHOLD = 2;
- /**
- * Constant for get mode for all balances.
- */
- public final static int GETBAL_ALL = 3;
- /**
- * Constant for customer contract type.
- */
- public final static String CUSTOMER_TYPE = "C";
- /**
- * Constant for agreement contract type.
- */
- public final static String AGREEMENT_TYPE = "A";
- /**
- * Constant for template contract type.
- */
- public final static String TEMPLATE_TYPE = "T";
- /**
- * Constant for content provider contract type.
- */
- public final static String CONTENTPROVIDER_TYPE = "B";
- /**
- * Constant for sales contract type.
- */
- public final static String SALES_TYPE = "S";
- /**
- * This attribute contains the trial period start date.
- */
- protected Date _trialPeriodStartDate;
- /**
- * Date, when the trial period of the contract will end.
- * Linked to CONTRACT_ALL.TRIAL_END_DATE (CustomerContract)
- */
- protected Date _trialPeriodEndDate;
- /**
- * This attribute contains the BusinessPartnerOrgNode.
- */
- protected ValueHolderInterface _dealer = new ValueHolder();
- /**
- * This attribute contains the foreign Network.
- */
- protected ValueHolderInterface _foreignNetwork = new ValueHolder();
- // FSP 345205, Interconnect partner, MCH 09.08.2010
- // /**
- // * This attribute contains the Order limit.
- // */
- // protected ValueHolderInterface _carrier = new ValueHolder();
- // end FSP 345205, Interconnect partner, MCH 09.08.2010
- /**
- * Linked to CONTRACT_ALL.EARLIEST_END_DATE (CustomerContract)
- */
- protected Date _earliestContractEndDate = NullConversion.DATE_NULL_VALUE;
- /**
- * Reference to the porting request of this contract
- * Linked via CO_ID
- */
- protected ValueHolderInterface _portingRequest = new ValueHolder(new Vector<PortingRequest>(1));
- /**
- * Flag which indicates if this contract is a template for preactivated prepaid cards - see feat. 202820_3 Maps to
- * CONTRACT_ALL.CONTRACT_TEMPLATE
- */
- protected String _prepaidContractTemplate = NullConversion.STRING_NULL_VALUE;
- /**
- * indicates if call detail statement should be generated. possible values:
- * R: on request
- * P: Periodically
- * null (CHAR_NULL_VALUE): no call detail statement is to be generated.
- */
- protected char _callDetail = NullConversion.CHAR_NULL_VALUE;
- /**
- * Constant value whether a call detail statement is created on request.
- */
- public static final char CALL_DETAIL_STMT_ON_REQUEST = 'R';
- /**
- * Constant value whether a call detail statement is created periodically.
- */
- public static final char CALL_DETAIL_STMT_PERIODICALLY = 'P';
- /**
- * indicates if user/installation address should be printed on the call detail instead of bill detail address
- */
- protected String _useUserInstallationAddress = NullConversion.STRING_NULL_VALUE;
- /**
- * Bill Medium Id
- */
- protected long _billMediumId = NullConversion.LONG_NULL_VALUE;
- /**
- * Medium for notification messages.
- */
- protected long _notificationMediumId = NullConversion.LONG_NULL_VALUE;
- /**
- * Charging period adjustment period for services with charging schedule
- * set to "Cut off date related".
- * Domain:
- * 'B' - Billing period reference date
- * 'A' - Contract activation date
- */
- protected char _chargingPeriodAdjustmentReference = NullConversion.CHAR_NULL_VALUE;
- /**
- * Constant for setting the charging period adjustment reference
- * to the billing period reference date.
- */
- public static final char BILLING_PERIOD_REFERENCE_DATE = 'B';
- /**
- * Constant for setting the charging period adjustment reference
- * to the contract activation date.
- */
- public static final char CONTRACT_ACTIVATION_DATE = 'A';
- /**
- * The next charging period is the same for all contracted services
- * with charging schedule set to "Cut off date related".
- * This attribute defines the next cut off date. Read only!
- */
- protected Date _nextCutOffDate = NullConversion.DATE_NULL_VALUE;
- /**
- * The last charging period is the same for all contracted services
- * with charging schedule set to "Cut off date related".
- * This attribute defines the last cut off date. Read only!
- */
- protected Date _lastCutOffDate = NullConversion.DATE_NULL_VALUE;
- /**
- * The date at which a notification message has been generated.
- * Read only!
- */
- protected Date _lastNotificationDate = NullConversion.DATE_NULL_VALUE;
- /**
- * The charge start date.
- * Read only.
- */
- protected Date _chargeStartDate = NullConversion.DATE_NULL_VALUE;
- /**
- * Concurrent request handler
- * feature 00276491_cms
- */
- private transient ConcurrentRequestHandler _concurrentRequestHandler;
- /**
- * Indicates if the contract data shall be available on every rating node (is common reference data).
- * Mapped to CONTRACT_ALL.COMMON_REF_DATA_IND.
- */
- protected boolean _isCommonRefData = NullConversion.BOOLEAN_NULL_VALUE;
- private final ValueHolderInterface _contractedPromotionPlans = new ValueHolder(new Vector<ContractedPromotionPlan>());
- // FSP 288320, MCH 09.06.2008
- protected final static String TICKLER_RERATING_SHORT_DESC = "CO FOR RERATING";
- protected final static String TICKLER_CALLDETAIL_SHORT_DESC = "CC CHARGE";
- protected final static String TICKLER_RERATING_LONG_DESC_MARK = "Contract is marked for re-rating";
- protected final static String TICKLER_RERATING_LONG_DESC_UNMARK = "Contract is unmarked for re-rating";
- protected final static String TICKLER_STATUS_NOTE = "NOTE";
- /**
- * Indicates whether the contract is a candidate for re-rating
- * Linked to CONTRACT_ALL.RR_CANDIDATE
- */
- protected boolean _isReratingCandidate = NullConversion.BOOLEAN_NULL_VALUE;
- /**
- * Reference to the BillingContractLock object
- */
- protected ValueHolderInterface _billingLock = new ValueHolder();
- /**
- * TODO remove the value holder, Reference to the ReratingContractLock object
- */
- protected ValueHolderInterface _reratingLock = new ValueHolder();
- // end 288320, MCH 09.06.2008
- /** contract template from which this Contract has been created */
- //protected ValueHolderInterface _template = new ValueHolder();
- protected long _templateId=NullConversion.LONG_NULL_VALUE;
- /**
- * The current contract state.
- * mapped to CONTRACT_ALL.CH_STATUS
- */
- protected char _state = 'o';
- // 00377727_E08_U07
- /**
- * List of the PAM schemes assigned to the contract.
- */
- protected ValueHolderInterface _pamSchemes = new ValueHolder(new Vector<ContractPamScheme>());
- /**
- * List of the PAM schemes which are not used any more.
- */
- protected ValueHolderInterface _pamSchemesFree = new ValueHolder(new Vector<ContractPamScheme>());
- protected ValueHolderInterface _sharedAccountPackageAssignments = new ValueHolder(new Vector<SharedAccountPackageAssignment>());
- /**
- * Extraction tag of the contract to indicate whether the contract or relevant RDR
- * will be loaded into shared memory. This is introduced by PC 13899 (feature 00403569)
- * Linked to CONTRACT_ALL.EXTRACTION_TAG
- */
- protected String _extractionTag = NullConversion.STRING_NULL_VALUE;
- /**
- * Date, when the contract extraction tag has been modified for the last time.
- * Introduced by PC 13899 (feature 00403569)
- * Linked to CONTRACT_ALL.MODIFIED_TIMESTAMP
- */
- protected java.sql.Timestamp _extractionTagModifiedDate = NullConversion.TIMESTAMP_NULL_VALUE;
- /**
- * Constant for default value of contract extraction tag.
- */
- private final static String DEFAULT_EXTRACTION_TAG = "Postpaid";
- /**
- * Default constructor.
- * Initializes the ValueHolder used by TOPLink
- */
- public Contract()
- {
- super();
- }
- /**
- * Returns the expiration date.
- */
- @Override
- public int getExpirationDateI()
- {
- if (!this.isAgreementContract())
- {
- return CAASDateConverter.toCAASDate(_expirationDate);
- }
- return NullConversion.INT_NULL_VALUE;
- }
- /**
- * Returns the TIMM generation date.
- */
- @Override
- public long getTIMMGenerationDateI()
- {
- if (this.isAgreementContract())
- {
- return 0;
- }
- return CAASTimeConverter.toCAASTime(_timmGenerationDate);
- }
- /**
- * Sets the expiration date.
- */
- @Override
- public void setExpirationDateI(int pDate)
- {
- if (!this.isAgreementContract())
- {
- _expirationDate = CAASDateConverter.toTimestamp(pDate);
- }
- }
- /**
- * Set the TIMM generation date.
- *
- * @param pDate
- */
- public void setTIMMGenerationDate(long pDate)
- {
- _timmGenerationDate = CAASTimeConverter.toTimestamp(pDate);
- }
- /**
- * Set the date a status is valid from
- *
- * @param pDate
- */
- public void setStatusValidFromDate(Timestamp pDate)
- {
- _statusValidFromDate = pDate;
- }
- /**
- * Create and assign a new primary key to this (new) Contract instance. Additionaly creates a public key.
- *
- * @throws ComponentException
- */
- public void createUniqueId()
- throws ComponentException
- {
- /*
- * Retrieve the reference of the PrimaryKeyFactory
- */
- FWPrimaryKeyFactory pFactory = FWPrimaryKeyFactory.instance();
- // Create a private key
- _id = pFactory.getNewPKeyValue("MAX_CONTRACT_ID");
- registerPrimaryKeyValues(Long.valueOf(getIDI()));
- }
- /**
- * Links to the database mapping as described in PContract.
- *
- * @return the mapping descriptor.
- * @throws ComponentException
- * @see com.lhs.Contract.bscs_core.persistence.PContract
- */
- public static RelationalDescriptor descriptor()
- throws ComponentException
- {
- return lookupDescriptor(com.lhs.Contract.bscs_core.persistence.PContract.class);
- }
- /**
- * Gets the contract type
- *
- * @return contract type
- */
- public ContractType getContractType()
- {
- return (ContractType) _contractType.getValue();
- }
- /**
- * Sets the contract type
- *
- * @param pContractType
- * @throws ComponentException
- * @throws ValidationException
- */
- public void setContractType(ContractType pContractType) throws ValidationException, ComponentException
- {
- FWValueHolder.setValue(_contractType, pContractType, this);
- if (pContractType == null)
- {
- _agreementType = NullConversion.STRING_NULL_VALUE;
- }
- else
- {
- String lShortName = pContractType.getShortName();
- if (ContractType.SHNAME_NORPICIBER.equals(lShortName) ||
- ContractType.SHNAME_NORPICIBERCH.equals(lShortName) ||
- ContractType.SHNAME_NORPOCIBER.equals(lShortName) ||
- ContractType.SHNAME_NORPOCIBERCH.equals(lShortName))
- {
- _agreementType = "CA";
- setTypeI("A");
- }
- else if (ContractType.SHNAME_NORPITAP.equals(lShortName) ||
- ContractType.SHNAME_NORPOTAP.equals(lShortName))
- {
- _agreementType = "RA";
- setTypeI("A");
- }
- else if (ContractType.SHNAME_NOICI.equals(lShortName) ||
- ContractType.SHNAME_NOICO.equals(lShortName))
- {
- _agreementType = "IC";
- setTypeI("A");
- }
- else if (ContractType.SHNAME_NOECI.equals(lShortName) ||
- ContractType.SHNAME_NOECO.equals(lShortName))
- {
- _agreementType = "EC";
- setTypeI("A");
- }
- else if (ContractType.SHNAME_NOD.equals(lShortName))
- {
- _agreementType = "DC";
- setTypeI("A");
- }
- else if (ContractType.SHNAME_NOSP.equals(lShortName))
- {
- _agreementType = "SP";
- setTypeI("A");
- }
- else if (ContractType.SHNAME_NOCP.equals(lShortName))
- {
- _agreementType = "CP";
- setTypeI("A");
- }
- else if (ContractType.SHNAME_NOMVNO.equals(lShortName))
- {
- _agreementType = "MO";
- setTypeI("A");
- }
- else if (ContractType.SHNAME_NOST.equals(lShortName))
- {
- _agreementType = NullConversion.STRING_NULL_VALUE;
- // mark this as a template
- setPrepaidContractTemplate(true);
- setTypeI("T");
- }
- else
- {
- if (ContractType.SHNAME_NOS.equals(lShortName))
- {
- // 390089_E04_U07: reset reference to template if pre-activated contract is converted into a regular contract
- setTemplate(null);
- }
- _agreementType = NullConversion.STRING_NULL_VALUE;
- setTypeI("S");
- }
- if (this.isNew())
- {
- // Set the common reference data flag to the default defined at the contract type
- setIsCommonReferenceData(pContractType.isCommonReferenceData());
- }
- }
- }
- /**
- * Indicates if it is a customer contract.
- *
- * @return true if it is a cuatomer contract
- */
- @Override
- public boolean isCustomerContract()
- {
- ContractType contractType = this.getContractType();
- return contractType.isCustomerContractType();
- }
- /**
- * Indicates if it is an agreement contract.
- *
- * @return true if it is an agreement contract
- */
- @Override
- public boolean isAgreementContract()
- {
- ContractType contractType = this.getContractType();
- return contractType.isContractAgreementType();
- }
- /**
- * Indicates if it is an MVNO agreement contract.
- *
- * @return true if it is an MVNO agreement contract
- */
- public boolean isMVNOAgreementContract()
- {
- return ContractType.SHNAME_NOMVNO.equals(getContractType().getShortName());
- }
- /**
- * Indicates if it is a content provider contract.
- *
- * @return true if it is content provider contract
- */
- public boolean isContentProviderContract()
- {
- ContractType contractType = this.getContractType();
- return contractType.isContentProviderType();
- }
- /**
- * Retrieve all aggregated objects
- *
- * @return Vector
- */
- @Override
- public Vector<AbstractDomainObject> getAggregatedObjects()
- {
- /*
- * Retrieve the aggregated objects of the superclass
- */
- Vector<AbstractDomainObject> vector = super.getAggregatedObjects();
- /*
- * Instantiate the vector if necessary
- */
- if (vector == null)
- {
- vector = new Vector<AbstractDomainObject>(1);
- }
- /*
- * Check wether the according aggregated objects exist
- * and add them to the vector
- */
- if (_compositeContractSection != null)
- {
- /*
- * Add the aggregated object
- */
- vector.add(_compositeContractSection);
- }
- return vector;
- }
- /**
- * Returns the business unit id of the contract.
- * For performance reason only the id and not a valueholder to the object is implemented
- *
- * @return business unit id
- */
- @Override
- public long getBusinessUnitId()
- {
- return _businessUnitId;
- }
- /**
- * Returns the description of the contract.
- *
- * @return description
- */
- public String getDescription()
- {
- return _description;
- }
- /**
- * Returns the type of the contract.
- *
- * @return type
- */
- @Override
- public String getTypeI()
- {
- return _type;
- }
- /**
- * Returns the container instance holding references to all sections of a contract..
- * Creation date: (02/15/2001 1:32:16 PM)
- *
- * @author Ulrich Schaefer
- * @return com.lhs.Contract.bscs_core.AbstractCompositeContractSection
- */
- public CompositeContractSection getCompositeContractSection()
- {
- /*
- * return attribute
- */
- return _compositeContractSection;
- }
- /**
- * Gets the second party.
- *
- * @return com.lhs.BusinessPartner.bscs_core.external.OrgNodeI
- */
- @Override
- public OrgNodeI getContractHolderI()
- {
- return FWValueHolder.getValue(_contractHolder);
- }
- /**
- * Gets the first contract holder
- *
- * @return first party
- */
- public OrgNodeI getFirstContractHolderI()
- {
- return FWValueHolder.getValue(_firstContractHolder);
- }
- /**
- * Retrieves all different ContractSections, which are assigned to this Contract.
- *
- * @return Vector
- * @throws ComponentException
- * @throws ValidationException
- */
- @Override
- public Vector<ContractSectionI> getContractSectionsI()
- throws ComponentException, ValidationException
- {
- /*
- * Check whether there is a CompositeContractSection assigned
- * to this Contract
- */
- if (_compositeContractSection == null)
- {
- throw new IllegalArgumentException("Missing _compositeContractSection");
- }
- /*
- * Retrieve the ContractSections from the aggregated CompositeContractSection
- */
- return _compositeContractSection.getContractSections();
- }
- /**
- * Returns the date, this Contract has been entered.
- *
- * @return long
- */
- @Override
- public int getCreationDateI()
- {
- return CAASDateConverter.toCAASDate(_creationDate);
- }
- /**
- * Returns the DataExchangeSection of a Contract
- *
- * @return com.lhs.Contract.bscs_core.external.DataExchangeSectionI
- * @throws ComponentException
- * @throws ValidationException
- */
- @Override
- public DataExchangeSectionI getDataExchangeSectionI()
- throws ComponentException
- {
- /*
- * Check whether there is a CompositeContractSection assigned
- * to this Contract
- */
- if (_compositeContractSection == null)
- {
- throw new ComponentException("Contract.MissingContractSection", "CompositeContractSection");
- }
- /*
- * Forward the request to the compositeContractSection
- */
- return _compositeContractSection.getDataExchangeSection();
- }
- /**
- * Returns the primary key for the corresponding row in the db.
- *
- * @return long Primary key
- */
- @Override
- public long getIDI()
- {
- return _id;
- }
- /**
- * Returns the date, this Contract has been modified the last time.
- *
- * @return long
- */
- @Override
- public long getModificationDateI()
- {
- return CAASTimeConverter.toCAASTime(_modificationDate);
- }
- /**
- * Returns the user, who has altered this contract for the last time.
- *
- * @return String
- */
- @Override
- public String getUserOfLastModificationI()
- {
- return _userOfLastModification;
- }
- /**
- * Returns the date, this Contract has been activated.
- *
- * @return long
- */
- @Override
- public long getActivationDateI()
- {
- return CAASTimeConverter.toCAASTime(_activationDate);
- }
- // --> defect 286384 NiJ
- /**
- * Returns all active ContractedDNProperties currently assigned to the contract.
- *
- * @return Vector
- * @throws ComponentException
- */
- public List<ContractedDNPropertiesI> getActiveDNProperties()
- throws ComponentException
- {
- List<ContractedDNPropertiesI> lActiveConDNPropertiesList = new ArrayList<ContractedDNPropertiesI>(5);
- ContractedCompositeProduct lCCP = getContractedCompositeProduct();
- // get list of ContractedSimpleProduct's assigned to contract
- Vector<ContractedProductElement> lCPEList = lCCP.getContractedProductElements();
- if (!lCPEList.isEmpty())
- {
- // loop through the ContractedProductElement's, get each active ContractedDNProperties and store it
- Iterator<ContractedProductElement> lIterCPE = lCPEList.iterator();
- while (lIterCPE.hasNext())
- {
- ContractedProductElement lCPE = lIterCPE.next();
- Vector<ContractedDNPropertiesI> lActiveContrDNProps = lCPE.getContractedDNPropertiesNoDeactive();
- if (lActiveContrDNProps.size() > 0)
- {
- // add to result vector
- lActiveConDNPropertiesList.addAll(lActiveContrDNProps);
- }
- }
- }
- return lActiveConDNPropertiesList;
- }
- /**
- * Returns all active ContractedPortProperties currently assigned to the contract.
- *
- * @return Return all active contracted ports.
- * @throws ComponentException
- */
- public List<ContractedPortPropertiesI> getActivePortProperties()
- throws ComponentException
- {
- List<ContractedPortPropertiesI> lActiveConPortPropertiesList = new ArrayList<ContractedPortPropertiesI>(5);
- ContractedCompositeProduct lCCP = getContractedCompositeProduct();
- Vector<ContractedProductElement> lCPEList = lCCP.getContractedProductElements();
- if (!lCPEList.isEmpty())
- {
- // loop through the ContractedProductElement's, get each active ContractedPortProperties and store it
- Iterator<ContractedProductElement> lIterCPE = lCPEList.iterator();
- while (lIterCPE.hasNext())
- {
- ContractedProductElement lCPE = lIterCPE.next();
- Vector<ContractedPortPropertiesI> lAllContrPortProps = lCPE.getContractedPortPropertiesI();
- // its needed to filter the active ports only
- for (int i = 0; i < lAllContrPortProps.size(); i++)
- {
- ContractedPortPropertiesI lContrPortProp = lAllContrPortProps.get(i);
- if (NullConversion.isNull(lContrPortProp.getDeactivationDateI()))
- {
- // this port is active, add to new vector
- lActiveConPortPropertiesList.add(lContrPortProp);
- }
- }
- }
- }
- return lActiveConPortPropertiesList;
- }
- // <-- 286384
- /**
- * Returns the InvoiceSection of a Contract
- *
- * @return com.lhs.Contract.bscs_core.external.InvoiceSectionI
- * @throws ComponentException
- * @throws ValidationException
- */
- @Override
- public InvoiceSectionI getInvoiceSectionI()
- throws ComponentException
- {
- /*
- * Check whether there is a CompositeContractSection assigned
- * to this Contract
- */
- if (_compositeContractSection == null)
- {
- throw new ComponentException("Contract.MissingContractSection", "CompositeContractSection");
- }
- /*
- * Forward the request to the compositeContractSection
- */
- return _compositeContractSection.getInvoiceSection();
- }
- /**
- * getPaymentSectionI. Returns the PaymentSection of a Contract
- *
- * @return com.lhs.Contract.bscs_core.external.PaymentSectionI
- * @throws ComponentException
- * @throws ValidationException
- */
- @Override
- public PaymentSectionI getPaymentSectionI()
- throws ComponentException
- {
- /*
- * Check whether there is a CompositeContractSection assigned
- * to this Contract
- */
- if (_compositeContractSection == null)
- {
- throw new IllegalArgumentException("Missing _compositeContractSection");
- }
- /*
- * Forward the request to the compositeContractSection
- */
- return _compositeContractSection.getPaymentSection();
- }
- /**
- * Returns the ProductSection of a Contract
- *
- * @return com.lhs.Contract.bscs_core.external.ProductSectionI
- * @throws ComponentException
- * @throws ValidationException
- */
- @Override
- public ProductSectionI getProductSectionI()
- throws ComponentException
- {
- /*
- * Check whether there is a CompositeContractSection assigned
- * to this Contract
- */
- if (_compositeContractSection == null)
- {
- throw new IllegalArgumentException("Missing _compositeContractSection");
- }
- /*
- * Forward the request to the compositeContractSection
- */
- return _compositeContractSection.getProductSection();
- }
- /**
- * Returns the date, when this Contract has been signed by the contract holder.
- *
- * @return int
- */
- @Override
- public int getSigningDateI()
- {
- return CAASDateConverter.toCAASDate(_signingDate);
- }
- /**
- * Set the business unit id of the contract
- *
- * @param pBusinessUnitId
- * business unit id
- */
- public void setBusinessUnitId(long pBusinessUnitId)
- {
- checkBusinessUnitAssignment(pBusinessUnitId);
- _businessUnitId = pBusinessUnitId;
- }
- /**
- * Check whether business unit assignment is valid
- *
- * @param pBusinessUnitId
- * business unit id
- * @throws ComponentException
- * if business unit assignment is invalid
- */
- private void checkBusinessUnitAssignment(long pBusinessUnitId)
- {
- boolean hasMvnoLicense = ContractAdministrator.getInstance().getLicenseUtils().checkLicense(LicenseInitializer.LicenseFeature.LHS_BSCS_MVNO_SUPPORT.getName());
- // if MVNO support license not available
- if (!hasMvnoLicense)
- {
- BusinessUnit newBusinessUnit = BusinessUnit.getBusinessUnitById(pBusinessUnitId);
- // new contracts can only be assigned to the first dedicated business unit (representing the operator itself)
- if (isNew())
- {
- if (!newBusinessUnit.isFirstDedicated())
- {
- throw new ComponentException("CMA.CommonDomain.MVNONotSupported");
- }
- }
- // existing contracts cannot be moved from the first dedicated business to another business unit
- else
- {
- BusinessUnit oldBusinessUnit = BusinessUnit.getBusinessUnitById(getBusinessUnitId());
- if (oldBusinessUnit.isFirstDedicated() && !newBusinessUnit.isFirstDedicated())
- {
- throw new ComponentException("CMA.CommonDomain.MVNONotSupported");
- }
- }
- }
- }
- /**
- * Set the description of the contract
- *
- * @param pDescription
- */
- public void setDescription(String pDescription)
- {
- _description = pDescription;
- }
- /**
- * Set the business unit id of the contract to the business unit of the session
- *
- * @throws ComponentException
- * if an error occurs
- */
- public void setBusinessUnitId() throws ComponentException
- {
- long lBusinessUnitId = CMSUser.getCMSUser().checkCurrentBusinessUnit();
- setBusinessUnitId(lBusinessUnitId);
- }
- /**
- * Sets the date, when this contract has been signed by the contract holder
- *
- * @param pDate
- * int
- */
- @Override
- public void setSigningDateI(int pDate)
- {
- _signingDate = CAASDateConverter.toDate(pDate);
- }
- /**
- * Sets the date, when this contract has been activated for the first time
- *
- * @param pDate
- * long
- */
- @Override
- public void setActivationDateI(long pDate)
- {
- _activationDate = CAASTimeConverter.toTimestamp(pDate);
- }
- /**
- * TOPLink hook, called right before the INSERT statement.
- */
- @Override
- public void preInsert() throws ComponentException, ValidationException
- {
- // ensure that public key is always set
- setPublicKey(null);
- super.preInsert();
- }
- /**
- * Returns the public key of this instance.
- *
- * @return The public key.
- */
- public String getPublicKey()
- {
- return _code;
- }
- /**
- * Returns the public key of this instance.
- *
- * @return The public key.
- */
- @Override
- public String getPublicKeyI()
- {
- return _code;
- }
- /**
- * Set the public key value. The public key can be set only once, subsequental calls to this method are just ignored. If pPubKey
- * is null then default value will be taken from the database sequence "MAX_CO_CODE"
- *
- * @param pPubKey
- * a value to set, could be null
- * @throws ComponentException
- */
- public void setPublicKey(String pPubKey)
- throws ComponentException
- {
- if (NullConversion.isNull(_code))
- {
- if (!NullConversion.isNull(pPubKey))
- {
- _code = pPubKey;
- }
- else
- {
- // nothing is set - use default value from the stored procedure
- _code = FWPrimaryKeyFactory.instance().getNewPKeyValueAsString("MAX_CO_CODE");
- }
- }
- else
- {
- // if public key already set - just do nothing
- // public key can be set only once
- }
- }
- // From CustomerContract
- /**
- * Set the dependent contract. Used during a contract takeover operation.
- *
- * @param pContractI
- */
- public void setDependentContract(Contract pContractI)
- {
- if (isCustomerContract())
- {
- _dependentContract = pContractI;
- }
- }
- /**
- * Returns the dependent contract.
- *
- * @return The dependent contract.
- */
- public Contract getDependentContract()
- {
- if (isCustomerContract())
- {
- return _dependentContract;
- }
- return null;
- }
- /**
- * Checks whether this instance has request to be generated or not.
- *
- * @return true if tasks have to be generated.
- * @throws ValidationException
- * @throws ComponentException
- */
- public boolean areTasksGenerated() throws ValidationException, ComponentException
- {
- return getContractTaskHandler().areTaskRegistered();
- }
- /**
- * Return whether this is a takeover contract, that means, result of a takeover operation.
- *
- * @return true if the contract was created as result of takeover.
- */
- public boolean isTakeoverContract()
- {
- return _isTakeoverContract;
- }
- /**
- * Mark this contract as the contract that was taken over or the new contract depending on the
- * input paramter.
- *
- * @param pInd
- */
- public void setIsTakeoverContract(boolean pInd)
- {
- _isTakeoverContract = pInd;
- }
- // <-- 233025
- /**
- * Accept a visitor, call method in visitor depending on type of this instance and pass the visitor to all depending instances.
- *
- * @param pVisitor
- * com.lhs.Contract.bscs_core.ContractVisitor
- * @throws ValidationException
- * @throws ComponentException
- * @throws SystemException
- */
- public void accept(ContractVisitor pVisitor) throws ComponentException, ValidationException
- {
- pVisitor.visitContract(this);
- ProductSection vProductSection = _compositeContractSection.getProductSection();
- if (pVisitor.isDone())
- {
- return;
- }
- if (vProductSection != null)
- {
- /*
- * propagate visitor ...
- */
- if (getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.CONTRACTED_COMPOSITE_PRODUCT))
- {
- /*
- * Retrieve the ContractedCompositeProduct from the ProductSection
- */
- ContractedCustomerProduct contractedCustomerProduct = vProductSection.getContractedCompositeProduct();
- contractedCustomerProduct.accept(pVisitor);
- }
- vProductSection.accept(pVisitor);
- }
- // Visit the customization section
- CustomizationSection customizationSection = _compositeContractSection.getCustomizationSection();
- if (customizationSection != null)
- {
- customizationSection.accept(pVisitor);
- }
- DataExchangeSection dataExchangeSection = _compositeContractSection.getDataExchangeSection();
- if (dataExchangeSection != null)
- {
- dataExchangeSection.accept(pVisitor);
- }
- GeneralContractSection generalContractSection = _compositeContractSection.getGeneralContractSection();
- if (generalContractSection != null)
- {
- generalContractSection.accept(pVisitor);
- }
- InvoiceSection invoiceSection = _compositeContractSection.getInvoiceSection();
- if (invoiceSection != null)
- {
- invoiceSection.accept(pVisitor);
- }
- PaymentSection paymentSection = _compositeContractSection.getPaymentSection();
- if (paymentSection != null)
- {
- paymentSection.accept(pVisitor);
- }
- }
- /**
- * Returns whether the contract has a service assigned
- *
- * @return boolean
- */
- @Override
- public boolean areServicesAssignedI()
- {
- if (this.isAgreementContract())
- {
- return false;
- }
- return "Y".equals(_servicesAssigned) || "y".equals(_servicesAssigned);
- }
- /**
- * changeStatusI. Change the status of the CustomerContract by creating a new ContractStatus, which is marked as pending, using
- * the state given in pNewState and the reason given in pReason.
- *
- * @param pNewState
- * com.lhs.CommonDomain.bscs_core.external.StateI
- * @param pReason
- * @param pValidFromDate
- * the time from which the pending status is valid from. For the time being only one pending state for a contract is
- * possible. This may change in future! If the value is passed as a NullConversion.INT_NULL_VALUE the system time is
- * taken instead.
- * @param pProperties
- * a list of properties which are used for resource retention in case of deactivation
- * @param pInstance
- * the MVNO instance
- * @param pEffectiveDate
- * the effective date of the MVNO instance
- * @param pRequestCode
- * the request code of the MVNO instance
- * @return List of services that have been added and/or activate during initial activation.
- * @precondition There doesn't exist any pending status for that CustomerContract
- * @throws ComponentException
- * @throws ValidationException
- * @see com.lhs.Contract.bscs_core.ContractStatus
- * @see com.lhs.CommonDomain.bscs_core.Reason
- */
- // PN337441 chenf
- public List<ContractedProductElementI> changeStatus(int pNewState, ReasonI pReason, long pValidFromDate,
- KeyValueI[] pProperties, Instance pInstance, Timestamp pEffectiveDate, String pRequestCode)
- throws ComponentException, ValidationException
- {
- /*
- * Check wether the pending and the current status have been already
- * retrieved
- */
- if (_currentStatus == null)
- {
- retrieveCurrentAndPendingStatus();
- }
- /*
- * Check whether a pending status for this contract already exists
- */
- if (_pendingStatus != null)
- {
- throw new ValidationException("Contract.NoStatusChangeWithPendingStatus");
- }
- /*
- * Check whether the requested state is valid for contracts
- */
- ContractStatus currentStatus = _currentStatus;
- if (!currentStatus.isFollowStateI(pNewState))
- {
- throw new ValidationException("Contract.InvalidState");
- }
- /*
- * check whether requested state is 'suspended' and contract is on trial
- */
- if (pNewState == ContractStatusI.Suspended && isOnTrialI())
- {
- throw new ValidationException("Contract.InvalidState", "OnTrial->Suspended");
- }
- /*
- * get old state
- */
- int vOldState = currentStatus.getStateI();
- /*
- * if not validated is set, reset the flag if new state is not 'on hold'
- */
- if (vOldState == ContractStatusI.Onhold && pNewState != ContractStatusI.Onhold)
- {
- setNotValidatedI(false);
- }
- /* check 2: if status change is from onhold to active: Feature 15860 */
- /*
- * introduce something similiar to FC 3/4 in combination with FC 18/19
- */
- if (pNewState == ContractStatusI.Active && vOldState == ContractStatusI.Onhold)
- {
- // this is an initial activation.
- // check whether this is a contract of the MNVO instance and update the valid from date appropriately
- if (!NullConversion.isNull(pEffectiveDate))
- {
- ((ContractStatus) getCurrentStatusI()).setValidFromDate(pEffectiveDate.getTime());
- }
- // #TODO check open amounts of payment responsible -> should be done on the client side!!! semantic of status change is
- // overrule check!
- /*
- * check 3: if status change is from onhold to active: Feature 84834
- * if is an AL contract, check if the main contract is still active and doesn't have pending requests
- */
- if (isALContractI())
- {
- // test if the main contract is active
- Contract mainContract = (Contract) this.getCompositeContractSection().getGeneralContractSection().getMainContract();
- if (mainContract.getCurrentStatusI().getStateI() != ContractStatusI.Active)
- {
- throw new ValidationException("Contract.MainContractIsNotActive",
- Long.valueOf(mainContract.getIDI()), mainContract.getPublicKeyI());
- }
- // test if the main contract has pending requests
- if (mainContract.hasPendingContractRequests())
- {
- throw new ValidationException("Contract.NoStatusChangeWithPendingStatus");
- }
- }
- }
- // begin 236082_cms
- /*
- * Constraints for two-level contracts:
- * 1. child may be activated if parent has been activated (checked above)
- * 2. parent may be suspended if all children are suspended or deactivated
- * 3. parent may be deactivated if children are deactivated
- */
- if (isMainContractI())
- {
- List<ContractI> childList = this.getCompositeContractSection().getGeneralContractSection().getRelatedContracts();
- Iterator<ContractI> childIter = childList.iterator();
- Contract child;
- if (pNewState == ContractStatusI.Suspended && vOldState != ContractStatusI.Suspended)
- {
- while (childIter.hasNext())
- {
- child = (Contract) childIter.next();
- if (child.getCurrentStatusI().getStateI() != ContractStatusI.Suspended
- && child.getCurrentStatusI().getStateI() != ContractStatusI.Deactive)
- {
- throw new ValidationException(
- "CMS.Contract.RelatedContracts.ChildContractIsNeitherSuspendedNorDeactivated", getPublicKey(),
- child.getPublicKey());
- }
- if (child.hasPendingContractRequests())
- {
- throw new ValidationException("Contract.NoStatusChangeWithPendingStatus");
- }
- }
- }
- else if (pNewState == ContractStatusI.Deactive && vOldState != ContractStatusI.Deactive)
- {
- while (childIter.hasNext())
- {
- child = (Contract) childIter.next();
- if (child.getCurrentStatusI().getStateI() != ContractStatusI.Deactive)
- {
- throw new ValidationException("CMS.Contract.RelatedContracts.ChildContractIsNotDeactivated",
- getPublicKey(), child.getPublicKeyI());
- }
- if (child.hasPendingContractRequests())
- {
- throw new ValidationException("CMS.Contract.NoStatusChangeWithPendingStatus");
- }
- }
- }
- }
- // end 236082_cms
- /*
- * Create a new ContractStatus object
- */
- ContractStatus pendingStatus = AbstractFactory.createObject(ContractStatus.class);
- /*
- * add status to list of contract stati
- */
- Vector<ContractStatus> vContractStati = getContractStati();
- vContractStati.add(pendingStatus);
- setContractStati(vContractStati);
- /*
- * set sequence number of status object
- */
- pendingStatus.setID(getNextContractStatusSeqNo());
- /*
- * Set the initial state to the current state
- */
- pendingStatus.setState(vOldState);
- /*
- * set back reference to this contract
- */
- pendingStatus.setContract(this);
- /*
- * Change its state to the requested state
- */
- pendingStatus.changeStateI(pReason, pNewState);
- /*
- * Mark the ContractStatus object to be pending
- * only in the case that it is not a CS contract type
- */
- if (getContractType().isGmdSupported())
- {
- pendingStatus.setIsPendingI(true);
- /*
- * Assign it to the contract
- */
- _pendingStatus = pendingStatus;
- }
- else
- {
- // no GMD support, so directly make the status change effective
- _currentStatus = pendingStatus;
- }
- long vTime;
- int vDate = CAASDateConverter.toCAASDate(pValidFromDate); // PN337441 chenf
- /*
- * if the date specifies today's take the timestamp from today! (To make the tester happy!)
- */
- if (vDate != ServerTime.getCurrentDateAsInt()) // PN337441 chenf
- {
- vTime = pValidFromDate; // PN337441 chenf
- }
- else
- {
- vTime = ServerTime.getCurrentTimeAsLong();
- }
- /*
- * set the time from which the status change is valid from
- */
- pendingStatus.setValidFromDate(vTime);
- /*
- * perform some additional action depending on the new pending state
- * propagate changes to ContractedProductElements!
- */
- if (getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.CONTRACTED_COMPOSITE_PRODUCT))
- {
- ChangeContractStatusVisitor lCreateChangeContractStatusVisitor = VisitorFactory.getInstance()
- .createChangeContractStatusVisitor(this, pNewState, vDate, pProperties);
- accept(lCreateChangeContractStatusVisitor);
- return lCreateChangeContractStatusVisitor.getAddedContractedProductElements();
- }
- return Collections.emptyList();
- }
- /**
- * changeStatusI. Change the status of the CustomerContract by creating a new ContractStatus, which is marked as pending, using
- * the state given in pNewState and the reason given in pReason.
- *
- * @param pNewState
- * com.lhs.CommonDomain.bscs_core.external.StateI
- * @param pReason
- * @param pValidFromDate
- * the time from which the pending status is valid from. For the time being only one pending state for a contract is
- * possible. This may change in future! If the value is passed as a NullConversion.INT_NULL_VALUE the system time is
- * taken instead.
- * @param pProperties
- * a list of properties which are used for resource retention in case of deactivation
- * @param pInstance
- * MVNO instance
- * @param pEffectiveDate
- * the effective date
- * @param pRequestCode
- * the request code
- * @precondition There doesn't exist any pending status for that CustomerContract
- * @throws SystemException
- * @throws ComponentException
- * @throws ValidationException
- * @see com.lhs.Contract.bscs_core.ContractStatus
- * @see com.lhs.CommonDomain.bscs_core.Reason
- */
- // PN337441 chenf
- @Override
- public List<ContractedProductElementI> changeStatusI(int pNewState, ReasonI pReason, long pValidFromDate,
- KeyValueI[] pProperties, Instance pInstance, Timestamp pEffectiveDate, String pRequestCode) throws ComponentException,
- ValidationException
- {
- /*
- * Retrieve the current Status
- */
- ContractStatusI currentStatus = getCurrentStatusI();
- /*
- * get old state
- */
- int vOldState = currentStatus.getStateI();
- // begin defect 254804 CWLEE
- // checks if user has the permission to change the status
- checkPermissionForTransition(vOldState, pNewState);
- // end defect 254804
- /*
- * Retrieve the contract administrator
- */
- ContractAdministrator administrator = ContractAdministrator.getInstance();
- if (isALContractI() && pNewState == ContractStatusI.Deactive && !getContractType().isGmdSupported())
- {
- Contract mainContract = (Contract) getCompositeContractSection().getGeneralContractSection().getMainContract();
- mainContract.getCompositeContractSection().getGeneralContractSection().removeRelatedContract(this);
- }
- // --> defect 234767 NIJ
- // - check for pending requests, in case of contract deactivation or suspension, refuse
- if (vOldState == ContractStatusI.Active && (pNewState == ContractStatusI.Suspended || pNewState == ContractStatusI.Deactive))
- {
- ContractAdministrator.getInstance().checkContractPendingRequests(this);
- }
- // <-- 234767
- // PN 238900
- if (pNewState == ContractStatusI.Deactive && hasPendingBARequest())
- {
- throw new ValidationException("Contract.PendingBARequestOnConDeactivation", Long.valueOf(getIDI()));
- }
- if (pNewState == ContractStatusI.Deactive)
- {
- checkSharedAccountPackageAssignmentsForContractDeactivation(); // check if contract can be deactivated from shared account package perspective
- }
- /*
- * if passed date is null than take the system date
- */
- // Begin PN337441 chenf
- long vDate = pValidFromDate;
- // End PN337441 chenf
- if (NullConversion.isNull(pValidFromDate))
- {
- vDate = ServerTime.getCurrentTimeAsLong(); // PN337441 chenf
- }
- else
- {
- /*
- * check whether date is valid
- */
- if (vDate < ServerTime.getCurrentDate().getTime())
- {
- throw new ValidationException("Contract.InvalidDate");
- }
- }
- // Feature 53406. If this is a VPN Subscriber Contract (Administrator), do not allow to deactivate it if the VPN has members
- // USc#021115 little optimization for the non active case
- if (vOldState == ContractStatusI.Active &&
- (pNewState == ContractStatusI.Deactive || pNewState == ContractStatusI.Suspended) && isVPNSubscriberContractI())
- {
- // - Get the internal and external members co ids. Since the error message cant hold all probably, lets limit both to 5.
- // begin PN 00271021 wongpy
- List<Long> vExtMembers = administrator.getVPNExternalMemberIds(getVPNOwnershipI(), this, ContractSettings.MAXEXTERNALCONTRACTSINVPNERROMESSAGE);
- List<Long> vIntMembers = administrator.getVPNInternalMemberIds(getVPNOwnershipI(), this, ContractSettings.MAXINTERNALCONTRACTSINVPNERROMESSAGE);
- // concat the co ids for the error message
- StringBuilder coIds = new StringBuilder();
- if (vExtMembers.size() > 0)
- {
- coIds.append("external : ");
- }
- for (int i = 0; i < vExtMembers.size(); i++)
- {
- Long value = vExtMembers.get(i);
- if (i > 0)
- {
- coIds.append(",");
- }
- coIds.append(value.longValue());
- }
- if (vIntMembers.size() > 0)
- {
- coIds.append(" internal : ");
- }
- for (int i = 0; i < vIntMembers.size(); i++)
- {
- Long value = vIntMembers.get(i);
- if (i > 0)
- {
- coIds.append(",");
- }
- coIds.append(value.longValue());
- }
- if (coIds.length() > 0)
- {
- throw new ValidationException("CMS.Contract.VPNHasMembers", coIds.toString());
- }
- }
- // Feature 53406. If this is a VPN User Contract (member), do not allow to activate it if the VPN Subscriber contract is not
- // active
- // USc#021115 little optimization for the non active case
- if (pNewState == ContractStatusI.Active && isVPNUserContractI())
- {
- Vector<VirtualPrivateNetworkI> vVPNMemberships = getVPNMembershipsI(); // a contract can hold more than one VPN
- // Membership Service
- Iterator<VirtualPrivateNetworkI> vIter = vVPNMemberships.iterator();
- // Begin PN 00254647/d : Kaiser, CWLEE
- // 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
- // in the list.
- // End PN 00254647/d
- while (vIter.hasNext())
- {
- VirtualPrivateNetworkI vVPN = vIter.next();
- // Begin PN 00254647/d : Kaiser
- // ContractI vVPNSubsContract= (ContractI)(administrator.getVPNAgreementI(vTx,vVPN));
- // if (vVPNSubsContract.getCurrentStatusI(vTx).getStateI()!=ContractStatusI.Active){
- // throw new ValidationException("Contract.VPNSubscriberContractIsNotActive");
- // }
- boolean bActiveVPNOwnerContract = false;
- ContractI[] aVPNSubsContract = administrator.getVPNAgreementsI(vVPN);
- // AV PN 00261964 Begin
- Contract lCustomerContract = null;
- // AV PN 00261964 End
- if (aVPNSubsContract.length > 0)
- {
- for (int i = 0; i < aVPNSubsContract.length; i++)
- {
- // AV PN 00261964 Begin
- // if (((ContractI)aVPNSubsContract[i]).getCurrentStatusI().getStateI()==ContractStatusI.Active)
- lCustomerContract = (Contract) aVPNSubsContract[i];
- if (lCustomerContract.hasPendingRequests())
- {
- lCustomerContract.refreshObject();
- AbstractDomainObject lClone = lCustomerContract.getInstanceForUpdate();
- TransactionContext.getCurrent().getUnitOfWork().revertObject(lClone);
- }
- if (lCustomerContract.getCurrentStatusI().getStateI() == ContractStatusI.Active)
- // AV PN 00261964 End
- {
- bActiveVPNOwnerContract = true;
- break;
- }
- }
- if (!bActiveVPNOwnerContract)
- {
- throw new ValidationException("Contract.VPNSubscriberContractIsNotActive", Long.valueOf(vVPN.getIDI()),
- vVPN.getNameI());
- }
- }
- else
- {
- throw new ValidationException("Contract.VPNSubscriberContractIsNotActive", Long.valueOf(vVPN.getIDI()),
- vVPN.getNameI());
- }
- }
- // End PN 00254647/d
- }
- /*
- * Feature 81481_2. If this is an activation some new port IN checks are required.
- * vParentRequest = zero means there is NO dependent request.
- */
- long vParentRequest = 0;
- if (pNewState == ContractStatusI.Active)
- {
- CheckContractActivationVisitor vVisitor = new CheckContractActivationVisitor();
- this.accept(vVisitor);
- TaskI vTask = vVisitor.getFoundPendingDeactivationRequest();
- if (vTask != null)
- {
- vParentRequest = vTask.getIDI();
- // #TODO check for Alternate line contracts !!!!!
- }
- }
- // feature 84926 - End date of tariff model assignment
- // in the activation of a contract, test if the rate plan is still valid
- if (pNewState == ContractStatusI.Active && vOldState == ContractStatusI.Onhold)
- {
- if (getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.CONTRACTED_COMPOSITE_PRODUCT))
- {
- CompositeProductI cp = (CompositeProductI) getContractedCompositeProductI().getProductI();
- CompositeProductAvailabilityPeriodI period = administrator.getProductAdministrator().getCurrentCompositeProductAvailabilityPeriodI(cp);
- if (period != null)
- {
- int lStatusChangeDate = CAASDateConverter.toCAASDate(vDate);
- int lAvailableFromI = period.getAvailableFromI();
- int lAvailableToI = period.getAvailableToI();
- if (lAvailableFromI != NullConversion.INT_NULL_VALUE && lAvailableFromI > lStatusChangeDate ||
- lAvailableToI != NullConversion.INT_NULL_VALUE && lAvailableToI < lStatusChangeDate)
- // --> defect 230669 NIJ
- {
- long cpId = cp.getIDI();
- Date availDateFrom = CAASDateConverter.toDate(lAvailableFromI);
- Date availDateTo = CAASDateConverter.toDate(lAvailableToI);
- Date compareDate = CAASDateConverter.toDate(lStatusChangeDate);
- String sAvailDateFrom = availDateFrom.toString();
- String sAvailDateTo = availDateTo.toString();
- throw new ValidationException("Contract.ActionValidFromDateDoesNotMatchWithAvailabilityOfCompositeProduct", sAvailDateFrom + "->"
- + sAvailDateTo, Long.valueOf(cpId), compareDate);
- }
- // <-- 230669
- }
- }
- }
- List<ContractedProductElementI> lAdditinalContractedServices;
- // feature 84834 - Alternate Line
- // if the contract takes part in an AL subscription all the contracts in the subscription will be affected
- // when a suspension or reactivation is performed or a deactivation of the main contract
- // USc#021115 little optimization to avoid method call if not necessary
- if (pNewState == ContractStatusI.Deactive && isMainContractI() ||
- (pNewState == ContractStatusI.Suspended
- || pNewState == ContractStatusI.Active
- && vOldState == ContractStatusI.Suspended)
- && isRelatedContract())
- {
- Contract mainContract;
- Vector<ContractI> relatedContracts;
- if (isMainContractI())
- {
- mainContract = this;
- relatedContracts = this.getCompositeContractSection().getGeneralContractSection().getRelatedContracts();
- }
- else
- {
- mainContract = (Contract) this.getCompositeContractSection().getGeneralContractSection().getMainContract();
- relatedContracts = mainContract.getCompositeContractSection().getGeneralContractSection().getRelatedContracts();
- }
- // change the status of each related contract, which is not on hold
- Iterator<ContractI> iter = relatedContracts.iterator();
- while (iter.hasNext())
- {
- Contract current = (Contract) iter.next();
- if (current.getCurrentStatusI().getStateI() != ContractStatusI.Onhold &&
- current.getCurrentStatusI().getStateI() != pNewState)
- {
- current.changeStatus(pNewState, pReason, vDate, pProperties, pInstance, pEffectiveDate, pRequestCode); // PN337441
- // chenf
- }
- }
- // change the status of the main contract
- lAdditinalContractedServices = mainContract.changeStatus(pNewState, pReason, vDate, pProperties, pInstance,
- pEffectiveDate, pRequestCode); // PN337441 chenf
- }
- else
- {
- lAdditinalContractedServices = changeStatus(pNewState, pReason, vDate, pProperties, pInstance, pEffectiveDate,
- pRequestCode); // PN337441 chenf
- }
- if (pNewState == ContractStatusI.Active)
- {
- ContractedResourcesPropertiesI crp = null;
- if (currentStatus.getStateI() != ContractStatusI.Onhold)
- {
- // this is a reactivation
- // --> defect 252780 NIJ/ reimplementing 00247400 DAE, missing in 801
- ContractedCompositeProductI ccp = getContractedCompositeProductI();
- // the resource might not yet assigned
- Vector<ContractedResourcesPropertiesI> lConResourcesProperties = ccp.getContractedResourcesPropertiesI();
- if (!lConResourcesProperties.isEmpty())
- {
- crp = lConResourcesProperties.get(0);
- }
- }
- /*
- * distinguish between inital activation and reactivation
- */
- short vPriority = ContractAdministrator.getInstance().getCommonDomainAdministrator().getUserPriorityI(GMDActionI.ActivateSubscription);
- // - if suspension is not supported then by reactivation write action for activation
- if (currentStatus.getStateI() == ContractStatusI.Onhold || crp == null)
- {
- // PN00235359 Larbig : do not set rating and provisioning flag here
- /*
- * 240721 - IN or not IN ?
- * For the initial activation, the IN trigger must always be set
- */
- if (isINContract())
- {
- getContractTaskHandler().registerAction(ContractSettings.CONTRACT_ACTIVATION,
- new AbstractDomainObjectI[]{this},
- vDate,
- vPriority,
- TaskTypeI.Provisioning,
- null,
- null,
- vParentRequest,
- "S", pInstance, pEffectiveDate, pRequestCode);
- }
- else
- {
- getContractTaskHandler().registerAction(ContractSettings.CONTRACT_ACTIVATION,
- new AbstractDomainObjectI[]{this},
- vDate,
- vPriority,
- TaskTypeI.Provisioning,
- null,
- null,
- vParentRequest,
- "U", pInstance, pEffectiveDate, pRequestCode);
- }
- }
- else
- {
- // PN00235359 Larbig : do not set rating and provisioning flag here
- getContractTaskHandler().registerAction(ContractSettings.CONTRACT_REACTIVATION, new AbstractDomainObjectI[]{this},
- vDate, vPriority, TaskTypeI.Provisioning, null, null, vParentRequest, pInstance, pEffectiveDate, pRequestCode);
- }
- // Begin PN 00302209 huangw
- /* activate an event if the contract is reactivated. */
- if (currentStatus.getStateI() == ContractStatusI.Suspended)
- {
- EventHandler.getInstance().activateEvent(this, ChargeableEventI.REACTIVATION_EVENT_NAME);
- }
- // End PN 00302209
- }
- else if (pNewState == ContractStatusI.Deactive)
- {
- /*
- * distinguish between deactivation from suspension and from other states
- */
- short vPriority = ContractAdministrator.getInstance().getCommonDomainAdministrator().getUserPriorityI(GMDActionI.DeactivateSubscription);
- if (currentStatus.getStateI() == ContractStatusI.Suspended)
- {
- // PN00235359 Larbig : do not set rating and provisioning flag here
- getContractTaskHandler().registerAction(ContractSettings.CONTRACT_TRANSITION, new AbstractDomainObjectI[]{this},
- vDate, vPriority, TaskTypeI.Provisioning, null, null, vParentRequest, pInstance, pEffectiveDate, pRequestCode);
- }
- else
- {
- // PN00235359 Larbig : do not set rating and provisioning flag here
- getContractTaskHandler().registerAction(ContractSettings.CONTRACT_DEACTIVATION, new AbstractDomainObjectI[]{this},
- vDate, vPriority, TaskTypeI.Provisioning, null, null, vParentRequest, pInstance, pEffectiveDate, pRequestCode);
- }
- }
- else if (pNewState == ContractStatusI.Suspended)
- {
- short vPriority = ContractAdministrator.getInstance().getCommonDomainAdministrator().getUserPriorityI(GMDActionI.DeactivateSubscription);
- getContractedCompositeProductI();
- // PN00235359 Larbig : do not set rating and provisioning flag here
- getContractTaskHandler().registerAction(ContractSettings.CONTRACT_SUSPENSION, new AbstractDomainObjectI[]{this},
- vDate, vPriority, TaskTypeI.Provisioning, null, null, vParentRequest, pInstance, pEffectiveDate, pRequestCode);
- // Begin PN 00302209 huangw
- /*
- * activate an event if the contract is suspended.
- */
- EventHandler.getInstance().activateEvent(this, ChargeableEventI.SUSPENSION_EVENT_NAME);
- // End PN 00302209
- }
- /*
- * feature 350656_cms
- */
- if (pNewState == ContractStatusI.Active && vOldState == ContractStatusI.Suspended)
- {
- // if it's a contract reactivation, just check if the pam schedule value changed IF a bill cycle change happened
- configurePamScheduleForBillCycleChange(true, false, this);
- }
- else if (pNewState != ContractStatusI.Suspended && pNewState != ContractStatusI.Deactive)
- {
- configurePamClass(pInstance, pEffectiveDate, pRequestCode, null, false, false);
- }
- return lAdditinalContractedServices;
- }
- /**
- * checkConsistency. Checks the consistency of the contract.
- *
- * @throws ValidationException
- * @throws ComponentException
- * @throws SystemException
- */
- protected void checkConsistency() throws ComponentException, ValidationException
- {
- // begin 236082_cms moved from (removed) CustomerContractTemplate
- if (ContractType.SHNAME_NOST.equals(getContractType().getShortName()))
- {
- /*
- * check whether customer is activ
- */
- int vCustomerState = getContractHolderI().getStatusI().getStateI();
- if (vCustomerState != OrgNodeStatusI.Active)
- {
- throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.StatesOfContractHolderAndContractNotCompatible");
- }
- // check that technology is present
- TechnologyI vTechnology = this.getContractedCompositeProductI().getTechnologyI();
- if (vTechnology == null)
- {
- throw new ValidationException("Contract.MissingTechnology");
- }
- // create a new visitor and check the contract structure
- ContractTemplateConsistencyVisitor lVisitor = VisitorFactory.getInstance().createContractTemplateConsistencyVisitor();
- // visit the contract structure
- this.accept(lVisitor);
- // final check
- lVisitor.finishConsistencyCheck();
- }
- // end 236082_cms
- // 236082_cms removed if (this.isCustomerContract()) {
- /*
- * check whether customer is activ
- */
- int vState = getCurrentStatusI().getStateI();
- int vCustomerState = getContractHolderI().getStatusI().getStateI();
- if (vCustomerState != OrgNodeStatusI.Active && getPendingStatusI() != null && getPendingStatusI().getStateI() == ContractStatusI.Active)
- {
- // in case of an activation or deactivation the customer must be active as well
- throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.StatesOfContractHolderAndContractNotCompatible");
- }
- if (
- // not active customer AND not-de-active contract -not allowed, exception!
- vState != ContractStatusI.Deactive && vCustomerState != OrgNodeStatusI.Active
- &&
- vState != ContractStatusI.Suspended && vCustomerState != OrgNodeStatusI.Suspended)
- {
- throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.StatesOfContractHolderAndContractNotCompatible");
- }
- ContractType contractType = getContractType();
- // 236082_cms
- if (contractType.isSectionSubsectionUsed(ProductSection.NAME, ProductSection.TECHNOLOGY))
- {
- // check that technology is present
- TechnologyI vTechnology = this.getContractedCompositeProductI().getTechnologyI();
- if (vTechnology == null)
- {
- throw new ValidationException("Contract.MissingTechnology");
- }
- }
- // 236082_cms
- if (contractType.isSectionSubsectionUsed(ProductSection.NAME, ProductSection.ALTERNATE_TARIFF))
- {
- // begin defect 262859 CWLEE: Check that alternate rate plan and BOP are not assigned at the same time
- if (getContractedCompositeProductI().getPricingSchemeI(PricingSchemeRoleI.AlternativPricingScheme) != null
- && getCurrentBOPPackageVersion() != null)
- {
- throw new ComponentException("Contract.ConsistencyCheckFailed.AlternateRatePlanAndBOPNotAllowed");
- // end defect 262859
- }
- }
- if (contractType.isSectionSubsectionUsed(ProductSection.NAME, ProductSection.CONTRACTED_COMPOSITE_PRODUCT))
- {
- // level contracts must not be checked than regular subscriber contracts
- if (!this.isLevelContractI())
- {
- // create a new visitor and check the contract structure
- // FSP 345205, PN 358243, MCH: added checking for agreement contract
- if (contractType.isContractAgreementType())
- {
- AgreementContractConsistencyVisitor lVisitor = VisitorFactory.getInstance()
- .createAgreementContractConsistencyVisitor();
- // visit the contract structure
- this.accept(lVisitor);
- // final check
- lVisitor.finishConsistencyCheck();
- }
- else
- {
- ContractConsistencyVisitor lVisitor = VisitorFactory.getInstance().createContractConsistencyVisitor();
- // visit the contract structure
- this.accept(lVisitor);
- // final check
- lVisitor.finishConsistencyCheck();
- }
- // end FSP 345205, PN 358243, MCH
- }
- /*
- * Make the additional checks for free unit services
- */
- OrgNodeI holderI = getContractHolderI();
- if (!holderI.areContractsAllowedI())
- {
- // if contains any non POFUL service an exception should be thrown
- ContractedCompositeProduct vConProduct = getContractedCompositeProduct();
- Iterator<ContractedProductElement> lIter = vConProduct.getContractedProductElements().iterator();
- // it is allowed that the contract hasn't any service at all or all POFUL service set to deactive or onhold
- while (lIter.hasNext())
- {
- ContractedProductElementI cpElementI = lIter.next();
- if (cpElementI.getServiceSubtypeI() != NetworkServiceI.FREE_UNIT_TYPE_POFUL)
- {
- throw new ValidationException("Contract.OrgNodeNotAllowedToHaveContracts");
- }
- }
- }
- } // while hasnext
- // 236082 removed}
- }
- /**
- * checkConsistencyI. check the consistency of a contract. This method is called by the client to validate its input. For
- * validation at commit time an internal, private method is used!
- *
- * @throws ValidationException
- * @throws ComponentException
- * @throws SystemException
- */
- @Override
- public void checkConsistencyI()
- throws ComponentException, ValidationException
- {
- // TODO_Heidi
- // from CustomerContract
- ContractedCompositeProduct vProduct = getContractedCompositeProduct();
- // from AgreementContract
- // ContractedProductI vProductI=getContractedCompositeProductI();
- // ContractedCompositeAgreementProduct vProduct= (ContractedCompositeAgreementProduct) vProductI;
- /*
- * check against the 'build in' rules
- */
- vProduct.validateTechnology();
- vProduct.validateTechnologyFlavour();
- vProduct.validateNetwork();
- /**
- * OK, Ulrich. That time has come !
- * We have normal customer contracts and prepaid contract templates.
- */
- if (this.isCustomerContract())
- {
- checkConsistency();
- }
- else if (this.isAgreementContract())
- {
- checkAgreementConsistency();
- }
- }
- /**
- * checkConsistency. Checks the consistency of the agreement contract.
- *
- * @param pCategory
- * String
- * @throws ValidationException
- * @throws ComponentException
- * @throws SystemException
- */
- protected void checkAgreementConsistency() throws ComponentException, ValidationException
- {
- /*
- * check whether customer is activ
- */
- int vState = getCurrentStatusI().getStateI();
- int vCustomerState = getContractHolderI().getStatusI().getStateI();
- if (vState != ContractStatusI.Deactive && vCustomerState != OrgNodeStatusI.Active)
- {
- throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.StatesOfContractHolderAndContractNotCompatible");
- }
- // check that technology is present
- TechnologyI vTechnology = this.getContractedCompositeProductI().getTechnologyI();
- if (vTechnology == null)
- {
- throw new ValidationException("Contract.MissingTechnology");
- }
- }
- /**
- * Resets the transient references within this instance as long as
- * some objects are not removed properly from the cache
- */
- protected void cleanTransientReferences()
- {
- /*
- * reset some transient values
- * after a merge the refs may refer to objects no longer availabe.
- */
- _currentStatus = null;
- _pendingStatus = null;
- // --> defect 349853 NiJ
- getContractedCompositeProduct().cleanTransientReferences();
- // <-- 349853
- }
- /**
- * Create all aggregated objects like CompositeContractSection
- *
- * @throws ComponentException
- * @throws ValidationException
- */
- @Override
- public void createAggregatedObjects()
- throws ComponentException, ValidationException
- {
- super.createAggregatedObjects();
- /*
- * Invoke the creation of the according aggregated objects and
- * assign it to the Contract
- */
- _compositeContractSection = createCompositeContractSection();
- }
- /**
- * @see com.lhs.ccb.sfw.domain.AbstractDomainObject#initAggregationRelationship()
- */
- @Override
- public void initAggregationRelationship()
- {
- // set the parent in all contract sections
- _compositeContractSection.setAggregatingParent(this);
- }
- /**
- * @return The created composite contract section
- * @throws ComponentException
- */
- protected CompositeContractSection createCompositeContractSection() throws ComponentException
- {
- return AbstractFactory.createAggregatedObject(this, CompositeContractSection.class);
- }
- /**
- * This method is called if a contract should be removed from database.. The
- * assigned resource are freed with respect to the retention mode stored in the
- * passed properties.
- *
- * @param pProperties
- * com.lhs.Topology.bscs_core.external.KeyValueI[]
- */
- protected void delete(KeyValueI... pProperties)
- throws ComponentException, ValidationException
- {
- // 00265683 if (this.isCustomerContract()) {
- /*
- * iterate over contract and execute resource retention according to the parameters passed as properties
- */
- ContractedCompositeProduct vConProduct = getContractedCompositeProduct();
- vConProduct.delete(pProperties);
- // begin 00265683
- CompositeContractSection compContrSection = this.getCompositeContractSection();
- // delete all contract sections, their subsections and histories
- compContrSection.getGeneralContractSection().delete(pProperties);
- compContrSection.getProductSection().delete(pProperties);
- compContrSection.getInvoiceSection().delete(pProperties);
- compContrSection.getDataExchangeSection().delete(pProperties);
- compContrSection.getPaymentSection().delete(pProperties);
- compContrSection.getCustomizationSection().delete(pProperties);
- // end 00265683
- // 377727_E08_U07
- List<ContractPamScheme> pamSchemes = this.getPamSchemes();
- for (ContractPamScheme scheme : pamSchemes)
- {
- scheme.delete();
- }
- List<ContractPamScheme> pamSchemesFree = this.getPamSchemesFree();
- for (ContractPamScheme scheme : pamSchemesFree)
- {
- scheme.delete();
- }
- /*
- * delete all dependend objects from the document section
- */
- // this.getCompositeContractSection().getDocumentSection().delete(pProperties);
- // Begin Defect 281935 Daniel Rezende
- // Propagate the contract deletion to all plugins
- long timestamp = ServerTime.getCurrentTimeAsLong();
- AbstractDomainObjectI[] objects = new AbstractDomainObjectI[]{this};
- PluginEvent cmsEvent = new PluginEvent(PluginEvent.CONTRACT_DELETION, timestamp, objects);
- PluginAdministrator.getInstance().registerCMSEvent(cmsEvent);
- // End Defect 281935 Daniel Rezende
- /*
- * delete the status object from contract
- */
- getCurrentStatusI().delete();
- /*
- * delete tickler records
- */
- Vector<BusinessPartnerEventMessageI> vTicklers = getBusinessPartnerEventMessages();
- Iterator<BusinessPartnerEventMessageI> vIter = vTicklers.iterator();
- AbstractDomainObjectI vADO = null;
- while (vIter.hasNext())
- {
- vADO = vIter.next();
- vADO.<AbstractDomainObject> getInstanceForUpdate().delete();
- }
- // if is an AL contract, delete the reference in CONTRACT_RELATION
- // 00265683if (isALContractI()) {
- if (getContractType().isSectionSubsectionUsed(GeneralContractSection.NAME, GeneralContractSection.CONTRACT_RELATION))
- {
- GeneralContractSection generalContractSection = this.getCompositeContractSection().getGeneralContractSection();
- ContractRelation cRel = generalContractSection.getMainContractRelation();
- if (cRel != null)
- {
- ContractI mainContractI = cRel.getMainContract();
- Contract mainContract = (Contract) mainContractI;
- mainContract.getCompositeContractSection().getGeneralContractSection().removeRelatedContract(this);
- if (!cRel.isCloneForUpdate())
- {
- vADO = cRel.getInstanceForUpdate();
- }
- else
- {
- vADO = cRel;
- }
- vADO.delete();
- }
- }
- // remove the reference to porting request, if exists
- Vector<PortingRequest> requests = getPortingRequests();
- Iterator<PortingRequest> iterator = requests.iterator();
- PortingRequest portingRequest = null;
- while (iterator.hasNext())
- {
- portingRequest = iterator.next();
- if (!portingRequest.isCloneForUpdate())
- {
- portingRequest = portingRequest.getInstanceForUpdate();
- }
- portingRequest.setContract(null);
- HistoricalPortingRequest portingRequestHistory = null;
- List<HistoricalPortingRequest> historyList = portingRequest.getHistoricalPortingRequests();
- if (!historyList.isEmpty())
- {
- int lSize = historyList.size();
- for (int i = 0; i < lSize; i++)
- {
- portingRequestHistory = historyList.get(i);
- if (!portingRequestHistory.isCloneForUpdate())
- {
- portingRequestHistory = portingRequestHistory.getInstanceForUpdate();
- }
- portingRequestHistory.setContractIdI(NullConversion.LONG_NULL_VALUE);
- }
- }
- }
- // PN 312099, MCH 29.08.2008
- // remove the lock objects
- removeLocks();
- // end 312099, MCH 29.08.2008
- /*
- * clean up the instance
- */
- cleanTransientReferences();
- }
- // PN 312099, MCH 29.08.2008
- /**
- * Removes the lock objects.
- */
- protected void removeLocks()
- {
- // billing lock
- BillingContractLock billingLock = getBillingLock();
- if (billingLock != null)
- {
- billingLock.delete();
- }
- // re-rating lock
- ReratingContractLock reratingLock = getReratingLock();
- if (reratingLock != null)
- {
- reratingLock.delete();
- }
- }
- // end 312099, MCH 29.08.2008
- /**
- * Read all BusinessPartnerEventMessages/Tickler from the database related to this contract. Creation date: (03/14/2001 10:18:22
- * AM)
- *
- * @return Vector
- * @throws ComponentException
- */
- @SuppressWarnings({"unchecked", "rawtypes"})
- public Vector<BusinessPartnerEventMessageI> getBusinessPartnerEventMessages()
- throws ComponentException
- {
- ExpressionBuilder vExpressionBuilder = new ExpressionBuilder();
- Expression vExpression = vExpressionBuilder.get("ContractID").equal(getIDI());
- return (Vector) AbstractFactory.readQueryObjects(BusinessPartnerEventMessage.class, vExpression);
- }
- /**
- * convinience method for the TaskManagement component
- *
- * @return com.lhs.Contract.bscs_core.external.ContractedCompositeProductI
- * @throws ValidationException
- * @throws ComponentException
- * @throws SystemException
- */
- @Override
- public ContractedCompositeProductI getContractedCompositeProductI() throws ComponentException, ValidationException
- {
- ProductSectionI vProductSection = getProductSectionI();
- ProductSection lProductSection = (ProductSection) vProductSection;
- /*
- * for the time being exactly one ContractedCompositeProduct is
- * assigned to a contract
- */
- return lProductSection.getContractedCompositeProduct();
- }
- /**
- * Returns the contracted rateplan.
- *
- * @return com.lhs.Contract.bscs_core.ContractedCompositeProduct
- * @throws ValidationException
- * @throws ComponentException
- * @throws SystemException
- */
- public ContractedCompositeProduct getContractedCompositeProduct() throws ComponentException, ValidationException
- {
- ProductSectionI vProductSection = getProductSectionI();
- ProductSection lProductSection = (ProductSection) vProductSection;
- /*
- * for the time being exactly one ContractedCompositeProduct is
- * assigned to a contract
- */
- return lProductSection.getContractedCompositeProduct();
- }
- /**
- * getContractStati. Returns the list of contract stati.
- *
- * @author Ulrich Schaefer
- * @return Vector
- */
- public Vector<ContractStatus> getContractStati()
- {
- return FWValueHolder.getValue(_contractStati);
- }
- /**
- * getCurrentStatusI. Returns the current status of the Contract.
- *
- * @return com.lhs.Contract.bscs_core.external.ContractStatusI
- * @throws SystemException
- * @throws ComponentException
- * @throws ValidationException
- */
- @Override
- public ContractStatusI getCurrentStatusI()
- throws ComponentException, ValidationException
- {
- /*
- * Check whether a currentStatus is assigned
- */
- if (_currentStatus == null)
- {
- retrieveCurrentAndPendingStatus();
- }
- return _currentStatus;
- }
- /**
- * getExternalContractReferenceNoI. Returns the identifier for this contract used by an external application
- *
- * @return String
- */
- @Override
- public String getExternalContractReferenceNoI()
- {
- if (this.isAgreementContract())
- {
- return null;
- }
- return _externalContractReferenceNo;
- }
- /**
- * getHistoryOfI. Returns the history of the contract
- *
- * @return Vector
- */
- @Override
- public Vector getHistoryI()
- {
- return null;
- }
- /**
- * Access to TaskHandler associated to this instance (which must be a clone!)
- *
- * @return com.lhs.Contract.bscs_core.ContractTaskHandler
- * @throws ComponentException
- * @throws ValidationException
- */
- public final ContractTaskHandler getContractTaskHandler()
- throws ComponentException, ValidationException
- {
- if (_contractTaskHandler == null)
- {
- throw new ComponentException("Contract.MissingContractTaskHandler");
- }
- return _contractTaskHandler;
- }
- /**
- * Returns the history of the objects specified by the passed classname assigned to this contract
- *
- * @return Vector
- * @throws SystemException
- * @throws ComponentException
- */
- @Override
- @SuppressWarnings("unchecked")
- public <T extends AbstractDomainObjectI> List<T> getHistoryOfI(Class<T> pClassname)
- throws ComponentException
- {
- /*
- * Select the ValueHolder according to the passed classname
- * (Only ContractStatus / ContractTurnover are valid classnames)
- */
- if (!ContractStatus.class.equals(pClassname))
- {
- throw new ComponentException("CommonDomain.Parameter.IsNull", "Invalid classname");
- }
- return (List<T>) getContractStati();
- }
- /**
- * getIdOfContractRepresentativeI. Returns the id of the contract representative
- *
- * @return String
- */
- @Override
- public String getIdOfContractRepresentativeI()
- {
- if (this.isAgreementContract())
- {
- return null;
- }
- return _idOfContractRepresentative;
- }
- /**
- * Returns the name of the contract representative
- *
- * @return String
- */
- @Override
- public String getNameOfContractRepresentativeI()
- {
- if (this.isAgreementContract())
- {
- return null;
- }
- return _nameOfContractRepresentative;
- }
- /**
- * Returns the pending status of the Contract.
- *
- * @return com.lhs.Contract.bscs_core.external.ContractStatusI
- * @throws SystemException
- * @throws ComponentException
- * @throws ValidationException
- */
- @Override
- public ContractStatusI getPendingStatusI()
- throws ComponentException, ValidationException
- {
- /*
- * Check whether a pendingStatus is assigned
- */
- if (_pendingStatus == null)
- {
- /*
- * Check whether the current Status has already been retrieved
- */
- if (_currentStatus == null)
- {
- retrieveCurrentAndPendingStatus();
- }
- }
- return _pendingStatus;
- }
- /**
- * Returns the VPNs this contract belongs to (as a Member).
- * Creation date: (7/24/01 3:33:51 PM)
- *
- * @return Vector
- */
- @Override
- public Vector<VirtualPrivateNetworkI> getVPNMembershipsI() throws ComponentException, ValidationException
- {
- if (this.isAgreementContract())
- {
- return null;
- }
- /*
- * The only way to know the VPN_IDs is look for
- * the VPN Access Services
- */
- // get the ContractedCompositeProduct
- ContractedCompositeProduct ccp = getContractedCompositeProduct();
- // Cycle through all ContractedProductElements
- Vector<VirtualPrivateNetworkI> vResult = new Vector<VirtualPrivateNetworkI>(3);
- // let's iterate through all ContractedProductElements of this ContractedSimpleProduct
- Vector<ContractedProductElement> listPEs = ccp.getContractedProductElements();
- if (!listPEs.isEmpty())
- {
- Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
- while (iterPEs.hasNext())
- {
- ContractedProductElement contractedPE = iterPEs.next();
- NetworkServiceI vNetworkService = contractedPE.getNetworkService();
- if (vNetworkService == null)
- {
- // skip non network services
- continue;
- }
- if (vNetworkService.isVPNInternalAccessServiceI())
- {
- // get the VPN_NUMBER from the service parameter
- Vector<ParameterValueNodeI> parameterValues = contractedPE.getCurrentParameterValueNodesI();
- if (parameterValues.isEmpty())
- {
- // This should not occur because the parameters need to be checked before!
- throw new ComponentException("Contract.InvalidParameterList", "VPN Number");
- }
- // Search for the VPN_NUMBER parameter
- Iterator<ParameterValueNodeI> paramIterI = parameterValues.iterator();
- ProductAdministratorI vPAdmin = ContractAdministrator.getInstance().getProductAdministrator(); // PN 315262,
- // refactoring,
- // MCH 10.11.2008
- String VPNNumberString = null;
- while (paramIterI.hasNext())
- {
- ParameterValueNodeI paramNodeI = paramIterI.next();
- if (vPAdmin.getParameterIndexI(vNetworkService, paramNodeI.getParameterI()) == 2)
- { // this is the VPN_NUMBER
- ParameterValueNode paramNode = (ParameterValueNode) paramNodeI;
- VPNNumberString = paramNode.getStringValue();
- break;
- }
- }
- if (VPNNumberString == null)
- {
- // A VPN Internal Access Service must have the VPNNumber parameter
- throw new ComponentException("Contract.InvalidParameterList", "VPN Number");
- }
- /* Retrieve the VPNNumber */
- ContractAdministrator vCoAdmin = ContractAdministrator.getInstance();
- // FSP 290812, PN 290812/d, MCH 22.09.2008: replaced ResourceAttributeI[] by HashMap<String,Object>
- long lResourceRegulationId = ((ResourceAdministrator) vCoAdmin.getResourceAdministrator()).getVpnOwnerNumberResourceRegulation();
- HashMap<String, Object> attr = new HashMap<String, Object>();
- attr.put(Attributes.RA_RESOURCE_REGULATION_ID, Long.valueOf(lResourceRegulationId));
- attr.put(Attributes.RA_NUMBER, VPNNumberString);
- Vector<ResourceI> vList = vCoAdmin.getResourceAdministrator().queryResourcesI(ResourceTypeI.vpn_number, QueryModeI.qm_vpn_user_contract,
- getContractedCompositeProductI().getTechnologyFlavourI().getIDI(), attr);
- // end 290812, PN 290812/d, MCH 22.09.2008
- if (!vList.isEmpty())
- {
- VPNNumberI vVPNNumber = (VPNNumberI) vList.firstElement();
- vResult.add(vVPNNumber.getVirtualPrivateNetworkI());
- }
- else
- {
- throw new ComponentException(DomainService.RC_INVALID_PARAMETER_VALUE, "VPN Number");
- }
- }
- else if (vNetworkService.isVPNExternalAccessServiceI())
- { // The VPN_ID is the CONTR_SERVICES_CAP table
- // get the VPN_ID from the ContractedDNproperties
- Vector<ContractedDNPropertiesI> pCDNPList = contractedPE.getContractedDNPropertiesI();
- if (!pCDNPList.isEmpty())
- {
- // we need only the first one
- ContractedDNPropertiesI pCDNProp = pCDNPList.firstElement();
- vResult.add(pCDNProp.getVPNI());
- // --> 246769 LeT
- }
- // <-- 246769
- }
- }
- }
- return vResult;
- }
- /**
- * If the contract is a VPN Administrator(subscriber) Contract, returns the administered VPN
- * This is for feature 53406
- *
- * @author E. Iglesias
- * @return boolean
- */
- @Override
- public VirtualPrivateNetworkI getVPNOwnershipI()
- throws ComponentException, ValidationException
- {
- if (this.isAgreementContract())
- {
- return null;
- }
- // get the ContractedCompositeProduct
- ContractedCompositeProduct ccp = getContractedCompositeProduct();
- Vector<ContractedProductElement> listPEs = ccp.getContractedProductElements();
- if (listPEs.isEmpty())
- {
- // no ContractedProductElements found !
- throw new ValidationException("Contract.InvalidVPNSubscriberContract",
- new Object[]{Long.valueOf(getIDI()), getPublicKey()});
- }
- VirtualPrivateNetworkI ret = null;
- Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
- while (iterPEs.hasNext())
- {
- // Cycle through all ContractedProductElements
- ContractedProductElement contractedPEI = iterPEs.next();
- // if ContractedProductElement is VPN Administrator, the contract is VPN Subscriber Contract
- NetworkServiceI vNetworkService = contractedPEI.getNetworkService();
- if (vNetworkService != null && vNetworkService.isVPNAdministratorI())
- {
- // get the VPN_ID from the ContractedDNproperties
- Vector<ContractedDNPropertiesI> pCDNPList = contractedPEI.getContractedDNPropertiesI();
- // this service has only one resource asigned, the VPNNumber
- ContractedDNPropertiesI pCDNProp = pCDNPList.firstElement();
- ret = pCDNProp.getVPNI();
- break;
- }
- }
- return ret;
- }
- /**
- * If the contract is a VPN Administrator(subscriber) Contract for the pVPN network, returns the VPN Number that identifies this
- * VPN.
- * This is for feature 53406
- *
- * @author E. Iglesias
- * @return VPNNumber
- */
- @Override
- public VPNNumberI getVPNOwnershipVPNNumberI(VirtualPrivateNetworkI pVPN)
- throws ComponentException, ValidationException
- {
- if (isAgreementContract())
- {
- return null;
- }
- // get the ContractedCompositeProduct
- ContractedCompositeProduct ccp = getContractedCompositeProduct();
- Vector<ContractedProductElement> listPEs = ccp.getContractedProductElements();
- if (listPEs.isEmpty())
- {
- // no ContractedProductElements found !
- throw new ValidationException("Contract.InvalidVPNSubscriberContract",
- new Object[]{Long.valueOf(getIDI()), getPublicKey()});
- }
- Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
- VPNNumberI ret = null;
- while (iterPEs.hasNext())
- {
- // cycle through all ContractedProductElements
- ContractedProductElement contractedPEI = iterPEs.next();
- // if ContractedProductElement is VPN Administrator, the contract is VPN Subscriber Contract
- NetworkServiceI vNetworkService = contractedPEI.getNetworkService();
- if (vNetworkService != null && vNetworkService.isVPNAdministratorI())
- {
- // get the VPN_ID from the ContractedDNproperties
- Vector<ContractedDNPropertiesI> pCDNPList = contractedPEI.getContractedDNPropertiesI();
- // this service has only one resource asigned, the VPNNumber
- ContractedDNPropertiesI pCDNProp = pCDNPList.firstElement();
- if (pCDNProp.getVPNI().getIDI() == pVPN.getIDI())
- {
- ret = (VPNNumberI) pCDNProp.getDirectoryNumberI();
- break;
- }
- }
- }
- return ret;
- }
- /**
- * Has this contract any pending subscription requests ? This method checks whether any contract-level entity is pending. It
- * does NOT iterate through the services. Current implementation is based on the information in memory. Therefore this metod can
- * still return true in a situation when SP FinishRequest was called from GMD-side.
- *
- * @return boolean true - there is pending subscription request(s) for this contract false - there is no pending requests
- * @throws ValidationException
- * @throws ComponentException
- * @throws SystemException
- */
- public boolean hasPendingContractRequests() throws ComponentException, ValidationException
- {
- // get status of the Contract
- ContractStatusI status = getCurrentStatusI();
- // get state of the Contract
- int state = status.getStateI();
- // US 00-10-21 if contract is deactivated, no pending requests can exist
- if (state == ContractStatusI.Deactive)
- {
- return false;
- }
- //
- // for onhold contracts and for contract activated in the same transaction
- // always assume as not pending.
- //
- if (state == ContractStatusI.Onhold || isNew())
- {
- return false;
- }
- //
- // check pending contract status
- // if status is pending then contract is also pending
- if (status.isPendingI() || getPendingStatusI() != null)
- {
- return true;
- }
- if (this.isCustomerContract())
- {
- //
- // check pending rate plan change
- //
- ContractedCompositeProduct compositeProduct = getContractedCompositeProduct();
- if (compositeProduct.getPendingCompositeProductI() != null)
- {
- return true;
- }
- //
- // check pending requested carriers
- //
- // check LocalExchangeCarrier
- if (compositeProduct.getRequestedCarrierI(CarrierRoleI.LocalExchangeCarrier) != null)
- {
- return true;
- }
- if (compositeProduct.getRequestedCarrierI(CarrierRoleI.LongDistanceCarrier) != null)
- {
- return true;
- }
- /*
- * check whether a Storage Medium replacement is pending
- */
- // --> defect 233437 NIJ
- Vector<ContractedResourcesPropertiesI> contrResPropListI = compositeProduct.getContractedResourcesPropertiesI();
- Iterator<ContractedResourcesPropertiesI> iterI = contrResPropListI.iterator();
- while (iterI.hasNext())
- {
- ContractedResourcesPropertiesI crpI = iterI.next();
- if (crpI != null && crpI.getRequestedStateI() != ContractedResourcesPropertiesI.Undefined)
- {
- return true;
- }
- }
- // <-- 233437
- /*
- * 240721
- */
- if (compositeProduct.hasPendingTariffOptionsEntry())
- {
- return true;
- }
- // Removed with 351863.
- /*
- * if (isCloneForUpdate())
- * {
- * if (getContractTaskHandler().isINTriggerRequestRegistered())
- * {
- * return true;
- * }
- * }
- */
- }
- return false;
- }
- /**
- * Has this contract any pending requests ? This method iterates throught the whole contract including the services to find any
- * entity that is pending. Current implementation is based on the information in memory. Therefore this metod can still return
- * true in a situation when SP FinishRequest was called from GMD-side.
- *
- * @return boolean true - there is pending request(s) for this contract false - there is no pending requests
- * @throws ValidationException
- * @throws ComponentException
- * @throws SystemException
- */
- public boolean hasPendingRequests() throws ComponentException, ValidationException
- {
- // TODO_Heidi
- // from Contract:
- // return false;
- // fo CustomerContract and AgreementContract:
- // get status of the Contract
- ContractStatusI status = getCurrentStatusI();
- // get state of the Contract
- int state = status.getStateI();
- // US 00-10-21 if contract is deactivated, no pending requests can exist
- if (state == ContractStatusI.Deactive)
- {
- return false;
- }
- //
- // check pending contract status
- //
- if (status.isPendingI() || getPendingStatusI() != null)
- {
- if (_log.isLoggable(Level.FINE))
- {
- _log.fine("Pending contract (status change) for CO_ID=" + getIDI());
- }
- return true;
- }
- //
- // if not contract status is pending and contract is onhold we can
- // stop immediatly
- //
- if (state == ContractStatusI.Onhold)
- {
- return false;
- }
- if (this.isCustomerContract())
- {
- //
- // check pending rate plan change
- //
- ContractedCompositeProduct compProduct = getContractedCompositeProduct();
- if (compProduct.hasPendingRequests())
- {
- return true;
- }
- ProductSection prodSection = (ProductSection) getProductSectionI();
- List<ContractedRatingOptionVersion> contrRatingOptVersions = prodSection.getContractedRatingOptionVersions();
- for (ContractedRatingOptionVersion contrRatingOptVersion : contrRatingOptVersions)
- {
- if (contrRatingOptVersion.isPending())
- {
- return true;
- }
- }
- if (getCompositeContractSection().getGeneralContractSection().hasPendingRequest())
- {
- return true;
- }
- if (this.hasPendingPamScheme()) {
- return true;
- }
- }
- return false;
- }
- /**
- * Initializes the CustomerContract by setting backward
- * references within its aggregated objects.
- */
- protected void initialize() throws ComponentException
- {
- /*
- * Retrieve the ProductSection
- */
- if (_compositeContractSection != null)
- {
- ProductSection productSection = _compositeContractSection.getProductSection();
- if (productSection != null)
- {
- /*
- * set back reference to this instance
- */
- productSection.initialize();
- }
- }
- else
- {
- _log.severe("Contract package internal error during contract initialization: Contract structure corrupted.");
- }
- }
- /**
- * Check if the contract is an AL contract.
- * Feature 84834 - Alternate Line.
- *
- * @author Renata Spencer
- * @return boolean
- */
- @Override
- public boolean isALContractI()
- {
- if (this.isAgreementContract())
- {
- return false;
- }
- return isChildContract();
- }
- /**
- * Check if the contract is child contract.
- * Feature 84834 - Alternate Line.
- *
- * @author Renata Spencer
- * @return boolean
- */
- public boolean isChildContract()
- {
- return "R".equals(_relationType);
- }
- /**
- * returns the relation type of the contracz
- *
- * @author Calin Naghi
- * @return String
- */
- @Override
- public String getRelationType()
- {
- return _relationType;
- }
- /**
- * isConfirmationGeneratedI. Returns whether the confirmation document has been generated
- *
- * @return boolean
- */
- @Override
- public boolean isConfirmationGeneratedI()
- {
- if (this.isAgreementContract())
- {
- return false;
- }
- return "X".equals(_confirmationGenerated);
- }
- /**
- * Check if the contract is a main contract.
- * Feature 84834 - Alternate Line.
- *
- * @author Renata Spencer
- * @return boolean
- */
- @Override
- public boolean isMainContractI()
- {
- return MAIN.equals(_relationType);
- }
- /**
- * Check if the contract is a related contract.
- * Feature 84834 - Alternate Line.
- *
- * @return boolean
- */
- protected boolean isRelatedContract()
- {
- return RELATED.equals(_relationType);
- }
- /**
- * isNotValidatedI. Returns whether the contract has been validated
- *
- * @return boolean
- */
- @Override
- public boolean isNotValidatedI()
- {
- return "X".equals(_notValidated);
- }
- /**
- * isOnTrialI.
- * Return true if contract is on trial that means trial end date is equal or greater than the current date
- *
- * @return boolean
- */
- @Override
- public boolean isOnTrialI() throws ComponentException
- {
- // TODO_Heidi: only for CustomerContract
- return this.getCompositeContractSection().getProductSection().getTrialPeriodEndDate() >= ServerTime.getCurrentDateAsInt();
- // if agreement contract
- // return false;
- }
- /**
- * This method returns true if this contract is preactivated. We can find out this information via the StorageMedium. If it has
- * a PrepaidProfile associated, then return true Creation date: (7/12/01 10:14:22 AM)
- *
- * @return boolean
- * @author Sergiu Burian
- * @throws ComponentException
- * @throws ValidationException
- */
- public boolean isPreactivatedContract() throws ComponentException, ValidationException
- {
- boolean retValue = false;
- // get the ContractedCompositeProduct
- ContractedCompositeProductI ccpI = getContractedCompositeProductI();
- ContractedCompositeProduct ccp = (ContractedCompositeProduct) ccpI;
- // check if the technology is storage medium driven
- TelecomTechnologyI vTechnology = (TelecomTechnologyI) getContractedCompositeProductI().getTechnologyI();
- if (vTechnology != null && vTechnology.isStorageMediumDrivenI())
- {
- // get the storage medium
- Vector<ResourceI> storageMediumList = ccp.getResourcesByTypeI(ResourceTypeI.storage_medium);
- if (!storageMediumList.isEmpty())
- {
- // get the first element
- StorageMediumI stMed = (StorageMediumI) storageMediumList.firstElement();
- // get prepaid profile for that storage medium
- PrepaidProfileI prepaidProfile = stMed.getPrepaidProfileI();
- // if we get something, that means that this is a preactivated contract : return true
- if (prepaidProfile != null)
- {
- retValue = true;
- }
- }
- }
- return retValue;
- }
- /**
- * Returns true if this contract is a prepaid contract template.
- * Creation date: (7/11/01 11:05:35 AM)
- *
- * @return boolean
- * @author : Sergiu Burian
- */
- @Override
- public boolean isPrepaidContractTemplateI()
- {
- if (this.isAgreementContract())
- {
- return false;
- }
- return "X".equals(_prepaidContractTemplate);
- }
- /**
- * Check if the contract is a regular contract.
- * Feature 84834 - Alternate Line.
- *
- * @author Renata Spencer
- * @return boolean
- */
- @Override
- public boolean isRegularContractI()
- {
- if (this.isAgreementContract())
- {
- return false;
- }
- return NullConversion.isNull(_relationType);
- }
- /**
- * Check if the Contract is a VPN Administrator(subscriber) Contract
- * This is for feature 53406
- *
- * @author E. Iglesias
- * @return boolean
- */
- @Override
- public boolean isVPNSubscriberContractI()
- throws ComponentException, ValidationException
- {
- if (this.isAgreementContract())
- {
- return false;
- }
- // get the ContractedCompositeProduct
- ContractedCompositeProduct ccp = getContractedCompositeProduct();
- // get the Contracted ProductElements
- Vector<ContractedProductElement> listPEs = ccp.getContractedProductElements();
- if (!listPEs.isEmpty())
- {
- Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
- while (iterPEs.hasNext())
- {
- // cycle through all ContractedProductElements
- ContractedProductElement contractedPEI = iterPEs.next();
- // if ContractedProductElement is VPN Administrator, the contract is VPN Subscriber Contract
- NetworkServiceI vNetworkService = contractedPEI.getNetworkService();
- if (vNetworkService != null && vNetworkService.isVPNAdministratorI())
- {
- return true;
- }
- }
- }
- return false;
- }
- /**
- * Check if the Contract is a VPN User Contract
- * This is for feature 53406
- *
- * @author E. Iglesias
- * @return boolean
- */
- @Override
- public boolean isVPNUserContractI()
- throws ComponentException, ValidationException
- {
- if (this.isAgreementContract())
- {
- return false;
- }
- /**
- * The only way to know if a contract is a VPN User Contract is check for
- * the existence of one VPN Access Service
- */
- // get the ContractedCompositeProduct
- ContractedCompositeProduct ccp = getContractedCompositeProduct();
- // Cycle through all ContractedProductElements
- Vector<ContractedProductElement> listPEs = ccp.getContractedProductElements();
- if (!listPEs.isEmpty())
- {
- Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
- while (iterPEs.hasNext())
- {
- ContractedProductElement contractedPE = iterPEs.next();
- int state = contractedPE.getStateI();
- if (state != ContractedProductElementI.Deactive)
- {
- // end 00227033 DAE
- // if ContractedProductElement is VPN Access, the contract is VPN User Contract
- NetworkServiceI vService = contractedPE.getNetworkService();
- if (vService != null && vService.isVPNUserI())
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- /**
- * postBuild. Initializes the CustomerContract
- * This method overwrites the generic method of AbstractDomainObject and will
- * always be called whenever a new CustomerContract is created!!!
- */
- @Override
- public void postBuild() throws ComponentException
- {
- // next is called by Toplink:
- /*
- * Invoke the initialization of the ContractedCustomerProduct
- */
- initialize();
- // from CustomerContract
- /*
- * Invoke the initialization of the Contract
- */
- /*
- * Ensure that this is a new object
- */
- if (isNew())
- {
- /*
- * if the contract was created and not loaded from database set creation date
- */
- _creationDate = ServerTime.getCurrentTime();
- /*
- * Create a new primary key an set the creation date
- */
- createUniqueId();
- /*
- * initialize signing date to system date
- */
- setSigningDateI(ServerTime.getCurrentDateAsInt());
- /*
- * set default value for contract extraction tag
- */
- setExtractionTag(Contract.DEFAULT_EXTRACTION_TAG);
- }
- }
- /**
- * postClone.
- * This method is a hook and hopefully called from top link after cloning
- * an instance.
- */
- @Override
- public void postClone() throws ComponentException
- {
- /*
- * Invoke the initialization of the ContractedCustomerProduct
- */
- initialize();
- // from CustomerContract
- /*
- * create mediation instance to a task management system
- */
- if (_contractTaskHandler == null)
- {
- /*
- * create ContractTaskHandler for registering action to the GMD, send at commit time to GMD
- */
- _contractTaskHandler = AbstractFactory.createObject(ContractTaskHandler.class);
- /*
- * set the backward reference to the contract
- */
- _contractTaskHandler.setContract(this);
- }
- /*
- * initialize status if contract is newly created
- * since we don't have a transaction context at initialisation time
- * This code is really ugly, I know, and if somebody could tell how
- * to do it better, I would really appreciate it!!!
- * US 99-07-27
- */
- if (getOriginalObject().isNew())
- {
- /*
- * create ContractStatus, status is set to "onhold" by its constructor!
- */
- ContractStatus vStatus = AbstractFactory.createObject(ContractStatus.class);
- vStatus.setID(1L);
- _currentStatus = vStatus;
- /*
- * add to list
- */
- Vector<ContractStatus> vContractStati = this.getContractStati();
- vContractStati.add(vStatus);
- this.setContractStati(vContractStati);
- /*
- * set back reference in ContractStatus.
- * Status initialisation (state and reason) is done in the ContractStatus instance.
- */
- vStatus.setContract(this);
- }
- // --> defect 233846 NIJ
- // - reset PROFILE_SERVICE lock object
- _contractedProductElementsLock = null;
- // <-- 233846
- // feature 276491_cms
- if (_concurrentRequestHandler == null)
- {
- /*
- * create ConcurrentRequestHandler
- */
- _concurrentRequestHandler = AbstractFactory.createObject(ConcurrentRequestHandler.class);
- /*
- * set the backward reference to the contract
- */
- _concurrentRequestHandler.setContract(this);
- // _concurrentRequestHandler.loadQueuedRequests();
- }
- }
- /**
- * Callback method for AbstractDomainObject. This mehtod is called after the method validateI is invoked for all updatable
- * object in the commitphase of the transaction context. This method calls the TaskManagement/GMD for handling the provisioning
- *
- * @throws ComponentException
- * @throws SystemException
- */
- @Override
- public void postValidate() throws ComponentException
- {
- if (isCloneForUpdate())
- {
- /*
- * initiate GMD action moved from prepareSave to this location. This method is only called at commit time!!!
- */
- /*
- * generate tasks (if no actions are registered the method immediatly returns)
- */
- // disabled till TaskManagement is working! (US 99-08-31)
- // --> defect 283814 NiJ
- // - Because the cloned objects are beeing held in a HashSet in the framework, it happens randomly
- // - that inside one transaction postValidate of CustomerContract is called before CustomerOrgNode.
- // - Since there might be dependent actions (customer activation + contract activation) ensure that
- // - customer request is generated first in order to be able to set the parent customer activation
- // - request in the contract activation request.
- if (_contractTaskHandler.areTaskRegistered())
- {
- // Check if a contract activation was registered
- ActionDetailsI lContrActionDetailsI = _contractTaskHandler.getActionDetails(ContractSettings.CONTRACT_ACTIVATION);
- if (lContrActionDetailsI == null)
- {
- lContrActionDetailsI = _contractTaskHandler.getActionDetails(TaskManagementSettings.CONTRACT_TAKEOVER_ACTIVATION);
- }
- if (lContrActionDetailsI != null)
- {
- // Check if a customer activation was registered (tasks not yet generated)
- OrgNode lContrHolder = (OrgNode) getContractHolderI();
- CustomerTaskHandler lContrHolderTaskHandler = lContrHolder.getCustomerTaskHandler();
- if (lContrHolderTaskHandler.isCustomerActionRegistered(BusinessPartnerSettings.CUSTOMER_ACTIVATION))
- {
- // Make sure the customer tasks are generated
- lContrHolderTaskHandler.generateTasks();
- }
- // Get generated customer tasks
- List<TaskI> lContrHolderTasks = lContrHolderTaskHandler.getGeneratedTasks();
- if (!lContrHolderTasks.isEmpty())
- {
- int lSize = lContrHolderTasks.size();
- for (int i = 0; i < lSize; i++)
- {
- // Grab the customer activation task
- TaskI lContrHolderTask = lContrHolderTasks.get(i);
- if (lContrHolderTask.getActionIDI() == BusinessPartnerSettings.CUSTOMER_ACTIVATION)
- {
- long lParentRequestId = lContrHolderTask.getIDI();
- // Set the parent request id (customer activation) in the contract activation request
- lContrActionDetailsI.ParentRequest = lParentRequestId;
- break;
- }
- }
- }
- }
- }
- // <-- 283814
- // --> defect 229631-1 NIJ
- // - check if there are any dependant contracts which tasks must be generated first
- // _contractTaskHandler.generateTasks();
- if (_dependentContract != null)
- {
- // generate tasks for dependent contracts first
- _dependentContract.getContractTaskHandler().generateTasks();
- }
- _contractTaskHandler.generateTasks();
- // <-- 229631-1
- /*
- * Ensure that the object has been modified or is a new object
- */
- if (getModified())
- {
- /*
- * Set the modification date and the user
- */
- _modificationDate = ServerTime.getCurrentTime();
- _userOfLastModification = ServiceContext.getCurrent().getUser().getUsername();
- }
- // defect 345307_cms/d
- if (isNew())
- {
- ContractAdministrator administrator = ContractAdministrator.getInstance();
- administrator.createContractCreationEventMessage(this);
- }
- // 345307_cms/d
- }
- }
- /**
- * refreshes this object along with the associated ContractedCompositeProduct-object
- *
- * @throws ComponentException
- * if something fails
- */
- @Override
- public void refreshObject() throws ComponentException
- {
- refreshObject(null);
- }
- /**
- * Refreshes this object, but exclude the passed contract from refresh.
- *
- * @param pContractToSkip
- * @throws ComponentException
- */
- protected void refreshObject(Contract pContractToSkip) throws ComponentException
- {
- // check if there is a pending contract request. If so after the contract refresh a refresh of the contract status have to
- // be forced.
- if (getPendingStatusI() != null)
- {
- super.refreshObject();
- // 00339993: the following forces a refresh of the contract status, otherwise it might happen that the contract is
- // refreshed, but the
- // contract status is refreshed much later. But a contract status change might change REC_VERSION (see
- // contract.finish_request), so
- // refresh of CONTRACT_ALL and CONTRACT_HISTORY must happen together
- if (getPendingStatusI() != null)
- {
- return;
- }
- }
- else
- {
- super.refreshObject();
- }
- /*
- * refresh the associated ContractedCompositeProduct-object
- */
- getContractedCompositeProductI().refreshObject();
- /*
- * We have to do a try if there are pending requests exspecially if the contract we are working on
- * is in an alternate line scenario and there might be a refresh of the other contracts necessary
- * If we are currently on an alternate line contract, we have to refresh the corresponding main contract and
- * all its children except the contract we are currently on to avoid endless recursion.
- */
- if (isMainContractI())
- {
- if (getContractType().isSectionSubsectionUsed(GeneralContractSection.NAME, GeneralContractSection.CONTRACT_RELATION))
- {
- GeneralContractSection generalContractSection = this.getCompositeContractSection().getGeneralContractSection();
- Vector<ContractI> relatedContracts = generalContractSection.getRelatedContracts();
- Iterator<ContractI> iter = relatedContracts.iterator();
- while (iter.hasNext())
- {
- Contract contract = (Contract) iter.next();
- if (null != pContractToSkip)
- {
- if (pContractToSkip != contract)
- {
- contract.refreshObject(pContractToSkip);
- }
- }
- else
- {
- contract.refreshObject(this);
- }
- }
- }
- }
- else if (isALContractI() && null == pContractToSkip)
- {
- if (getContractType().isSectionSubsectionUsed(GeneralContractSection.NAME, GeneralContractSection.CONTRACT_RELATION))
- {
- GeneralContractSection generalContractSection = this.getCompositeContractSection().getGeneralContractSection();
- Contract mainContr = (Contract) generalContractSection.getMainContract();
- mainContr.refreshObject(this);
- }
- }
- // refresh PAM schemes (377727_E08_U07)
- refreshPamSchemes();
- }
- /**
- * replaceDealerI. Replace the dealer, this contract is assigned to.
- *
- * @author Ulrich Schaefer
- * @param pDealer
- * com.lhs.BusinessPartner.bscs_core.external.DealerOrgNodeI
- * @throws ValidationException
- * @throws ComponentException
- * @throws SystemException
- */
- @Override
- public void replaceDealerI(DealerOrgNodeI pDealer, boolean pPropagateToResource)
- throws ComponentException, ValidationException
- {
- /*
- * replace dealer, further action (resource related) only needed if flag in parameters is set!
- */
- if (!this.isAgreementContract())
- {
- this.setDealer(pDealer);
- if (pPropagateToResource)
- {
- /*
- * propagate dealer change to resources
- */
- ChangeDealerVisitor vVisitor = new ChangeDealerVisitor(pDealer);
- this.accept(vVisitor);
- }
- }
- }
- /**
- * retrieveCurrentAndPendingStatus. Retrieves the current and the pending ContractStatus from the list of all contract stati.
- *
- * @throws SystemException
- * @throws ComponentException
- * @throws ValidationException
- * @see com.lhs.Contract.bscs_core.ContractStatus
- */
- synchronized public void retrieveCurrentAndPendingStatus()
- throws ComponentException, ValidationException
- {
- /*
- * Check whether the retrieval is already done
- */
- if (_currentStatus == null)
- {
- ContractStatus currentStatus = null;
- ContractStatus pendingStatus = null;
- ContractStatus status;
- {
- /*
- * Retrieve the list of all stati
- */
- Vector<ContractStatus> stati = getContractStati();
- /*
- * Check wether a current status exists
- */
- if (!stati.isEmpty())
- {
- /*
- * Loop over all stati and look for the current one
- */
- Iterator<ContractStatus> iterator = stati.iterator();
- while (iterator.hasNext())
- {
- ContractStatus tmpStatus = iterator.next();
- /*
- * Check wether it is a pending status
- */
- if (tmpStatus.isPendingI())
- {
- status = pendingStatus;
- }
- else
- {
- status = currentStatus;
- }
- /*
- * Check whether the current/pending status is already set
- */
- if (status != null)
- {
- /*
- * Compare the seqNo of both stati and select the one
- * with the higher seqNo
- */
- if (tmpStatus.getIDI() > status.getIDI())
- {
- status = tmpStatus;
- }
- }
- /*
- * Otherwise just assign the status to the current status
- */
- else
- {
- status = tmpStatus;
- }
- /*
- * Check whether it is a pending status and assign status
- */
- if (tmpStatus.isPendingI())
- {
- pendingStatus = status;
- }
- else
- {
- currentStatus = status;
- }
- }
- /*
- * Assign the temporary current/pending status to the class attribute
- */
- if (currentStatus != null)
- {
- _currentStatus = currentStatus;
- }
- if (pendingStatus != null)
- {
- _pendingStatus = pendingStatus;
- }
- /*
- * Check whether at least a current status has been detected
- */
- if (_currentStatus == null)
- {
- throw new ComponentException("Contract.MissingStatus", new Object[]{Long.valueOf(getIDI())});
- }
- }
- else
- {
- throw new ComponentException("Contract.MissingStatus", new Object[]{Long.valueOf(getIDI())});
- }
- }
- }
- }
- /**
- * setConfirmationGenerated. Sets whether the confirmation document has been generated
- *
- * @param pValue
- */
- public void setConfirmationGenerated(boolean pValue)
- {
- if (pValue)
- {
- _confirmationGenerated = "X";
- }
- else
- {
- _confirmationGenerated = NullConversion.STRING_NULL_VALUE;
- }
- }
- /**
- * setFirstContractHolder. Stores the reference of the OrgNode, the contract is assigned to.
- *
- * @param pOrgNode
- * com.lhs.BusinessPartner.bscs_core.external.OrgNodeI
- * @throws ComponentException
- * @throws ComponentException
- */
- public void setFirstContractHolder(OrgNodeI pOrgNode) throws ComponentException
- {
- /*
- * Store the passed OrgNode
- */
- FWValueHolder.setValue(_firstContractHolder, pOrgNode, this);
- }
- /**
- * setContractHolder. Stores the reference of the OrgNode, the contract is assigned to.
- *
- * @param pOrgNode
- * com.lhs.BusinessPartner.bscs_core.external.OrgNodeI
- * @throws ComponentException
- */
- public void setContractHolder(OrgNodeI pOrgNode)
- throws ComponentException
- {
- /*
- * Store the passed OrgNode
- */
- FWValueHolder.setValue(_contractHolder, pOrgNode, this);
- }
- /**
- * This method was created in VisualAge.
- *
- * @param pStati
- * Vector
- * @throws ComponentException
- */
- public void setContractStati(List<ContractStatus> pStati)
- throws ComponentException
- {
- /*
- * Store the passed list of contract stati
- */
- FWValueHolder.setValue(_contractStati, pStati, this);
- }
- /**
- * setExternalContractReferenceNoI. Set the external identifier for this contract.
- *
- * @param pExternalContractReferenceNo
- */
- @Override
- public void setExternalContractReferenceNoI(String pExternalContractReferenceNo)
- {
- if (!this.isAgreementContract())
- {
- _externalContractReferenceNo = pExternalContractReferenceNo;
- }
- }
- /**
- * setIdOfContractRepresentativeI. Set the id of the contract representative
- *
- * @param pIdOfContractRepresentative
- */
- @Override
- public void setIdOfContractRepresentativeI(String pIdOfContractRepresentative)
- {
- if (!this.isAgreementContract())
- {
- _idOfContractRepresentative = pIdOfContractRepresentative;
- }
- }
- /**
- * Set the current status of the contract.
- *
- * @author Renata Spencer
- * @param pStatus
- * ContractStatusI
- */
- public void setCurrentStatus(ContractStatus pStatus)
- {
- _currentStatus = pStatus;
- }
- /**
- * setNameOfContractRepresentativeI. Set the name of the contract representative
- *
- * @param pNameOfContractRepresentative
- */
- @Override
- public void setNameOfContractRepresentativeI(String pNameOfContractRepresentative)
- {
- if (!this.isAgreementContract())
- {
- _nameOfContractRepresentative = pNameOfContractRepresentative;
- }
- }
- /**
- * setNotValidated. Sets whether the contract is validated
- *
- * @param pValue
- * @throws ComponentException
- * @throws SystemException
- * @throws ValidationException
- */
- public void setNotValidatedI(boolean pValue) throws ComponentException, ValidationException
- {
- /*
- * only an onhold contract can be set to 'not validated'
- */
- if (pValue)
- {
- if (getCurrentStatusI().getStateI() == ContractStatusI.Onhold || getCurrentStatusI().getStateI() == ContractStatusI.Deactive)
- {
- _notValidated = "X";
- }
- else
- {
- throw new ValidationException("Contract.ContractStatusOnholdRequired");
- }
- }
- else
- {
- _notValidated = NullConversion.STRING_NULL_VALUE;
- }
- }
- /**
- * Sets this contract as (not) a prepaid contract template - feat. 202820_3. depending on the input boolean parameter. Creation
- * date: (7/12/01 8:33:56 AM)
- *
- * @author Sergiu Burian
- * @param vFlag
- */
- public void setPrepaidContractTemplate(boolean vFlag)
- {
- if (vFlag)
- {
- _prepaidContractTemplate = "X";
- }
- else
- {
- _prepaidContractTemplate = NullConversion.STRING_NULL_VALUE;
- }
- }
- /**
- * Sets the type of the contract regarding AL:
- * M' - Main contract, 'R' - Related contract, null - regular contract
- * Feature 84834 - Alternate Line.
- *
- * @author Renata Spencer
- * @param pRelationType
- * a String
- */
- public void setRelationType(String pRelationType)
- {
- _relationType = pRelationType;
- }
- /**
- * Sets whether the contract has a service assigned
- *
- * @param pValue
- */
- public void setServicesAssigned(boolean pValue)
- {
- if (pValue)
- {
- _servicesAssigned = "Y";
- }
- else
- {
- _servicesAssigned = NullConversion.STRING_NULL_VALUE;
- }
- }
- /**
- * This method should be called at commit time, this instance has to be a clone!. If the contract is an AL contract, it should
- * belong to the same technology and to the same dealer or service provider of the main contract
- *
- * @return boolean
- * @throws ValidationException
- * @throws ComponentException
- */
- public boolean validateALContract() throws ComponentException, ValidationException
- {
- boolean isValid = true;
- /*
- * only validate if data was changed and if is an AL contract
- */
- if (isALContractI() && getModified())
- {
- /*
- * check whether the technology is the same as in the main contract
- */
- if (!getContractedCompositeProductI().getTechnologyI().equals(
- this.getCompositeContractSection().getGeneralContractSection().getMainContract().getContractedCompositeProductI().getTechnologyI()))
- {
- Contract cContr = (Contract) this.getCompositeContractSection().getGeneralContractSection().getMainContract();
- throw new ValidationException("Contract.InvalidMainContract", Long.valueOf(cContr.getIDI()), cContr.getPublicKey());
- }
- /*
- * check whether the dealer is the same as in the main contract
- */
- OrgNodeI dealer = this.getDealer();
- if (dealer != null && !dealer.equals(((Contract) this.getCompositeContractSection().getGeneralContractSection().getMainContract()).getDealer()))
- {
- Contract cContr = (Contract) this.getCompositeContractSection().getGeneralContractSection().getMainContract();
- throw new ValidationException("Contract.InvalidMainContract", Long.valueOf(cContr.getIDI()), cContr.getPublicKey());
- }
- }
- return isValid;
- }
- /**
- * validateContract. This method should be called at commit time, this instance has to be a clone!. The contract is checked
- * against the rule depending on the Technology and the TechnologyFlavour.
- *
- * @return boolean
- * @throws ValidationException
- * @throws ComponentException
- * @throws SystemException
- */
- public boolean validateContract()
- throws ComponentException, ValidationException
- {
- /*
- * only validate if data was changed
- */
- if (isCloneForUpdate())
- {
- /*
- * check if validation should be performed
- */
- if (!isNotValidatedI() && !isTakeoverContract())
- {
- /*
- * replace "VALIDATEONCOMMIT" with Metaapplication string constant
- */
- /*
- * only check if status is not deactive
- */
- if (getCurrentStatusI().getStateI() != ContractStatusI.Deactive)
- {
- // 236082 removed if (this.isCustomerContract())
- checkConsistency();
- /*
- * 236082_cms removed else if (this.isAgreementContract())
- * this.checkConsistency("VALIDATECUSTOMERCONTRACT");
- */
- List<ContractedDNPropertiesI> list = getActiveDNProperties();
- Iterator<ContractedDNPropertiesI> iter = list.iterator();
- while (iter.hasNext())
- {
- ContractedDNProperties dnProperties = (ContractedDNProperties) iter.next();
- if (dnProperties.getDirectoryNumberI() instanceof PhoneNumber)
- {
- PortingRequest portingRequest = dnProperties.getPortingRequest();
- if (portingRequest != null)
- {
- PhoneNumber number = (PhoneNumber) dnProperties.getDirectoryNumberI();
- if (portingRequest.getStatus().getStateI() == PortingRequestStatus.Faild
- || portingRequest.getStatus().getStateI() == PortingRequestStatus.Cancelled)
- {
- if (PortingAction.PORTING_IN.equals(((PortingAction) portingRequest.getRequestActionI())
- .getRequestActionShortDescr()))
- {
- throw new ValidationException("CMS.TaskManagement.NumberIsNotAllowedToBeUsed", number.getNumberI());
- }
- }
- }
- }
- }
- }
- else
- {
- ContractedCompositeProduct lCCP = getContractedCompositeProduct();
- // get list of ContractedSimpleProduct's assigned to contract
- Vector<ContractedProductElement> lCPEList = lCCP.getContractedProductElements();
- if (!lCPEList.isEmpty())
- {
- // loop through the ContractedProductElement's, get each active ContractedDNProperties and store it
- Iterator<ContractedProductElement> lIterCPE = lCPEList.iterator();
- while (lIterCPE.hasNext())
- {
- ContractedProductElement lCPE = lIterCPE.next();
- Vector<ContractedDNProperties> contrDNProps = lCPE.getContractedDNProperties();
- if (!contrDNProps.isEmpty())
- {
- // loop through the ContractedProductElement's
- Iterator<ContractedDNProperties> lIterator = contrDNProps.iterator();
- while (lIterator.hasNext())
- {
- ContractedDNProperties dnProperties = lIterator.next();
- if (dnProperties.getDirectoryNumberI() instanceof PhoneNumber)
- {
- PhoneNumberPortingInformation info = ((PhoneNumber) dnProperties.getDirectoryNumberI()).getPortingInformation();
- if (info != null)
- {
- PortingRequest portingRequest = (PortingRequest) info.getPortingRequest();
- if (portingRequest != null)
- {
- if (PortingAction.PORTING_OUT.equals(((PortingAction) portingRequest
- .getRequestActionI()).getRequestActionShortDescr()))
- {
- return true;
- }
- }
- }
- }
- }
- }
- }
- }
- // allow modifications for such deactive contracts, that are not deactivated via GMD chain, but immediatly set
- // to deactive.
- // If later in a following transaction such a contract is going to be changed, the change is rejected!
- if (getModified() && !getCurrentStatusI().isNew())
- {
- throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.ModificationOfDeactiveContractNotAllowed");
- }
- }
- /*
- * In future the check will return a generic result set, which provides information about the rules which have
- * failed
- * So far it is returned false to be safe
- */
- /*
- * check the return value
- */
- }
- }
- return true;
- }
- /**
- * Checkes whether the re-rating flag is changed.
- *
- * @return true, if changed; otherwise false
- * @throws ComponentException
- */
- protected boolean isReratingFlagChanged() throws ComponentException
- {
- return ((Contract) getOriginalObject())._isReratingCandidate != _isReratingCandidate;
- }
- // end 288320, Re-rating, MCH 30.06.2008
- /**
- * This method should be called at commit time. It checks, whether the contract type requires special billing accounts. The
- * functionality is called when a contract is activated.
- *
- * @return true if the billing account validation was successfull.
- * @throws ValidationException
- * @throws ComponentException
- */
- public boolean validateBillingAccounts() throws ComponentException, ValidationException
- {
- // only when a activation is performed.
- if (getPendingStatusI() != null && getPendingStatusI().getStateI() == ContractStatusI.Active)
- {
- ContractType contractType = getContractType();
- BillingAdministratorI billAdmin = AdministratorFactory.getInstance().getBillingAdministrator(); // PN 314351, MCH
- // 07.10.2008,
- // refactoring
- OrgNode contractHolder = (OrgNode) getContractHolderI();
- List<BillingAccount> billAccList = billAdmin.getOwnedBillingAccounts(contractHolder);
- if (!contractHolder.isPaymentResponsibleI())
- {
- billAccList = billAdmin.getOwnedBillingAccounts(contractHolder.getPaymentResponsibleI());
- }
- Iterator<BillingAccount> billAccIter = billAccList.iterator();
- boolean hasInvoiceBA = false;
- boolean hasReconBA = false;
- boolean hasCreditMemoBA = false;
- while (billAccIter.hasNext())
- {
- BillingAccount billAcc = billAccIter.next();
- if (billAcc.getInvoiceIndicatorI() == BillingAccountI.IndicatorInvoicing)
- {
- hasInvoiceBA = true;
- }
- if (billAcc.getInvoiceIndicatorI() == BillingAccountI.IndicatorReconciliation)
- {
- hasReconBA = true;
- }
- // 254176_cms
- if (billAcc.getInvoiceIndicatorI() == BillingAccountI.IndicatorCreditMemo)
- {
- hasCreditMemoBA = true;
- }
- }
- // In case a contract type is billing relevant there must be invoice billing account
- boolean isLALeaf = contractHolder.isLeafI() && contractHolder.getParentI() != null;
- // preactivated contracts assigned to a operator are billing relevant, but the operator doesn't have invoice BA,
- // therefore they are excluded from the check
- if (contractType.isBillingRelevant() && !hasInvoiceBA && !isLALeaf && !contractHolder.isHomeOperator())
- {
- throw new ValidationException("Billing.BillingAccount.WrongForContractType", getPublicKey());
- }
- // 254176_cms
- // In case a contract type is reconciliation and credit memo relevant then one reconciliation billing account
- // or one credit memo billing account is sufficient.
- // If a contract type is reconciliation relevant and not credit memo relevant, then there must be a reconciliation
- // billing account. Analog if a contract type is credit memo relevant and not reconciliation relevant, then there
- // must be credit memo billing account
- if (!contractType.isCreditMemoRelevant() && contractType.isReconciliationRelevant() && !hasReconBA)
- {
- throw new ValidationException("Billing.BillingAccount.WrongForContractType", getPublicKey());
- }
- if (!contractType.isReconciliationRelevant() && contractType.isCreditMemoRelevant() && !hasCreditMemoBA)
- {
- throw new ValidationException("Billing.BillingAccount.WrongForContractType", getPublicKey());
- }
- }
- return true;
- }
- /**
- * This method should be called at commit time. This method checks if rate plan, alternate rate plan and prepaid profile
- * assigned to the contract are valid for the business unit of th econtract.
- *
- * @return true if the business unit validation was successfull.
- * @throws ValidationException
- * @throws ComponentException
- */
- public boolean validateBusinessUnit()
- throws ComponentException, ValidationException
- {
- if (getCurrentStatusI().getStateI() == ContractStatusI.Deactive)
- {
- return true;
- }
- boolean isValid = true;
- // change of business unit
- if (!isNew() && ((Contract) this.getOriginalObject()).getBusinessUnitId() != getBusinessUnitId())
- {
- if (getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.CONTRACTED_COMPOSITE_PRODUCT))
- {
- // check for the contracted product
- ContractedCompositeProduct contrCompProduct = getContractedCompositeProduct();
- // 00258863 in case a product change was done in the same transaction as the business unit change
- // then check the pending rate plan instead of the current rate plan
- CompositeProductI pendingComProd = contrCompProduct.getPendingCompositeProductI();
- CompositeProductTemplate compProdTemp;
- if (pendingComProd != null)
- {
- compProdTemp = (CompositeProductTemplate) pendingComProd.getCompositeProductTemplateI();
- }
- else
- {
- compProdTemp = (CompositeProductTemplate) contrCompProduct.getCompositeProductI().getCompositeProductTemplateI();
- }
- if (compProdTemp != null)
- {
- if (!compProdTemp.isAssignedToBusinessUnit(getBusinessUnitId()))
- {
- throw new ValidationException("CMS.Contract.WrongBuUnit",
- "CompositeProduct (RP_CODE)", Long.valueOf(compProdTemp.getIDI()), Long.valueOf(getBusinessUnitId()));
- }
- }
- if (getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.ALTERNATE_TARIFF))
- {
- // check the alternate rate plan
- PricingSchemeI psi = contrCompProduct.getPricingSchemeI(PricingSchemeRoleI.AlternativPricingScheme);
- if (psi != null)
- {
- ProductI product = psi.getProductI();
- if (product != null)
- {
- compProdTemp = (CompositeProductTemplate) ((CompositeProductI) product).getCompositeProductTemplateI();
- if (compProdTemp != null)
- {
- if (!compProdTemp.isAssignedToBusinessUnit(getBusinessUnitId()))
- {
- throw new ValidationException("CMS.Contract.WrongBuUnit",
- "Alternate CompositeProduct (ALT_RPCODE)", Long.valueOf(compProdTemp.getIDI()), Long.valueOf(getBusinessUnitId()));
- }
- }
- }
- }
- }
- }
- if (!NullConversion.isNull(getBillMediumId()))
- {
- // bill medium has changed, check whether this is the right one
- BillMedium lBillMedium = BillMedium.getBillMediumById(getBillMediumId());
- if (!lBillMedium.isAssignedToBusinessUnit(getBusinessUnitId()))
- {
- throw new ComponentException("CMS.BillingAccount.BillMediumNotValidForBU", Long.valueOf(lBillMedium.getIDI()),
- lBillMedium.getShortDescription(), Long.valueOf(getBusinessUnitId()), BusinessUnit.getBusinessUnitById(getBusinessUnitId()));
- }
- }
- }
- // begin 236082_cms
- // check whether a parent contract and its child contracts have the same business unit assigned
- CompositeContractSection compConSection = getCompositeContractSection();
- GeneralContractSection genConSection = compConSection.getGeneralContractSection();
- ContractType contractType = this.getContractType();
- ContractSectionType sectionType = contractType.getContractSectionTypeByName("General Contract Section");
- if (sectionType != null)
- {
- List<ContractI> childList = genConSection.getRelatedContracts();
- if (childList != null)
- {
- Iterator<ContractI> childIter = childList.iterator();
- Contract childContract;
- while (childIter.hasNext())
- {
- childContract = (Contract) childIter.next();
- if (childContract.getBusinessUnitId() != getBusinessUnitId())
- {
- throw new ValidationException("CMS.Contract.RelatedContracts.DifferentBusinessUnits", getPublicKey(), childContract.getPublicKey());
- }
- }
- }
- // Check whether the business unit of the second contract holder is the same as the business unit of the contract.
- // If the second contract holder is the home operator then the contract may have assigned a different
- // business unit because the home operator is always assigned to the default business unit and in case of
- // a multi company setup the default business unit cannot be assigned to a contract.
- OrgNode secondContractHolder = (OrgNode) getContractHolderI();
- // second contract holder is not the home operator
- if (!"O".equals(secondContractHolder.getPartyType()))
- {
- if (getBusinessUnitId() != secondContractHolder.getBusinessUnitId())
- {
- throw new ValidationException("CMS.Contract.SecondContractHolder.DifferentBusinessUnits", getPublicKey(),
- secondContractHolder.getPublicKey());
- }
- }
- }
- // end 236082_cms
- return isValid;
- }
- // begin 236082_cms
- /**
- * checks that no balances are shared among business partner contracts
- *
- * @return true if validation successful
- * @throws ComponentException
- * @throws ValidationException
- * validation
- */
- public boolean validateBalances() throws ComponentException, ValidationException
- {
- OrgNodeI secondContractHolder = getContractHolderI();
- if (secondContractHolder.isBusinessPartner())
- {
- String[] targetCoIds = getTargetContracts();
- if (targetCoIds.length > 0)
- {
- throw new ValidationException("CMS.Contract.BalanaceSharingNotAllowedForBusinessPartnerContracts", getPublicKey());
- }
- }
- return true;
- }
- // end 236082_cms
- /**
- * validateContractHolder. This method should be called at commit time, this instance has to be a clone, if it should be
- * validated!. The contract holder is checked, that means if the holder is active.
- *
- * @return boolean
- * @throws ValidationException
- * @throws ComponentException
- * @throws SystemException
- */
- public boolean validateContractHolder() throws ComponentException, ValidationException
- {
- // From CustomerContract:
- boolean isValid = true;
- if (isCloneForUpdate())
- {
- /*
- * check whether customer assigned to this contract is mandatory
- */
- OrgNodeI vContractHolder = getContractHolderI();
- if (vContractHolder == null)
- {
- throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.MissingContractHolder");
- }
- CustomerOrgNodeI vCustomer = (CustomerOrgNodeI) vContractHolder;
- if (this.isCustomerContract())
- {
- // prepaid templates are assignable only to dummy customers
- if (isPrepaidContractTemplateI())
- {
- // check if the contract holder is a dummy customer
- if (!vCustomer.isDummyCustomerI())
- {
- throw new ValidationException("CMS.Contract.DummyCustomerRequiredForTemplate");
- }
- }
- }
- }
- return isValid;
- }
- // --> defect 233846
- /**
- * Create a database lock on PROFILE_SERVICE table
- *
- * @throws ComponentException
- * @throws ValidationException
- */
- public void createContractedProductElementsLock()
- throws ComponentException, ValidationException
- {
- // do only 1 time and only for large accounts contracts
- if (_contractedProductElementsLock == null && (isLevelContractI() || getContractHolderI().hasParentI()))
- {
- // - In case in the MAD the pesimistic locking of PROFILE_SERVICE is turned on
- // - create the DatabaseLock object so the SELECT..FOR UPDATE NOWAIT is executed
- // - on commit time before the updates on PROFILE_SERVICE are performed.
- // - This way the CMS wont stop and wait in case of existing locks on that table
- // - but will throw an exception.
- boolean lockPROFILE_SERVICE = ContractSettings.LOCK_PROFILE_SERVICE_FORUPDATE;
- if (lockPROFILE_SERVICE)
- {
- // create the database lock object
- _contractedProductElementsLock =
- AbstractFactory.createObject(ContractedProductElementLock.class);
- // initialize the database object in order to pessimistic lock the PROFILE_SERVICE table on commit time
- _contractedProductElementsLock.setCoId(Long.toString(getIDI()));
- }
- }
- }
- // <-- 233846
- /**
- * This method checks for pending balance adjustment requests.
- * A request is pending if CRH_REQUEST.STATUS is 2 (Inserted)
- * or 4 (In progress).
- * Only for BSCS 7.01 and later!!!
- *
- * @return boolean
- * @throws ComponentException
- * @throws SystemException
- * @throws ValidationException
- */
- public boolean hasPendingBARequest()
- throws ComponentException
- {
- long lContractId = getIDI();
- ExpressionBuilder lExpressionBuilder = new ExpressionBuilder();
- Expression lExpression = lExpressionBuilder.get("_contract").get("_id").equal(lContractId);
- long lStatus[] = {2, 4}; // 2: Inserted, 4: In progress
- lExpression = lExpression.and(lExpressionBuilder.get("_status").in(lStatus));
- Vector<?> lCommonRequestListI = AbstractFactory.readQueryObjects(com.lhs.TaskManagement.bscs_core.CommonRequest.class, lExpression);
- if (!lCommonRequestListI.isEmpty())
- {
- return true;
- }
- return false;
- }
- /**
- * @return The method returns true if the contract belongs to the IN platform.
- * This can happen if at least one contracted service is marked as prepaid and/or
- * if the Non-explicit services payment type from CONTR_TARIFF_OPTIONS is set as
- * "pRepaid" or "as Defined in rateplan".
- * @throws ComponentException
- * @throws ValidationException
- * @throws SystemException
- */
- public boolean isINContract()
- throws ComponentException, ValidationException
- {
- if (!getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.CONTRACTED_COMPOSITE_PRODUCT))
- {
- return false;
- }
- int contractState = getCurrentStatusI().getStateI();
- /*
- * Check the non-explicit services payment type
- */
- /*
- * Get the contracted composite product
- */
- ContractedCompositeProduct contractedCompositeProd = getContractedCompositeProduct();
- String nonExplPaymType = contractedCompositeProd.getNonexplServPaymentType();
- // 00259948 if (!(nonExplPaymType.equals(ContractInterOperatorTariffHistory.PAYMENT_TYPE_POSTPAID)))
- if (ContractInterOperatorTariffHistory.PAYMENT_TYPE_PREPAID.equals(nonExplPaymType))
- {
- /*
- * OK. That's enough to recognize that the contract is in IN
- */
- return true;
- }
- Vector<ContractedProductElement> listPEs = contractedCompositeProd.getContractedProductElements();
- if (!listPEs.isEmpty())
- {
- Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
- while (iterPEs.hasNext())
- {
- ContractedProductElementI contractedPEI = iterPEs.next();
- if (contractedPEI.isPrepaidI())
- {
- if (contractState == ContractStatusI.Onhold)
- {
- /*
- * in case of on-hold contracts, we do not care about the service status
- */
- return true;
- }
- int lContractServiceState = contractedPEI.getStateI();
- if (lContractServiceState != ContractedProductElementI.Onhold &&
- lContractServiceState != ContractedProductElementI.Deactive)
- {
- /*
- * At least one prepaid contracted service found.
- * This can happen only if this is an IN contract.
- */
- return true;
- }
- }
- } // iterate through contracted product elements
- }
- /*
- * #TODO Iterate through AL contracts if case.
- */
- /*
- * if we got here, this is no IN contract
- */
- return false;
- }
- /**
- * The method returns all balances monitoring the current contract.
- * The return list is filled with ContractedProductElement objects.
- * It can be called for all balances or only for the Money Wallets.
- *
- * @author Sergiu BURIAN
- * PN 246410
- * @param pMoneyWalletsOnly
- * @param pContractOnly
- * @param pGetMode
- * @return The monitored balance.
- * @throws ValidationException
- * @throws ComponentException
- * @throws SystemException
- */
- public List<ContractedProductElement> getMonitoringBalances(boolean pMoneyWalletsOnly, boolean pContractOnly, int pGetMode)
- throws ComponentException, ValidationException
- {
- ArrayList<ContractedProductElement> lBalList = new ArrayList<ContractedProductElement>();
- List<ContractI> lContracts = null;
- if (!pContractOnly)
- {
- /*
- * The "monitoring" relations work only within contracts
- * that belong to customers that belong to the same family.
- * So far, a family can have only one member.
- * !!! This will change in RBP !!!
- */
- OrgNodeI lCustomer = getContractHolderI();
- // check is only executed for non service provider and contract not belonging to the
- // network operator. Contribution list shouldn't be set anyway.
- // Caution: this check prevents the getContractsI() for service provider and home operators, which
- // would result in a huge result set.
- if (lCustomer.isResellerI() || lCustomer.isHomeOperator())
- {
- lContracts = new ArrayList<ContractI>(1);
- lContracts.add(this);
- }
- else
- {
- /*
- * The "monitoring" relations work only within contracts
- * that belong to customers that belong to the same family.
- * So far, a family can have only one member.
- */
- lContracts = ContractAdministrator.getInstance().getMonitoringRelevantContract(lCustomer);
- if (lContracts.isEmpty())
- {
- lContracts = new ArrayList<ContractI>(1);
- lContracts.add(this);
- }
- }
- }
- else
- {
- lContracts = new ArrayList<ContractI>(1);
- lContracts.add(this);
- }
- Iterator<ContractI> lContrIter = lContracts.iterator();
- while (lContrIter.hasNext())
- {
- ContractI lCrtContr = lContrIter.next();
- int lContractStateI = lCrtContr.getCurrentStatusI().getStateI();
- /*
- * Check if the contract is active
- */
- int lContractPendingState = 0;
- ContractStatusI lContractPendingStatus = lCrtContr.getPendingStatusI();
- if (lContractPendingStatus != null)
- {
- lContractPendingState = lContractPendingStatus.getStateI();
- }
- if (lContractStateI == ContractStatusI.Active && lContractPendingStatus == null ||
- lContractStateI == ContractStatusI.Active && lContractPendingStatus != null
- && (pGetMode == GETBAL_ALL || lContractPendingState == ContractStatusI.Deactive) ||
- lContractStateI == ContractStatusI.Onhold && (pGetMode == GETBAL_ACT_ONHOLD || pGetMode == GETBAL_ALL) ||
- lContractStateI == ContractStatusI.Suspended && pGetMode == GETBAL_ALL)
- {
- ContractedCompositeProduct lConCompProduct = (ContractedCompositeProduct) lCrtContr.getContractedCompositeProductI();
- Vector<ContractedProductElement> lConServices = lConCompProduct.getContractedProductElements();
- Iterator<ContractedProductElement> lServicesIter = lConServices.iterator();
- while (lServicesIter.hasNext())
- {
- ContractedProductElement lConProductElem = lServicesIter.next();
- ProductElementTemplateI lPet = lConProductElem.getProductElementI().getProductElementTemplateI();
- if (!lPet.isCostControlServiceI())
- {
- // ignore this service, only cost control services are considered for the following
- continue;
- }
- int lCurrentState = lConProductElem.getStateI();
- int lPendingState = lConProductElem.getRequestedStateI();
- HistoryI lPendingStatus = lConProductElem.getPendingStatusEntryI();
- if (lCurrentState == ContractedProductElementI.Active && lPendingStatus == null ||
- lCurrentState == ContractedProductElementI.Active && lPendingStatus != null
- && (pGetMode == GETBAL_ALL || lContractPendingState == ContractStatusI.Deactive) ||
- (lCurrentState == ContractedProductElementI.Onhold || lCurrentState == ContractedProductElementI.Deactive)
- && lPendingState == ContractedProductElementI.Active ||
- lCurrentState == ContractedProductElementI.Onhold && (pGetMode == GETBAL_ACT_ONHOLD || pGetMode == GETBAL_ALL) ||
- lCurrentState == ContractedProductElementI.Suspended && pGetMode == GETBAL_ALL)
- {
- boolean lToBeAdded = false;
- NetworkServiceI lNWServI = (NetworkServiceI) lPet;
- CostControlPackage ccPack = (CostControlPackage) lNWServI.getCostControlPackageI();
- if (getIDI() == lCrtContr.getIDI() && (ccPack.isSelfMonitoringBalance() || ccPack.isContractBalanceI()))
- {
- /*
- * Special case if we are looking at the same contract
- * We have to take care about the "Contract balance" flag
- * and about the "Self monitoring flag"
- */
- lToBeAdded = true;
- }
- else
- {
- /*
- * we have to look into its parameters (even though it is the same contract!!!)
- * Remember that the monitoring relation is set via the values
- * of a specific parameter with the "Contribution" purpose
- */
- /*
- * get all current value nodes
- */
- Vector<ParameterValueNodeI> lParameters = lConProductElem.getCurrentParameterValueNodesI();
- int lParamSize = lParameters.size();
- for (int i = 0; i < lParamSize; ++i)
- {
- ParameterValueNodeI lParameterValueI = lParameters.get(i);
- /*
- * Check the purpos -> Contribution
- */
- if (lParameterValueI.getParameterI().getPurposeI() == Parameter.PURPOSE_CONTRIBUTION_LIST)
- {
- ParameterValueNode lParameterValue = (ParameterValueNode) lParameterValueI;
- if (!NullConversion.isNull(lParameterValue.getNumericValue())
- && ((long) lParameterValue.getNumericValue()) == getIDI())
- {
- lToBeAdded = true;
- break;
- }
- }
- }
- }
- // has the service qualified?
- if (lToBeAdded)
- {
- /*
- * if it has to be considered, add it to the list
- * according to the input parameter filter
- */
- if (!pMoneyWalletsOnly || ccPack.isMoneyWalletI())
- {
- lBalList.add(lConProductElem);
- }
- }
- } // end - if the contracted service is active
- } // end of loop through all services
- } // end - if current contract is active
- } // end - iterating through all contracts
- return lBalList;
- }
- private static final int LEVEL_CONTRACT_UNKNOWN = 0;
- private static final int LEVEL_CONTRACT_NO = 1;
- private static final int LEVEL_CONTRACT_YES = 2;
- /**
- * Determines whether the contract is a level contract or not, or
- * if this is not yet defined.
- */
- private transient int _levelContractFlag = LEVEL_CONTRACT_UNKNOWN;
- /**
- * Check if the Contract is a level contract or a standard contract.
- * This is for feature 68993.
- *
- * @author M. Rupprecht
- * @return boolean
- */
- @Override
- public boolean isLevelContractI() throws ComponentException, ValidationException
- {
- boolean ret = false;
- if (this.isAgreementContract())
- {
- return false;
- }
- /*
- * Is the state retrieved yet?
- */
- switch (_levelContractFlag)
- {
- case LEVEL_CONTRACT_UNKNOWN :
- /*
- * Get the contract Holder
- */
- OrgNodeI holder = getContractHolderI();
- /*
- * Get the level of the Holder
- */
- long level = holder.getLevelI();
- /*
- * Test, if the level is the subscriber level
- */
- if (NullConversion.isNull(level))
- {
- return false;
- }
- // This is not a level contract
- _levelContractFlag = LEVEL_CONTRACT_NO;
- ret = false;
- break;
- case LEVEL_CONTRACT_NO :
- ret = false;
- break;
- case LEVEL_CONTRACT_YES :
- ret = true;
- break;
- default :
- throw new IllegalArgumentException("Unknown level contract flag " + _levelContractFlag);
- }
- return ret;
- }
- /**
- * setContractHolderI. Sets the contract holder of the contract. This is for feature 68993.
- *
- * @author M. Rupprecht
- * @param pOrgNode
- * a OrgNodeII
- * @throws SystemException
- * @throws ComponentException
- * @throws ValidationException
- */
- @Override
- public void setContractHolderI(OrgNodeI pOrgNode) throws ComponentException, ValidationException
- {
- /*
- * check if original object is already set and different from the passed object
- */
- Contract vOriginalContract = (Contract) getOriginalObject();
- OrgNodeI vOriginalOrgNode = vOriginalContract.getContractHolderI();
- /*
- * Feature 313299
- * For use in single customer care deployment so as to avoid to allow
- * a post paid customer to be non payment responsible.
- */
- if (!pOrgNode.isPaymentResponsibleI() &&
- CorporateAccountManager.getInstance().isCorporateAccountMemberI(pOrgNode) == LogicalI._False
- && pOrgNode.hasRole(PartyRole.SUBSCRIBER))
- {
- throw new ValidationException("CMS.BusinessPartner.MustBePaymentResp", "Contract holder has SUBSCRIBER role");
- }
- if (vOriginalOrgNode != null)
- {
- if (!vOriginalOrgNode.equals(pOrgNode))
- {
- throw new ComponentException("CMS.Contract.ContractHolderAlreadyAssigned", "Use 'takeover' functionality!");
- }
- /*
- * holder is already set, nothing to do!
- */
- return;
- }
- setContractHolder(pOrgNode);
- }
- /**
- * Flag indicating wether the itemized bill shall be archieved -> 'X', otherwise -> NULL Linked to CONTRACT_ALL.CO_ARCHIVE
- */
- protected String _archivingEnabled = NullConversion.STRING_NULL_VALUE;
- /**
- * Returns a boolean value if archiving is enabled
- *
- * @return boolean
- */
- public boolean isArchivingEnabled()
- {
- return "X".equals(_archivingEnabled);
- }
- /**
- * Set the value if archiving is enabled
- *
- * @retrun none
- * @param pValue
- */
- public void setArchivingEnabled(boolean pValue)
- {
- if (pValue)
- {
- _archivingEnabled = "X";
- }
- else
- {
- _archivingEnabled = NullConversion.STRING_NULL_VALUE;
- }
- }
- /**
- * isArchivingEnabled. Returns a boolean value if archiving is enabled
- *
- * @return boolean
- */
- @Override
- public boolean isArchivingEnabledI()
- {
- if (this.isAgreementContract())
- {
- return false;
- }
- return isArchivingEnabled();
- }
- /**
- * setArchivingEnabledI. Set the value if archiving is enabled
- *
- * @retrun none
- * @param pValue
- * @throws ComponentException
- * @throws ValidationException
- * @throws SystemException
- */
- @Override
- public void setArchivingEnabledI(boolean pValue)
- throws ComponentException, ValidationException
- {
- // Forward the call to the aggregated ItemizedBillSettings
- if (!this.isAgreementContract())
- {
- setArchivingEnabled(pValue);
- // Feat. 83597 - changing the archive flag is rating relevant
- // So, rating provisioning required
- // SB 21-Jul-2001
- // get the contract and all data for rating provisioning
- ContractTaskHandler vContractTaskHandler = getContractTaskHandler();
- long vTime = ServerTime.getCurrentTimeAsLong();
- short vPriority = ContractAdministrator.getInstance().getCommonDomainAdministrator().getUserPriorityI(GMDActionI.ChangeMobileSubscription);
- // register the action for provisioning
- vContractTaskHandler.registerAction(ContractSettings.CONTRACT_PARAMETERS_SET,
- new AbstractDomainObjectI[]{this},
- vTime,
- vPriority,
- TaskTypeI.Provisioning,
- "N", "Y");
- }
- // 00270484
- else
- {
- setArchivingEnabled(pValue);
- }
- }
- /**
- * Checks if user has the proper permission to change the contract status.
- *
- * @param pOldState
- * current state
- * @param pNewState
- * follow-up state
- * @throws ComponentException
- * @throws ValidationException
- */
- public void checkPermissionForTransition(int pOldState, int pNewState) throws ComponentException, ValidationException
- {
- // check if state transition is valid
- ContractStatus currentStatus = (ContractStatus) getCurrentStatusI();
- if (!currentStatus.isFollowStateI(pNewState))
- {
- throw new ValidationException("CMS.Contract.InvalidState");
- }
- String permission = NullConversion.STRING_NULL_VALUE;
- switch (pNewState)
- {
- case ContractStatusI.Active : {
- if (pOldState == ContractStatusI.Suspended)
- {
- permission = "PermContractReactivation";
- }
- else
- {
- permission = "PermContractActivation";
- }
- break;
- }
- case ContractStatusI.Suspended : {
- permission = "PermContractSuspension";
- break;
- }
- case ContractStatusI.Deactive : {
- permission = "PermContractDeactivation";
- break;
- }
- default :
- throw new IllegalArgumentException("Unknown new contract state " + pNewState);
- } // switch
- com.lhs.ccb.sfw.security.UserI user = ServiceContext.getCurrent().getUser();
- if (!user.hasPermission(permission))
- {
- // user does not have the permission
- throw new ValidationException("CMS.Contract.NoPermissionGranted.StatusChange", permission);
- }
- }
- /**
- * Returns the contracts for which this contract is contributing to
- *
- * @return contract ids
- */
- public String[] getTargetContracts()
- {
- String sql = "SELECT co.co_code " +
- "from mkt_parameter p, parameter_value pv, contract_all co, " +
- "profile_service ps, service_parameter sp, mpulknxv nxv, " +
- "pr_serv_status_hist pssh " +
- "where p.purpose ='C' and pv.parameter_id=p.parameter_id and prm_value_number=#CO_ID and " +
- "co.co_id=pv.co_id and ps.co_id=pv.co_id and co.ch_status!='d' and " +
- "ps.status_histno=pssh.histno and pssh.status!='D' and " +
- "ps.co_id= pssh.co_id and " +
- "ps.sncode= pssh.sncode and " +
- "ps.profile_id= pssh.profile_id and " +
- "sp.svcode=nxv.sscode and nxv.sncode=ps.sncode and " +
- "pv.prm_seqno=( select max(pv2.prm_seqno) from parameter_value pv2 where " +
- "pv.parameter_id=pv2.parameter_id and " +
- "pv.prm_value_id=pv2.prm_value_id and " +
- "pv.prm_no=pv2.prm_no and pv.prm_seqno=pv2.prm_seqno and pv.complex_seqno=pv2.complex_seqno and " +
- "pv.parent_seqno=pv2.parent_seqno and pv.sibling_seqno=pv2.sibling_seqno and " +
- "pv.value_seqno=pv2.value_seqno) order by co.co_code";
- ArrayList<Long> arguments = new ArrayList<Long>(1);
- DirectReadQuery query = new DirectReadQuery();
- query.setSQLString(sql);
- query.addArgument("CO_ID");
- arguments.add(Long.valueOf(getIDI()));
- List<String> result = (List<String>) TransactionContext.getCurrent().getUnitOfWork().executeQuery(query, arguments);
- int size = result.size();
- return result.toArray(new String[size]);
- }
- /**
- * Returns the current assigned BOPPackage (if available)
- *
- * @return current assigned BOPPackage
- * @throws ComponentException
- * @throws ValidationException
- * more than one active BOP service
- */
- public BOPPackageVersion getCurrentBOPPackageVersion() throws ComponentException, ValidationException
- {
- ContractedCompositeProduct conCompProd = getContractedCompositeProduct();
- List<ContractedProductElement> conProdElems = conCompProd.getContractedProductElements();
- Iterator<ContractedProductElement> iter = conProdElems.iterator();
- BOPPackage bopPkg = null;
- BOPPackageVersion bopPkgVers = null;
- while (iter.hasNext())
- {
- ContractedProductElement conProdElem = iter.next();
- NetworkServiceI networkService = conProdElem.getNetworkService();
- if (networkService != null)
- {
- if (networkService.getSubtypeI() == NetworkServiceI.BOP_SERVICE_SUBTYPE)
- {
- List<ParameterValueNode> paramValNodes = conProdElem.getCurrentParameterValueNodes();
- Iterator<ParameterValueNode> iter2 = paramValNodes.iterator();
- // Is BOP service activated or to be activated?
- CPEStatusHistoryI pendingStatus = conProdElem.getPendingStatusEntryI();
- if (iter2.hasNext()
- &&
- (
- conProdElem.getStateI() == ContractedProductElementI.Onhold && pendingStatus != null
- && pendingStatus.getStateI() == ContractedProductElementI.Active ||
- conProdElem.getStateI() == ContractedProductElementI.Active && pendingStatus == null
- ))
- {
- if (bopPkg != null)
- {
- throw new ValidationException("CMS.Contract.SeveralActiveBOPServices", Long.valueOf(getIDI()), bopPkg.getLongDescription());
- }
- ParameterValueNode paramValNode = iter2.next();
- long bopPkgId = (long) paramValNode.getNumericValue();
- bopPkg = AbstractFactory.getObjectFromID(BOPPackage.class, Long.valueOf(bopPkgId));
- if (bopPkg != null)
- {
- bopPkgVers = bopPkg.getCurrentVersion();
- }
- }
- }
- }
- }
- return bopPkgVers;
- }
- /**
- * validate BOPPackage assignment
- *
- * @return true if valid BOPPackage assignment, ValidationException is thrown if invalid
- * @throws ComponentException
- * @throws ValidationException
- * BOPPackage assignment is invalid
- */
- public boolean validateBOP() throws ComponentException, ValidationException
- {
- List<String[]> errors = checkBOP();
- if (!errors.isEmpty())
- {
- int size = errors.size();
- ComponentException[] compExcs = new ComponentException[size];
- for (int i = 0; i < size; i++)
- {
- String[] elem = errors.get(i);
- Object[] objArr = new Object[elem.length - 1];
- System.arraycopy(elem, 0, objArr, 0, elem.length - 1);
- compExcs[i] = new ComponentException("CMS.BOP_CONFIG_ERROR_" + elem[elem.length - 1], objArr);
- }
- ComponentException e = new ComponentException("CMS.BOP_CONFIG_ERROR");
- e.addNestedExceptions(compExcs);
- throw e;
- }
- return true;
- }
- // --> defect 286384 NiJ
- /**
- * Checks the rateplan limits for resource assignment (DN_LIMIT, DN_BLOCK_LIMIT, PORT_LIMIT).
- * The resources are checked PER contract. DN_LIMIT is related to the amount of active
- * non-block directory numbers assigned to the contract.
- * DN_BLOCK limit is related to the amount of active block directory numbers assigned to
- * the contract.
- *
- * @throws ComponentException
- */
- public void checkAssignResourceLimits()
- throws ComponentException
- {
- ContractedCompositeProduct lCcp = getContractedCompositeProduct();
- // get the dn limits from the ccp template
- int lDnLimit = lCcp.getCompositeProductI().getCompositeProductTemplateI().getDnLimitI();
- int lDnBlockLimit = lCcp.getCompositeProductI().getCompositeProductTemplateI().getDnBlockLimitI();
- if (lDnLimit != NullConversion.INT_NULL_VALUE ||
- lDnBlockLimit != NullConversion.INT_NULL_VALUE)
- {
- List<ContractedDNPropertiesI> lAllActiveConDNProperties = getActiveDNProperties();
- if (lAllActiveConDNProperties.size() > 0)
- {
- int lDnNums = 0;
- int lDnBlocks = 0;
- ArrayList<PhoneNumberI> lDnBlocksConstPart = new ArrayList<PhoneNumberI>();
- for (int i = 0; i < lAllActiveConDNProperties.size(); i++)
- {
- ContractedDNProperties lcDNprop = (ContractedDNProperties) lAllActiveConDNProperties.get(i);
- DirectoryNumberI lDirNum = lcDNprop.getDirectoryNumberI();
- if (lDirNum instanceof PhoneNumberI)
- {
- PhoneNumberI lPhoneNum = (PhoneNumberI) lDirNum;
- if (lPhoneNum.isBlockDirectoryNumberI())
- {
- // first check if the blocks have not been already retrieved for this directory number
- if (!lDnBlocksConstPart.contains(lPhoneNum))
- {
- // remember the constant part for which the blocks have already been retrieved
- lDnBlocksConstPart.add(lPhoneNum);
- // this is a not yet regarded blocked directory number, get the coresponding blocks
- List<DirectoryNumberBlockI> lCurrentlDirnumBlocks = lPhoneNum.getActiveDirectoryNumberBlocksI();
- if (!lCurrentlDirnumBlocks.isEmpty())
- {
- // add to assigned directory number block list
- lDnBlocks += lCurrentlDirnumBlocks.size();
- }
- }
- }
- else
- {
- // add to assigned directory number list (used for PhoneNumber types)
- lDnNums++;
- }
- }
- else
- {
- // add to assigned directory number list (used for any other types derived from DirectoryNumber)
- lDnNums++;
- }
- }
- // check directory number assignment limit
- if (lDnLimit != NullConversion.INT_NULL_VALUE && lDnNums > lDnLimit)
- {
- // error
- throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.ExceededDirnumAssignmentLimit",
- Integer.valueOf(lDnLimit),
- Long.valueOf(lCcp.getCompositeProductI().getIDI()),
- lCcp.getCompositeProductI().getShortNameI());
- }
- // check directory number block assignment limit
- if (lDnBlocks > 0)
- {
- if (lDnBlockLimit != NullConversion.INT_NULL_VALUE && lDnBlocks > lDnBlockLimit)
- {
- throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.ExceededDirnumBlockAssignmentLimit",
- Integer.valueOf(lDnBlockLimit),
- Long.valueOf(lCcp.getCompositeProductI().getIDI()),
- lCcp.getCompositeProductI().getShortNameI());
- }
- }
- }
- }
- // get the port limits from the ccp template
- int lDnPortLimit = lCcp.getCompositeProductI().getCompositeProductTemplateI().getPortLimitI();
- // check PORT_LIMIT, if no port limit exists return immediatly.
- if (lDnPortLimit != NullConversion.INT_NULL_VALUE)
- {
- List<ContractedPortPropertiesI> lAllActiveConPortProperties = getActivePortProperties();
- // check PORT_LIMIT && check if there are any active ports attached to the service
- if (lAllActiveConPortProperties.size() > lDnPortLimit && lDnPortLimit > 0)
- {
- throw new ValidationException("CMS.Contract.ConsistencyCheckFailed.ExceededPortAssignmentLimit",
- Integer.valueOf(lDnPortLimit),
- Long.valueOf(lCcp.getCompositeProductI().getIDI()),
- lCcp.getCompositeProductI().getShortNameI());
- }
- }
- }
- // <-- 286384
- /**
- * For an BOP contract it is not allowed to have billing accounts below the contract-level
- * i.e. profile-, service- or charge-type-level.
- *
- * @return true if billing account assignment is consistent, false otherwise
- * @throws ComponentException
- */
- protected boolean checkBillingAccountsForBOP() throws ComponentException
- {
- BillingAdministratorI billAdmin = AdministratorFactory.getInstance().getBillingAdministrator(); // PN 314351, MCH
- // 07.10.2008, refactoring
- List<BillingAccountAssignment> billAccAssignList = billAdmin.getExplicitBillAccAssignments(getIDI(), ServerTime.getCurrentTime());
- Iterator<BillingAccountAssignment> billAccAssignIter = billAccAssignList.iterator();
- boolean ok = true;
- BillingAccountAssignment billAccAssign;
- while (ok && billAccAssignIter.hasNext())
- {
- billAccAssign = billAccAssignIter.next();
- if (billAccAssign.getBillingAccAssignTemplateVersion() != null)
- {
- List<BillingAccountAssignmentTemplateRule> rules =
- billAccAssign.getBillingAccAssignTemplateVersion().getBillingAccountAssignmentTemplateRules();
- for (BillingAccountAssignmentTemplateRule rule : rules)
- {
- ok = NullConversion.isNull(rule.getChargeTypeId()) &&
- NullConversion.isNull(rule.getProfileId()) &&
- NullConversion.isNull(rule.getService());
- }
- }
- }
- return ok;
- }
- /**
- * check BOPPackage assignment
- *
- * @return list of errors and parameters
- * @throws ComponentException
- * @throws ValidationException
- */
- protected List<String[]> checkBOP() throws ComponentException, ValidationException
- {
- if (!getContractType().isSectionSubsectionUsed(ProductSection.NAME, ProductSection.ALTERNATE_TARIFF))
- {
- // no BOP supported for this type of contract
- return new ArrayList<String[]>(0);
- }
- BOPPackageVersion bopPkgVers = getCurrentBOPPackageVersion();
- List<String[]> errors = null;
- if (bopPkgVers != null)
- {
- ContractedCompositeProduct conCompProd = getContractedCompositeProduct();
- CompositeProduct compProd = null;
- if (conCompProd.getPendingCompositeProductI() != null)
- {
- compProd = (CompositeProduct) conCompProd.getPendingCompositeProductI();
- }
- else
- {
- compProd = (CompositeProduct) conCompProd.getCompositeProductI();
- }
- List<ContractedProductElement> conProdElems = conCompProd.getContractedProductElements();
- Iterator<ContractedProductElement> iter = conProdElems.iterator();
- ProductElement[] prodElems = new ProductElement[conProdElems.size()];
- SimpleProduct[] simpleProds = new SimpleProduct[conProdElems.size()];
- int count = 0;
- errors = new ArrayList<String[]>(3);
- // we have a BOP service
- if (conCompProd.getContractedProductElementMap().size() > 1)
- {
- throw new ValidationException("CMS.Contract.InvalidNumberOfProfiles");
- }
- else if (conCompProd.getContractedProductElementMap().get(TopologyAdministrator.getInstance().getDefaultProfileI()) == null)
- {
- throw new ValidationException("CMS.Contract.InvalidProfile");
- }
- while (iter.hasNext())
- {
- ContractedProductElement conProdElem = iter.next();
- CPEStatusHistoryI currStatus = conProdElem.getCurrentStatusEntry();
- CPEStatusHistoryI pendingStatus = conProdElem.getPendingStatusEntryI();
- // only check for activated or to be activated services
- if (currStatus.getStateI() == ContractedProductElementI.Active ||
- pendingStatus != null &&
- pendingStatus.getStateI() == ContractedProductElementI.Active)
- {
- prodElems[count] = (ProductElement) conProdElem.getProductElementI();
- simpleProds[count] = (SimpleProduct) conProdElem.getSimpleProduct();
- NetworkServiceI service = conProdElem.getNetworkService();
- count++;
- if (service != null)
- {
- // check whether it is a free unit service
- if (service.isFreeUnitTypeI())
- {
- // get parameter for free unit package
- List<ParameterValueNode> paramValNodes = conProdElem.getCurrentParameterValueNodes();
- Iterator<ParameterValueNode> iter2 = paramValNodes.iterator();
- // Is FU service activated or to be activated?
- while (iter2.hasNext())
- {
- ParameterValueNode paramValNode = iter2.next();
- // the free unit parameter is the only single entry parameter
- if (paramValNode.isSingleEntryParameterValueNode())
- {
- long fupPkgId = (long) paramValNode.getNumericValue();
- FreeUnitPackageTemplate fuPkg = AbstractFactory.getObjectFromID(FreeUnitPackageTemplate.class, Long.valueOf(fupPkgId));
- if (fuPkg != null && !"B".equals(fuPkg.getApplicationMethodI()))
- {
- errors.add(new String[]{getPublicKey(), fuPkg.getShortDescriptionI(), service.getShortNameI(),
- String.valueOf(BOPPackageVersion.BOP_ERROR_CO_HAS_EXPL_NON_BILLING_TIME_FUP)});
- }
- }
- }
- }
- }
- }
- }
- errors.addAll(bopPkgVers.checkServiceConfiguration(compProd, simpleProds, prodElems));
- String[] coCodes = getTargetContracts();
- if (coCodes.length > 0)
- {
- StringBuilder coCodesStr = new StringBuilder();
- for (int i = 0; i < coCodes.length; i++)
- {
- if (i > 0)
- {
- coCodesStr.append(", ");
- }
- coCodesStr.append(coCodes[i]);
- }
- errors.add(new String[]{getPublicKey(), coCodesStr.toString(), String.valueOf(BOPPackageVersion.BOP_ERROR_BOP_CONTRACT_CONTRIBUTES)});
- }
- if (!checkBillingAccountsForBOP())
- {
- errors.add(new String[]{getPublicKey(), String.valueOf(BOPPackageVersion.BOP_ERROR_BOP_CONTRACT_WRONG_BILLING_ACCOUNT)});
- }
- }
- else
- {
- errors = new ArrayList<String[]>(0);
- }
- return errors;
- }
- /**
- * Set the type of the contract, only type 'S' is allowed for this class.
- */
- @Override
- public void setTypeI(String pType)
- {
- _type = pType;
- }
- /**
- * Indicates if the contract has a BOP service assigned
- *
- * @return true if the contract has a BOP service
- * @throws ComponentException
- * @throws ValidationException
- */
- public boolean hasBOPService() throws ComponentException, ValidationException
- {
- ContractedCompositeProduct conCompProd = getContractedCompositeProduct();
- List<ContractedProductElement> conProdElems = conCompProd.getContractedProductElements();
- Iterator<ContractedProductElement> iter = conProdElems.iterator();
- while (iter.hasNext())
- {
- ContractedProductElement conProdElem = iter.next();
- if (conProdElem.getServiceSubtypeI() == NetworkServiceI.BOP_SERVICE_SUBTYPE)
- {
- return true;
- }
- }
- return false;
- }
- /**
- * @see com.lhs.Contract.bscs_core.external.ContractI#getCustomizationSectionI()
- */
- @Override
- public CustomizationSectionI getCustomizationSectionI()
- {
- return _compositeContractSection.getCustomizationSection();
- }
- /**
- * getTrialPeriodStartDate. Returns the date, when the trial period for this Contract starts.
- *
- * @return int
- */
- public int getTrialPeriodStartDate()
- {
- return CAASDateConverter.toCAASDate(_trialPeriodStartDate);
- }
- /**
- * setTrialPeriodStartDate. Set the date, when the trial period for this Contract starts.
- *
- * @param pTrialStartDate
- */
- public void setTrialPeriodStartDate(int pTrialStartDate)
- {
- _trialPeriodStartDate = CAASDateConverter.toDate(pTrialStartDate);
- }
- /**
- * getTrialPeriodEndDateI. Returns the date, when the trial period for this Contract ends.
- *
- * @return int
- */
- public int getTrialPeriodEndDate()
- {
- return CAASDateConverter.toCAASDate(_trialPeriodEndDate);
- }
- /**
- * setTrialPeriodEndDateI. Sets the date, when the trial period for this contract will end. Behaviour must be as follows in CMS:
- * >> save old trial end date (of contract) #old_trial_date = SELECT TRIAL_END_DATE FROM CONTRACT_ALL WHERE CO_ID =
- * #given_contract_id >> set new trial end date of contract UPDATE CONTRACT_ALL SET TRIAL_END_DATE = #new_trial_date WHERE CO_ID
- * = #given_contract_id >> set trial end date of contracted services which >> - don't have a trial date or >> - whose trial is
- * older than the new trial date >> - whose trial date is equal to the old trial date of the contract UPDATE PROFILE_SERVICE SET
- * TRIAL_END_DATE = #new_trial_date WHERE CO_ID = #given_contract_id AND ((TRIAL_END_DATE IS NULL) OR (TRIAL_END_DATE <
- * #new_trial_date) OR (TRIAL_END_DATE = #old_trial_date)) >> modify contract ( UPDATE CONTRACT_ALL SET TRIAL_END_DATE =
- * #new_trial_end_date, CO_USERLASTMOD = #current_user, CO_MODDATE = sysdate, REC_VERSION = #incremented_rec_version WHERE
- * ((CO_ID = #given_contract) AND (REC_VERSION = #old_rec_version)) >> create rating provisioning request because the trial end
- * date is influences rating INSERT INTO GMD_REQUEST_BASE (REQUEST_ID, ENTRY_DATE) VALUES (#new_request_id, sysdate) INSERT INTO
- * MDSRRTAB (PROVISIONING_FLAG, ACTION_DATE, INSERTED_BY_TARGYS, REQUEST, RATING_FLAG, VMD_RETRY, STATUS, REQUEST_UPDATE,
- * PRIORITY, TS, SWITCH_ID, ERROR_CODE, GMD_MARKET_ID, ERROR_RETRY, ACTION_ID, INSERT_DATE, DATA_1, WORKER_PID, DATA_2,
- * PARENT_REQUEST, DATA_3, SCCODE, PLCODE, CO_ID, CUSTOMER_ID, USERID) VALUES('N', sysdate, 'X', #request_id, 'Y', 0, 2, null,
- * 0, sysdate, #switch_id, 0, #gmd_market_id, 0, #action_id, sysdate, null, 0, null, null, null, #market_id, #network,
- * #given_contract_id, #given_customer_id, #current_user)
- *
- * @param pTrialEndDate
- * new trial period end date
- * @throws SystemException
- * @throws ComponentException
- * @throws ValidationException
- */
- public void setTrialPeriodEndDate(int pTrialEndDate)
- throws ComponentException, ValidationException
- {
- // From CustomerContract
- // ---> begin of defect 242337 (OH)
- // In the following code whether the new trial end date can be set on the contract:
- //
- // check whether technology supports on trial contracts
- ContractedCompositeProduct ccp = getContractedCompositeProduct();
- TelecomTechnologyI technology = (TelecomTechnologyI) ccp.getTechnologyI();
- // 236082_cms exclude agreement contracts
- ContractType contractType = getContractType();
- if (!contractType.isContractAgreementType() && technology != null && !technology.isTrialPeriodSupportedI())
- {
- // in case the end date is a null value, it does not switch on trial contract, therefore just return
- if (NullConversion.isNull(pTrialEndDate))
- {
- return;
- }
- throw new ValidationException("CMS.Contract.TechnologyDoesNotSupportOnTrialContracts");
- }
- // check whether trial end date is not in the future (past days or today)
- int currentDate = ServerTime.getCurrentDateAsInt();
- // DAE 00245602 TrialEndDate must be possible set to NULL
- Date vDate = CAASDateConverter.toDate(pTrialEndDate);
- if (pTrialEndDate != NullConversion.INT_NULL_VALUE && pTrialEndDate <= currentDate)
- {
- throw new ValidationException("CMS.Contract.InvalidTrialEndDate.LessThanCurrent",
- vDate);
- }
- int expirationDate = getExpirationDateI();
- // check whether contract is still on trial (old trial end date is set and still in the future)
- if (isOnTrialI())
- {
- // check whether contract expires before new trial end date
- if (!NullConversion.isNull(expirationDate) && pTrialEndDate > expirationDate)
- {
- // defect 00254807/d APO
- // throw new ValidationException( "Contract.InvalidTrialEndDate.GreaterThanExpiration");
- throw new ValidationException("CMS.Contract.InvalidTrialEndDate.GreaterThanExpiration",
- vDate, CAASDateConverter.toDate(expirationDate));
- // end 00254807/d
- }
- }
- else
- {
- // check whether contract (that is not on trial) is in state onhold
- if (getCurrentStatusI().getStateI() == ContractStatusI.Onhold)
- {
- // check whether new trial end date is less or equal to contract expiration date
- if (!NullConversion.isNull(expirationDate))
- {
- // defect 00254807/d APO
- // throw new ValidationException( "Contract.InvalidTrialEndDate.GreaterThanExpiration");
- if (NullConversion.INT_NULL_VALUE == pTrialEndDate)
- {
- throw new ValidationException("CMS.Contract.InvalidTrialEndDate.GreaterThanExpiration",
- "", CAASDateConverter.toDate(expirationDate));
- }
- throw new ValidationException("Contract.InvalidTrialEndDate.GreaterThanExpiration",
- vDate, CAASDateConverter.toDate(expirationDate));
- }
- // End 00254807/d
- }
- else
- {
- // an active, deactive or suspended contract can not be set to 'on trial'!
- throw new ValidationException("Contract.ContractStatusOnholdRequired");
- }
- }
- // save old trial end date
- int oldTrialPeriodEndDate = CAASDateConverter.toCAASDate(_trialPeriodEndDate);
- // set new trial end date
- _trialPeriodEndDate = CAASDateConverter.toDate(pTrialEndDate);
- // create rating provisioning request for changing the trial end date on the contract
- short priority = ContractAdministrator.getInstance().getCommonDomainAdministrator().
- getUserPriorityI(GMDActionI.ChangeMobileSubscription);
- getContractTaskHandler().registerAction(
- ContractSettings.CONTRACT_PARAMETERS_SET,
- new AbstractDomainObjectI[]{this},
- currentDate, priority, TaskTypeI.Provisioning, "N", "Y");
- // iterate through all contracted services / contracted product elements and set the trial end date
- ContractTaskHandler vTaskHandler = getContractTaskHandler();
- priority = ContractAdministrator.getInstance().getCommonDomainAdministrator().
- getUserPriorityI(GMDActionI.ServiceControl);
- String provFlag = "N";
- String ratingFlag = "Y";
- Vector<ContractedProductElement> cpeList = ccp.getContractedProductElements();
- Iterator<ContractedProductElement> lIter = cpeList.iterator();
- while (lIter.hasNext())
- {
- ContractedProductElement cpe = lIter.next();
- final int lTrialPeriodEndDateI = cpe.getTrialPeriodEndDateI();
- // check whether:
- // (trial end date of contracted service is not set) OR
- // (trial end date of contracted service is less than new trial end date of contract) OR
- // (trial end date of contracted service is equal to old trial end date of contract)
- if (NullConversion.isNull(lTrialPeriodEndDateI) ||
- lTrialPeriodEndDateI < pTrialEndDate ||
- lTrialPeriodEndDateI == oldTrialPeriodEndDate)
- {
- // create rating provisioning request for the changing trial end date on the contracted service
- vTaskHandler.registerAction(ContractSettings.SL_CHANGE_TRIAL_DATE,
- new AbstractDomainObjectI[]{this, cpe},
- currentDate, priority, TaskTypeI.Provisioning, provFlag, ratingFlag);
- // trial end date on service
- cpe.setTrialPeriodEndDate(pTrialEndDate);
- }
- }
- // ---> end of defect 242337 (OH)
- }
- /**
- * setDealer. Stores the reference of the DealerOrgNode, the contract is assigned to. This method does not perform any checks.
- *
- * @param pDealerOrgNode
- * com.lhs.BusinessPartner.bscs_core.external.DealerOrgNodeI
- * @throws ComponentException
- */
- public void setDealer(OrgNodeI pDealerOrgNode) throws ComponentException
- {
- if (!isAgreementContract())
- {
- /*
- * Store the passed DealerOrgNode
- */
- FWValueHolder.setValue(_dealer, pDealerOrgNode, this);
- }
- }
- /**
- * getDealerI. Returns the dealer, this Contract is assigned to.
- *
- * @return com.lhs.BusinessPartner.bscs_core.external.OrgNodeI
- */
- public OrgNodeI getDealer()
- {
- if (isAgreementContract())
- {
- return null;
- }
- // might be a dealer or a service provider!
- return FWValueHolder.getValue(_dealer);
- }
- /**
- * Gets the Foreign Network.
- *
- * @return _foreignNetwork
- */
- public Network getForeignNetwork()
- {
- return FWValueHolder.getValue(_foreignNetwork);
- }
- /**
- * Sets the Foreign Network.
- *
- * @param pNetwork
- * @throws ComponentException
- */
- public void setForeignNetwork(Network pNetwork) throws ComponentException
- {
- FWValueHolder.setValue(_foreignNetwork, pNetwork, this);
- }
- // begin 236082_cms
- /**
- * checks whether a party role and party type combination of the current user matches the party type and the party role of the
- * second contract holder.
- *
- * @throws ComponentException
- * @return true if user has sufficient permissions, false otherwise.
- */
- public boolean hasPartyTypeAndRolePermission() throws ComponentException
- {
- com.lhs.CommonDomain.bscs_core.CMSUserI user = CMSUser.getCMSUser();
- ContractType contractType = getContractType();
- OrgNode secondContractHolder = (OrgNode) getContractHolderI();
- long secondPartyRoleId = contractType.getSecondPartyRole().getId();
- char secondPartyTypeId = secondContractHolder.getPartyType().charAt(0);
- return user.isAuthorizedForPartyRoleConfig(secondPartyTypeId, secondPartyRoleId);
- }
- /**
- * checks whether a party role and party type combination of the current user matches the party type and the party role of the
- * second contract holder.
- *
- * @throws ComponentException
- * in case the user has not sufficient rights (party role and party type combinations do not match)
- */
- public void checkPartyTypeAndRolePermission() throws ComponentException
- {
- if (!hasPartyTypeAndRolePermission())
- {
- com.lhs.CommonDomain.bscs_core.CMSUserI user = CMSUser.getCMSUser();
- ContractType contractType = getContractType();
- throw new ComponentException("CMS.Contract.UserNotAllowed", user.getName(), getPublicKey(), contractType.getShortName());
- }
- }
- // end 236082_cms
- /**
- * set type of call detail generation. Possible values: P, R, null
- */
- @Override
- public void setCallDetail(char pCallDetailFlag)
- {
- if (!NullConversion.isNull(pCallDetailFlag) && pCallDetailFlag != 'R' && pCallDetailFlag != 'P')
- {
- throw new ComponentException(DomainService.RC_INVALID_PARAMETER_VALUE, "CALL_DETAIL", "P,R,NULL");
- }
- if (!isNew() && pCallDetailFlag != _callDetail)
- {
- createCallDetailChangeTickler(pCallDetailFlag);
- }
- _callDetail = pCallDetailFlag;
- }
- /**
- * Create a tickler for a call detail change.
- *
- * @param pCallDetailFlag
- */
- protected void createCallDetailChangeTickler(char pCallDetailFlag)
- {
- // create a tickler
- SystemEventMessageDefinitionI definition = new SystemEventMessageDefinitionI();
- definition.OrgNode = this.getContractHolderI();
- definition.Contract = this;
- definition.ShortDescription = TICKLER_CALLDETAIL_SHORT_DESC;
- if (NullConversion.isNull(pCallDetailFlag))
- {
- definition.LongDescription = NLSAdministrator.getInstance().translate("nlsCallDetailDisabled");
- }
- else
- {
- // - Enhance long description by adding the P (periodically) or R (on request) flag in order to see which option was
- // choosen when enabling the
- // - call detail statement.
- definition.LongDescription = NLSAdministrator.getInstance().translate("nlsCallDetailEnabled", Character.valueOf(pCallDetailFlag));
- }
- definition.Status = TICKLER_STATUS_NOTE;
- definition.Priority = 4;
- BusinessPartnerEventManagementAdministrator.getInstance().createSystemEventMessageI(definition);
- }
- /**
- * indicates which address shoudl be used.
- *
- * @param pFlag
- */
- @Override
- public void setUseUserInstallationAddress(boolean pFlag)
- {
- if (pFlag)
- {
- _useUserInstallationAddress = "X";
- }
- else
- {
- _useUserInstallationAddress = NullConversion.STRING_NULL_VALUE;
- }
- }
- /**
- * sets the bill medium id
- *
- * @param pBillMediumId
- */
- @Override
- public void setBillMedium(long pBillMediumId)
- {
- _billMediumId = pBillMediumId;
- }
- /**
- * returns the call detail flag
- *
- * @return The call detail setup.
- */
- @Override
- public char getCallDetail()
- {
- return _callDetail;
- }
- /**
- * returns is the call detail statement should be printed
- *
- * @return boolean
- */
- @Override
- public boolean isCallDetailEnabled()
- {
- return _callDetail == CALL_DETAIL_STMT_ON_REQUEST || _callDetail == CALL_DETAIL_STMT_PERIODICALLY;
- }
- /**
- * returns true if user/installation address should be printed on call detail statement
- *
- * @return boolean
- */
- @Override
- public boolean useUserInstallationAddress()
- {
- return "X".equals(_useUserInstallationAddress);
- }
- /**
- * returns the contracted bill medium id
- *
- * @return long
- */
- @Override
- public long getBillMediumId()
- {
- return _billMediumId;
- }
- /**
- * Hook called when instance is refreshed.
- */
- @Override
- public void postRefresh() throws ComponentException, ValidationException
- {
- // update the transient smart refs as well since the data might have changed on the database
- cleanTransientReferences();
- }
- /**
- * Optional callback method, invoked after the clone object has merged
- * with the original object (this happens after commit).
- * Defect 00266184
- */
- @Override
- public void postMerge()
- {
- // reset transient field, will be filled with next access
- cleanTransientReferences();
- }
- /**
- * @return The method returns true if the contract has post- and pre-paid services. *
- * @throws ComponentException
- * @throws ValidationException
- */
- public boolean isMixedContract() throws ValidationException, ComponentException
- {
- /*
- * Get the contracted composite product
- */
- ContractedCompositeProduct contractedCompositeProd = getContractedCompositeProduct();
- Vector<ContractedProductElement> listPEs = contractedCompositeProd.getContractedProductElements();
- if (!listPEs.isEmpty())
- {
- Iterator<ContractedProductElement> iterPEs = listPEs.iterator();
- while (iterPEs.hasNext())
- {
- ContractedProductElementI contractedPEI = iterPEs.next();
- if (contractedPEI.isPrepaidI() && contractedPEI.getPrepaidTimePackageI() != null)
- {
- return true;
- }
- if (!contractedPEI.isPrepaidI())
- {
- ProductElementTemplateI vTemplate = contractedPEI.getProductElementI().getProductElementTemplateI();
- if (vTemplate instanceof NetworkServiceI)
- {
- NetworkService lNetworkService = (NetworkService) vTemplate;
- if (!contractedPEI.isValueAddedServiceI() && lNetworkService.isRatingRelevant())
- {
- return true;
- }
- }
- }
- // in case access and subscription charges are postpaid, return immediatly.
- if (!contractedPEI.hasPrepaidAccessAndSubscriptionCharges())
- {
- return true;
- }
- }
- }
- return false;
- }
- // APO 00260533_cms
- /**
- * check product change request
- *
- * @return true if there is a pending rate plan or service package request.
- * @throws ComponentException
- * @throws ValidationException
- */
- public boolean hasProductChangeRequest() throws ComponentException, ValidationException
- {
- // check pending rate plan change
- ContractedCompositeProduct compositeProduct = getContractedCompositeProduct();
- if (compositeProduct.getPendingCompositeProductI() != null)
- {
- return true;
- }
- // check pending service package change
- if (compositeProduct.hasPendingSPchangeRequest())
- {
- return true;
- }
- return false;
- }
- /**
- * Get the contract next status sequence number.
- *
- * @return The next contract status sequence number.
- */
- public long getNextContractStatusSeqNo()
- {
- if (_currentStatus == null)
- {
- retrieveCurrentAndPendingStatus();
- }
- if (_pendingStatus != null)
- {
- return _pendingStatus.getIDI() + 1;
- }
- if (_currentStatus != null)
- {
- return _currentStatus.getIDI() + 1;
- }
- return 1L;
- }
- /**
- * Returns the charging period adjustment reference.
- * For services with charging schedule
- * set to "Cut off date related".
- * Domain:
- * 'B' - Billing period reference date
- * 'A' - Contract activation date
- *
- * @return Returns the charging period adjustment reference.
- */
- public char getChargingPeriodAdjustmentReference()
- {
- return _chargingPeriodAdjustmentReference;
- }
- /**
- * Sets the charging period adjustment reference.
- * For services with charging schedule
- * set to "Cut off date related".
- * Domain:
- * 'B' - Billing period reference date
- * 'A' - Contract activation date
- *
- * @param pChargingPeriodAdjustmentReference
- * The charging period adjustment reference to set.
- */
- public void setChargingPeriodAdjustmentReference(
- char pChargingPeriodAdjustmentReference)
- {
- _chargingPeriodAdjustmentReference = pChargingPeriodAdjustmentReference;
- }
- /**
- * Returns the identifier of the medium for notification messages.
- *
- * @return Returns the notification medium identifier.
- */
- public long getNotificationMediumId()
- {
- return _notificationMediumId;
- }
- /**
- * Sets the identifier of the medium for notification messages.
- *
- * @param pNotificationMediumId
- * The notification medium identifier to set.
- */
- public void setNotificationMediumId(long pNotificationMediumId)
- {
- _notificationMediumId = pNotificationMediumId;
- }
- /**
- * Returns the charge start date.
- *
- * @return Returns the charge start date.
- */
- public Date getChargeStartDate()
- {
- return _chargeStartDate;
- }
- /**
- * Sets the charge start date.
- *
- * @param pStartDate
- */
- public void setChargeStartDate(Date pStartDate)
- {
- _chargeStartDate = pStartDate;
- }
- /**
- * Returns the last cust off date.
- * The last charging period is the same for all contracted services
- * with charging schedule set to "Cut off date related".
- * This attribute defines the next cut off date. Read only!
- *
- * @return Returns the last cut off date.
- */
- public Date getLastCutOffDate()
- {
- return _lastCutOffDate;
- }
- /**
- * Returns the last notification date.
- *
- * @return Returns the last notification dDate.
- */
- public Date getLastNotificationDate()
- {
- return _lastNotificationDate;
- }
- /**
- * Returns the next cut off date.
- * The next charging period is the same for all contracted services
- * with charging schedule set to "Cut off date related".
- * This attribute defines the next cut off date. Read only!
- *
- * @return Returns the next cut off date.
- */
- public Date getNextCutOffDate()
- {
- return _nextCutOffDate;
- }
- /**
- * @return _recVersion
- */
- public BigDecimal getRecVersion()
- {
- // feature 00276491_cms
- return _recordVersion;
- }
- /**
- * return ConcurrentRequestHandler associated with this Contract
- *
- * @return ConcurrentRequestHandler
- * @throws ComponentException
- * ConcurrentRequestHandler is not set
- */
- public ConcurrentRequestHandler getConcurrentRequestHandler() throws ComponentException
- {
- // feature 00276491_cms
- if (_concurrentRequestHandler == null)
- {
- throw new ComponentException("Contract.ConcurrentRequestHandlerMissing");
- }
- return _concurrentRequestHandler;
- }
- // B: 00280461_cms
- /**
- * Sets the earliest contract end date.
- *
- * @param pEarliestContractEndDate
- * Date
- */
- public void setEarliestContractEndDate(Date pEarliestContractEndDate)
- {
- _earliestContractEndDate = pEarliestContractEndDate;
- }
- /**
- * Returns the earliest contract end date.
- *
- * @return Date
- */
- public Date getEarliestContractEndDate()
- {
- return _earliestContractEndDate;
- }
- // E: 00280461_cms
- /**
- * Returns true if the contract data shall be available on every rating node (is common reference data).
- *
- * @return boolean
- */
- public boolean isCommonReferenceData()
- {
- return _isCommonRefData;
- }
- /**
- * Sets the flag that indicates if the contract data shall be available
- * on every rating node (is common reference data).
- *
- * @param pIsCommonRefData
- * @throws ComponentException
- * @throws ValidationException
- */
- public void setIsCommonReferenceData(boolean pIsCommonRefData) throws ValidationException, ComponentException
- {
- if (_isCommonRefData != pIsCommonRefData)
- {
- _isCommonRefData = pIsCommonRefData;
- if (!this.isNew())
- {
- // Rating needs to be informed about the change
- ContractTaskHandler contractTaskHandler = getContractTaskHandler();
- long time = ServerTime.getCurrentTimeAsLong();
- short priority = ContractAdministrator.getInstance().getCommonDomainAdministrator().getUserPriorityI(GMDActionI.ChangeMobileSubscription);
- contractTaskHandler.registerAction(TaskManagementSettings.CONTRACT_SNAPSHOT,
- new AbstractDomainObjectI[]{this},
- time,
- priority,
- TaskTypeI.Provisioning,
- "N", "Y");
- }
- }
- }
- /**
- * Returns the porting requests of contract.
- *
- * @return Vector
- */
- public Vector<PortingRequest> getPortingRequests()
- {
- return FWValueHolder.getValue(_portingRequest);
- }
- /**
- * Adds another PortingRequest to this Contract resp.
- *
- * @param pPortingRequest
- * PortingRequest
- * @throws ComponentException
- * @throws ValidationException
- */
- public void addPortingRequest(PortingRequest pPortingRequest) throws ComponentException, ValidationException
- {
- // Retrieve the list of all ContractedProductElements
- Vector<PortingRequest> elementList = getPortingRequests();
- elementList.add(pPortingRequest);
- // in case of a deactive contract, avoid that the contract is marked as modified.
- if (getCurrentStatusI().getStateI() == ContractStatusI.Deactive)
- {
- _portingRequest.setValue(elementList);
- }
- else
- {
- FWValueHolder.setDirectValue(_portingRequest, elementList, this);
- }
- }
- // FSP 288320, Re-rating, MCH 26.06.2008
- /**
- * Checks whether the contract is marked as candidate for re-rating.
- */
- @Override
- public boolean isReratingCandidate()
- {
- return _isReratingCandidate;
- }
- /**
- * Marks the subscriber contract as candidate for re-rating or removes the mark.
- * Deactivated contracts can be marked or unmarked as long as the deactivation isn't passed longer than _pDays_.
- *
- * @param pMark
- * true - mark as candidate, false - remove the mark
- * @param pDays
- * @throws ComponentException
- * @throws ValidationException
- */
- @Override
- public void markForRerating(boolean pMark, int pDays) throws ComponentException, ValidationException
- {
- validateCandidateForRerating(pDays);
- _isReratingCandidate = pMark;
- createReratingTickler(pMark); // PN 312791_cms, MCH 02.12.2008, 09.02.2009
- }
- /**
- * Checks whether the contract can be marked for re-rating.
- * Deactivated contracts can be marked or unmarked as long as the deactivation isn't passed longer than _pDays_.
- *
- * @param pDays
- * - days number will be checked, if greater than 0
- * @throws ComponentException
- * @throws ValidationException
- */
- protected void validateCandidateForRerating(int pDays) throws ComponentException, ValidationException
- {
- // only subscriber contracts are allowed
- if (!getContractHolderI().isCustomer())
- {
- throw new ValidationException("CMS.Contract.MarkCandidateForRerating.NotAllowedForNonSubscriberContract",
- Long.valueOf(getIDI()), getPublicKeyI());
- }
- // check contract state
- int status = getCurrentStatusI().getStateI();
- if (status == ContractStatusI.Deactive && pDays > 0)
- {
- // Timestamp date = CAASTimeConverter.toTimestamp( getCurrentStatusI().getCreationDateI());
- // Timestamp now = ServerTime.getCurrentTime();
- long date = getCurrentStatusI().getCreationDateI();
- long now = ServerTime.getCurrentTimeAsLong();
- if (date + pDays * ServerTime.MILLISECONDS_IN_DAY < now)
- {
- throw new ValidationException("CMS.Contract.MarkCandidateForRerating.Status.Timeout",
- Long.valueOf(getIDI()), getPublicKeyI());
- }
- }
- // only state 'active' and 'suspended' are allowed
- else if (status != ContractStatusI.Active && status != ContractStatusI.Suspended)
- {
- throw new ValidationException("CMS.Contract.MarkCandidateForRerating.Status.Invalid",
- Long.valueOf(getIDI()), getPublicKeyI());
- }
- }
- /**
- * Check whether the contract is a subscriber contract
- */
- @Override
- public boolean isSubscriberContract()
- {
- String shName = getContractType().getShortName();
- if (ContractType.SHNAME_NOS.equals(shName) || ContractType.SHNAME_NOST.equals(shName)
- || ContractType.SHNAME_NOPAS.equals(shName))
- {
- return true;
- }
- return false;
- }
- /**
- * @see com.lhs.ccb.sfw.domain.AbstractDomainObject#validateI()
- */
- @Override
- public boolean validateI()
- throws ValidationException, ComponentException
- {
- // omit other validations, if the re-rating flag of the deactivated contract is changed
- // and is the only changed attribute.
- if (checkReratingFlag())
- {
- return true;
- }
- return super.validateI();
- }
- /**
- * Checkes whether the re-rating flag of the deactivated contract is changed
- * and is the only changed attribute.
- *
- * @return true, if re-rating flag of the deactivated customer is changed and is the only changed attribute;
- * otherwise false
- * @throws ComponentException
- */
- protected boolean checkReratingFlag() throws ComponentException
- {
- if (getCurrentStatusI().getStateI() == ContractStatusI.Deactive && !_valueHolderChanged)
- {
- String[] names = getModifiedCompareableAttributesNames();
- if (names.length == 1 && "_isReratingCandidate".equals(names[0]))
- {
- return true;
- }
- }
- return false;
- }
- /**
- * @return the billing lock object
- */
- @Override
- public BillingContractLock getBillingLock()
- {
- return FWValueHolder.getValue(_billingLock);
- }
- /**
- * @return the re-rating lock object
- */
- @Override
- public ReratingContractLock getReratingLock()
- {
- return FWValueHolder.getValue(_reratingLock);
- }
- /* public Contract getTemplate()
- {
- return FWValueHolder.getValue(_template);
- }
- public void setTemplate(Contract pContract)
- {
- FWValueHolder.setValue(_template, pContract, this);
- }
- */
- public long getTemplateId()
- {
- return _templateId;
- }
- public void setTemplateId(long pId)
- {
- _templateId=pId;
- }
- /** convenience method to set the template id, input parameter can be null */
- public void setTemplate(Contract pContract)
- {
- _templateId=(null==pContract)?NullConversion.LONG_NULL_VALUE:pContract.getIDI();
- }
- /**
- * @see com.lhs.ccb.sfw.domain.AbstractDomainObject#preValidate()
- */
- @Override
- public void preValidate() throws ValidationException, ComponentException
- {
- super.preValidate();
- if (isNew())
- {
- // create entries for billing and re-rating locks
- BillingContractLock bLock = AbstractFactory.createObject(BillingContractLock.class);
- bLock.setContract(this);
- FWValueHolder.setValue(_billingLock, bLock, this);
- ReratingContractLock rLock = AbstractFactory.createObject(ReratingContractLock.class);
- rLock.setContract(this);
- FWValueHolder.setValue(_reratingLock, rLock, this);
- }
- }
- // PN 312791_cms, MCH 02.12.2008, 09.02.2009
- /**
- * Creates a re-rating tickler.
- */
- protected void createReratingTickler(boolean pIsMarked)
- {
- NLSSystemEventMessageDefinitionI definition = new NLSSystemEventMessageDefinitionI();
- definition.OrgNode = this.getContractHolderI();
- definition.Contract = this;
- definition.ShortDescription = TICKLER_RERATING_SHORT_DESC;
- definition.LongDescription = pIsMarked ? TICKLER_RERATING_LONG_DESC_MARK : TICKLER_RERATING_LONG_DESC_UNMARK;
- definition.Status = TICKLER_STATUS_NOTE;
- definition.Priority = 4;
- BusinessPartnerEventManagementAdministrator.getInstance().createNLSSystemEventMessageI(definition);
- }
- // end 312791_cms, MCH 02.12.2008, 09.02.2009
- // end 288320, Re-rating, MCH 30.06.2008
- /**
- * @return the state, see {@link ContractStatusI}
- */
- public int getState()
- {
- return ContractStatus.charToState(_state);
- }
- /**
- * Set the state of the contract and set the date this is valid from, normally set only by PL/SQL. But under some conditions
- * (if a contract status change is <b>not</b> provisioned to rating or the network) it might be necessary to set the value
- * directly.
- *
- * @param pState
- * the state to set {@link ContractStatusI}
- */
- public void setState(int pState)
- {
- _state = ContractStatus.stateToChar(pState);
- _statusValidFromDate = new Timestamp(getCurrentStatusI().getValidFromDateI());
- }
- // FSP 313297, Contracted Product Handling, MCH 12.01.2009
- /**
- * Gets the first contract status.
- *
- * @return The first contract status object.
- * @throws ComponentException
- * @throws ValidationException
- * @see com.lhs.Contract.bscs_core.ContractStatus
- */
- public ContractStatusI getFirstStatus()
- throws ComponentException, ValidationException
- {
- Vector<ContractStatus> stati = getContractStati();
- Iterator<ContractStatus> iterator = stati.iterator();
- while (iterator.hasNext())
- {
- ContractStatus tmpStatus = iterator.next();
- if (tmpStatus.getIDI() == 1)
- {
- return tmpStatus;
- }
- }
- return null;
- }
- // end 313297, Contracted Product Handling, MCH 12.01.2009
- /**
- * @return
- */
- public Vector<ContractedPromotionPlan> getContractedPromotionPlans()
- {
- return FWValueHolder.getValue(_contractedPromotionPlans);
- }
- /**
- * @param pContractedPromotionPlan
- */
- public void addContractedPromotionPlan(ContractedPromotionPlan pContractedPromotionPlan)
- {
- Vector<ContractedPromotionPlan> contractedPromotionPlans = (Vector<ContractedPromotionPlan>) _contractedPromotionPlans.getValue();
- contractedPromotionPlans.add(pContractedPromotionPlan);
- FWValueHolder.setDirectValue(_contractedPromotionPlans, contractedPromotionPlans, this);
- }
- /**
- * @param pContractedPromotionPlan
- */
- public void removeContractedPromotionPlan(ContractedPromotionPlan pContractedPromotionPlan)
- {
- Vector<ContractedPromotionPlan> contractedPromotionPlans = (Vector<ContractedPromotionPlan>) _contractedPromotionPlans.getValue();
- contractedPromotionPlans.remove(pContractedPromotionPlan);
- FWValueHolder.setDirectValue(_contractedPromotionPlans, contractedPromotionPlans, this);
- }
- /**
- * @return true if this is a contract defined for the Ericsson charging system. false if this is a BSCS contract or a ECMS
- * contract.
- */
- @Override
- public boolean isChargingSystemContract()
- {
- if (this.isAgreementContract())
- {
- return false;
- }
- CompositeProductI lCompositeProductI = getContractedCompositeProduct().getCompositeProductI();
- return lCompositeProductI != null && lCompositeProductI.isChargingSystemTypeI();
- }
- /**
- * Gets the ProductElement for MainAccount (for CS contracts)
- *
- * @return the service representing the CS main account.
- */
- public ProductElement getProductElementForMainAccount()
- {
- Vector<ProductElementI> productElements = getContractedCompositeProduct().getCompositeProductI().getProductElementsI();
- for (ProductElementI productElement : productElements)
- {
- ProductElementTemplateI productElementTemplate = productElement.getProductElementTemplateI();
- if (productElementTemplate instanceof NetworkService)
- {
- NetworkService networkService = (NetworkService) productElementTemplate;
- if (networkService.isCSMainAccount())
- {
- return (ProductElement) productElement;
- }
- }
- }
- return null;
- }
- /**
- * Retrieves the last deactivated MSISDN
- *
- * @return MSISDN
- */
- public String getLastDeactivatedMSISDN()
- {
- List<ContractedProductElement> lContractedProductElements = getContractedCompositeProduct().getContractedProductElements();
- if (lContractedProductElements.isEmpty())
- {
- throw new ComponentException("CMS.Contract.Invalid", Long.valueOf(getIDI()), getPublicKey());
- }
- for (ContractedProductElement lContractedProductElement : lContractedProductElements)
- {
- Vector<ContractedDNPropertiesI> lContractedDNPropertiesI = lContractedProductElement.getContractedDNPropertiesI();
- if (!lContractedDNPropertiesI.isEmpty())
- {
- // We only want to return the main number of the contract
- DirectoryNumberI lDirectoryNumber = lContractedDNPropertiesI.get(lContractedDNPropertiesI.size() - 1).getDirectoryNumberI();
- return lDirectoryNumber.getNumberI();
- }
- }
- throw new ComponentException("CMS.Contract.NoMSISDN", Long.valueOf(getIDI()), getPublicKey());
- }
- /**
- * 350656_cms
- *
- * @param pInstance
- * - Instance
- * @param pEffectiveDate
- * @param pRequestCode
- * @param pCompositeProduct
- * @param isRpChange
- * - true if the method is being called for a rateplan change
- * @param isContrTO
- * - true if the method is being called for a contract takeover
- */
- public void configurePamClass(Instance pInstance, Timestamp pEffectiveDate,
- String pRequestCode,
- CompositeProductI pCompositeProduct,
- boolean isRpChange,
- boolean isContrTO)
- {
- if (isChargingSystemContract() && !this.getContractType().isCustomerContractTemplateType())
- {
- Vector<ContractedProductElementI> elements = getContractedCompositeProductI().getContractedProductElementsI();
- for (ContractedProductElementI element : elements)
- {
- if (element.getServiceSubtypeI() == NetworkServiceI.PAM_INFO_SERVICE_SUBTYPE)
- {
- // register PAM Scheme ( FSP 369277, Multiple PAM, MCH)
- if (isRpChange || isContrTO)
- {
- // 377727_E08_U15: PAM class and schedule are no longer stored in service parameter.
- // Take the PAM class from PAM Info Service and the schedule from bill cycle
- PamClass myPamClass = element.getProductElementI().getPamConfig().getPamClass();
- PamSchedule pamSchedule = getPamScheduleFromBillCycle();
- registerPamSchemeBillCycle(myPamClass, pamSchedule, (ContractedProductElement) element);
- }
- break;
- }
- }
- }
- }
- /**
- * feature 350656_cms / rework done with 377727_E08_U16
- *
- * @param pIsContractReactivation
- * @param pIsContractTakeover
- * @param pCurrentContract
- */
- public void configurePamScheduleForBillCycleChange(boolean pIsContractReactivation, boolean pIsContractTakeover, Contract pCurrentContract)
- {
- if (!(pIsContractReactivation || pIsContractTakeover
- || (isChargingSystemContract() && getState() == ContractStatusI.Active && !hasPendingRequests())))
- {
- throw new ComponentException("CMS.CustomerContractWithPendingRequest");
- }
- boolean isPamScheduleChanged = false;
- Timestamp effectiveDate = ServerTime.getCurrentTime();
- Vector<ContractedProductElementI> elements = getContractedCompositeProductI().getContractedProductElementsI();
- // gets the billcycle in order to discover if the customer has a pam schedule set
- PamSchedule newPamSchedule = getPamScheduleFromBillCycle();
- // get the existing (old) PAM Info Service Schedule from CONTRACT_PAM_SCHEME
- PamSchedule oldPamSchedule = pCurrentContract.getPamScheduleFromBillCycleScheme();
- if ((null == oldPamSchedule && null != newPamSchedule)
- || (null != oldPamSchedule && null == newPamSchedule)
- || (null != oldPamSchedule && null != newPamSchedule && (newPamSchedule.getExternalKey() != oldPamSchedule.getExternalKey())))
- {
- isPamScheduleChanged = true;
- }
- if (!isPamScheduleChanged)
- {
- return;
- }
- ContractedProductElementI cpePamInfoService = null; // PN 397120, MCH
- // trigger new action id
- registerActionForBillCycleChange(pIsContractTakeover, effectiveDate); // PN 397120, MCH
- // check for services which might be affected by the Change of the Default PAM Schedule
- for (ContractedProductElementI element : elements)
- {
- // remember PAM Info Service (PN 397120, MCH)
- if (element.getServiceSubtypeI() == NetworkServiceI.PAM_INFO_SERVICE_SUBTYPE)
- {
- cpePamInfoService = element;
- }
- NetworkService networkService = (NetworkService) ((ContractedProductElement) element).getNetworkService();
- if (networkService != null && networkService.isCostControlServiceI())
- {
- CostControlPackage ccPackage = (CostControlPackage) networkService.getCostControlPackageI();
- if (ccPackage.getPamConfig() != null && ccPackage.getPamConfig().getPamSchedule() == null)
- {
- countPamScheduleChange(ccPackage.getPamConfig().getPamClass(), oldPamSchedule, newPamSchedule,
- (ContractedProductElement) element);
- }
- }
- ProductElementI pe = element.getProductElementI();
- if (pe.getPamConfig() != null && pe.getPamConfig().getPamSchedule() == null)
- {
- countPamScheduleChange(pe.getPamConfig().getPamClass(), oldPamSchedule, newPamSchedule,
- (ContractedProductElement) element);
- }
- if (pe.getPamConfigRecCharge() != null && pe.getPamConfigRecCharge().getPamSchedule() == null)
- {
- countPamScheduleChange(pe.getPamConfigRecCharge().getPamClass(), oldPamSchedule, newPamSchedule,
- (ContractedProductElement) element);
- }
- if (networkService != null && networkService.isPamSpecialService())
- {
- long pamClassExternalKey = NullConversion.LONG_NULL_VALUE;
- long pamScheduleExternalKey = NullConversion.LONG_NULL_VALUE;
- Vector<ParameterValueNodeI> paramValues = element.getCurrentParameterValueNodesI();
- Iterator<ParameterValueNodeI> iter = paramValues.iterator();
- while (iter.hasNext())
- {
- ParameterValueNode value = (ParameterValueNode) iter.next();
- String parameterPublicKey = ((Parameter) value.getParameterI()).getPublicKey();
- if ("PAM_CLASM".equals(parameterPublicKey))
- {
- pamClassExternalKey = (long) value.getNumericValue();
- continue;
- }
- // there are 2 parameters for PAM schedule
- if ("PAM_SCHED".equals(parameterPublicKey))
- {
- pamScheduleExternalKey = (long) value.getNumericValue();
- }
- }
- PamClass pamClass = null;
- if (!NullConversion.isNull(pamClassExternalKey))
- {
- pamClass = PPamClass.readObjectByExternalKey(pamClassExternalKey);
- }
- PamSchedule pamSchedule = null;
- if (!NullConversion.isNull(pamScheduleExternalKey))
- {
- pamSchedule = AbstractFactory.getObjectFromPublicKey(PamSchedule.class, pamScheduleExternalKey);
- }
- if (pamClass != null && pamSchedule == null)
- {
- countPamScheduleChange(pamClass, oldPamSchedule, newPamSchedule, (ContractedProductElement) element);
- }
- }
- }
- // finally evaluate the settings done via 'countPamScheduleChange'.
- // For provisioning the modified scheme has to be linked to any product element.
- registerPamScheduleChanges(newPamSchedule, (ContractedProductElement) cpePamInfoService); // instead of elements.lastElement() (PN 397120, MCH)
- }
- // PN 397120, MCH
- /**
- * Registers action for bill cycle change.
- *
- * @param pIsTakeover
- * @param pEffectiveDate
- */
- private void registerActionForBillCycleChange(boolean pIsTakeover, Timestamp pEffectiveDate)
- {
- if (pIsTakeover)
- {
- // the new request must be a child of the contract takeover activation request
- ActionDetailsI details = getContractTaskHandler().getActionDetails(TaskManagementSettings.CONTRACT_TAKEOVER_ACTIVATION);
- long parentRequestId = details.PreallocatedRequestId;
- details = getContractTaskHandler().registerAction(
- TaskManagementSettings.PAM_SCHEME_CHANGE,
- new AbstractDomainObjectI[] { this }, pEffectiveDate.getTime(),
- details.Priority, // the same priority as for contract takeover activation
- TaskTypeI.Provisioning, "Y", null,
- parentRequestId);
- details.PreallocatedRequestId = TaskManagementAdministrator.getInstance().getNewRequestIdI();
- }
- else
- {
- getContractTaskHandler().registerAction(
- TaskManagementSettings.PAM_SCHEME_CHANGE,
- new AbstractDomainObjectI[] { this },
- pEffectiveDate.getTime(),
- ContractAdministrator.getInstance().getCommonDomainAdministrator()
- .getUserPriorityI(GMDActionI.ActivateSubscription),
- TaskTypeI.Provisioning, "Y", null, 0, null, pEffectiveDate, null);
- }
- }
- /**
- * Set the batch transaction identifier of the batch job, that touched last the contract.
- *
- * @param pTransactionId
- * the _transactionId to set
- */
- public void setTransactionId(long pTransactionId)
- {
- _transactionId = pTransactionId;
- }
- /**
- * The batch transaction identifier of the batch job, that touched last the contract.
- *
- * @return the _transactionId
- */
- public long getTransactionId()
- {
- return _transactionId;
- }
- // 377727_E08_U07
- /**
- * Returns the PAM schemes of contract.
- */
- public Vector<ContractPamScheme> getPamSchemes()
- {
- return FWValueHolder.getValue(_pamSchemes);
- }
- /**
- * Returns the free PAM schemes of contract.
- */
- public Vector<ContractPamScheme> getPamSchemesFree()
- {
- return FWValueHolder.getValue(_pamSchemesFree);
- }
- /**
- * Searches for the assigned PAM scheme with the given PAM service id.
- *
- * @param pPamServiceId
- * @return
- */
- public ContractPamScheme getPamScheme(long pPamServiceId)
- {
- if (NullConversion.isNull(pPamServiceId))
- {
- return null;
- }
- List<ContractPamScheme> pamSchemes = getPamSchemes();
- for (ContractPamScheme pamScheme : pamSchemes)
- {
- if (pamScheme.getPamServiceId() == pPamServiceId)
- {
- return pamScheme;
- }
- }
- return null;
- }
- /**
- * Searches for the assigned PAM scheme (except PAM purpose 'BillCycle') with the given PAM class and PAM schedule.
- * First checkes the pending values, than the current values.
- *
- * @param pPamClass
- * @param pPamSchedule
- * @return ContractPamScheme or null if not found.
- */
- public ContractPamScheme getPamScheme(PamClass pPamClass, PamSchedule pPamSchedule)
- {
- if (pPamClass == null) // 00377727_E08: Only Pam Class is mandatory
- {
- return null;
- }
- Vector<ContractPamScheme> pamSchemes = getPamSchemes();
- long pamClassId = pPamClass.getIDI();
- long pamScheduleId = NullConversion.LONG_NULL_VALUE;
- if (pPamSchedule != null)
- {
- pamScheduleId = pPamSchedule.getIDI();
- }
- for (ContractPamScheme pamScheme : pamSchemes)
- {
- if ((// Check if pPamClass can be found as pending OR current value in CONTRACT_PAM_SCHEME
- pamScheme.getPamClassPending() != null && pamScheme.getPamClassPending().getIDI() == pamClassId
- || pamScheme.getPamClass() != null && pamScheme.getPamClassPending() == null && pamScheme.getPamClass().getIDI() == pamClassId)
- // AND Check if pPamSchedule is null and so are pending and current values
- // OR if pPamSchedule is not null and can be found as pending OR current value
- && (pamScheme.getPamSchedulePending() == null && pamScheme.getPamSchedule() == null && pPamSchedule == null
- || pamScheme.getPamSchedulePending() != null && pamScheme.getPamSchedulePending().getIDI() == pamScheduleId
- || pamScheme.getPamSchedule() != null && pamScheme.getPamSchedulePending() == null
- && pamScheme.getPamSchedule().getIDI() == pamScheduleId))
- {
- return pamScheme;
- }
- }
- return null;
- }
- /**
- * Searches for a PAM scheme with the current PAM Class and PAM Schedule corresponded to the given parameters.
- *
- * @param pPamClass
- * @param pPamSchedule
- * @return PAM Scheme or null
- */
- public ContractPamScheme getPamSchemeCurrent(PamClass pPamClass, PamSchedule pPamSchedule)
- {
- if (pPamClass == null)
- {
- return null;
- }
- Vector<ContractPamScheme> pamSchemes = getPamSchemes();
- for (ContractPamScheme pamScheme : pamSchemes)
- {
- if (pamScheme.getPamClass() != null && pamScheme.getPamClass().getIDI() == pPamClass.getIDI()
- && (pamScheme.getPamSchedule() == null && pPamSchedule == null
- || pamScheme.getPamSchedule() != null && pPamSchedule != null
- && pamScheme.getPamSchedule().getIDI() == pPamSchedule.getIDI()))
- {
- return pamScheme;
- }
- }
- return null;
- }
- /**
- * Searches for a PAM scheme with the pending PAM Class and PAM Schedule corresponded to the given parameters.
- *
- * @param pPamClass
- * @param pPamSchedule
- * @return PAM Scheme or null
- */
- public ContractPamScheme getPamSchemePending(PamClass pPamClass, PamSchedule pPamSchedule)
- {
- if (pPamClass == null)
- {
- return null;
- }
- Vector<ContractPamScheme> pamSchemes = getPamSchemes();
- for (ContractPamScheme pamScheme : pamSchemes)
- {
- if (pamScheme.getPamClassPending() != null && pamScheme.getPamClassPending().getIDI() == pPamClass.getIDI()
- && (pamScheme.getPamSchedulePending() == null && pPamSchedule == null
- || pamScheme.getPamSchedulePending() != null && pPamSchedule != null
- && pamScheme.getPamSchedulePending().getIDI() == pPamSchedule.getIDI()))
- {
- return pamScheme;
- }
- }
- return null;
- }
- /**
- * Gets the first PAM service id in the range 0-99 which is not used (any more) in the assigned PAM schemes.
- *
- * @return free PAM scheme
- */
- protected ContractPamScheme getFreePamScheme()
- {
- Vector<ContractPamScheme> pamSchemes = getPamSchemes();
- int size = pamSchemes.size();
- if (size == 100)
- {
- // no free PAM service id exists
- throw new ComponentException("CMS.Contract.NoFreePAMServiceIdAwailable", getIDI(), getPublicKeyI());
- }
- ContractPamScheme newPamScheme = null;
- Vector<ContractPamScheme> pamSchemesFree = getPamSchemesFree();
- int sizeFree = pamSchemesFree.size();
- if (sizeFree == 0)
- {
- newPamScheme = AbstractFactory.createObject(ContractPamScheme.class);
- newPamScheme.setContract(this);
- newPamScheme.setPamServiceId(size);
- }
- else
- {
- newPamScheme = pamSchemesFree.remove(0);
- FWValueHolder.setValue(_pamSchemesFree, pamSchemesFree, this);
- }
- pamSchemes.add(newPamScheme);
- FWValueHolder.setValue(_pamSchemes, pamSchemes, this);
- return newPamScheme;
- }
- /**
- * Registers or unregisters a PAM scheme.
- *
- * @param pPamClass
- * @param pPamSchedule
- * @param pDelete
- * @return
- */
- public ContractPamScheme registerPamScheme(PamClass pPamClass, PamSchedule pPamSchedule, boolean pDelete)
- {
- int number = pDelete ? -1 : 1;
- if (null == pPamSchedule)
- {
- pPamSchedule = getPamScheduleFromBillCycle();
- }
- ContractPamScheme pamScheme = getPamScheme(pPamClass, pPamSchedule);
- if (pamScheme == null)
- {
- if (pDelete)
- {
- return null;
- }
- pamScheme = getFreePamScheme();
- }
- else if (!pamScheme.isCloneForUpdate())
- {
- pamScheme = pamScheme.getInstanceForUpdate();
- }
- pamScheme.setPamClassPending(pPamClass);
- pamScheme.setPamSchedulePending(pPamSchedule);
- int counter = pamScheme.getCounter();
- int counterPending = pamScheme.getCounterPending();
- if (!NullConversion.isNull(counterPending))
- {
- pamScheme.setCounterPending(counterPending + number);
- }
- else if (!NullConversion.isNull(counter))
- {
- pamScheme.setCounterPending(counter + number);
- }
- else
- {
- pamScheme.setCounterPending(number);
- }
- pamScheme.setTaskI(null);
- return pamScheme;
- }
- /**
- * Registers the PAM scheme for the purpose 'BillCycle'.
- *
- * @param pPamClass
- * @param pPamSchedule
- * @param pCpe
- */
- private ContractPamScheme registerPamSchemeBillCycle(PamClass pPamClass, PamSchedule pPamSchedule, boolean pDelete)
- {
- boolean isChanged = false;
- ContractPamScheme pamScheme = getPamSchemeBillCycle();
- if (pamScheme == null)
- {
- if (!pDelete)
- {
- pamScheme = getFreePamScheme();
- pamScheme.setCounterPending(1);
- pamScheme.setPamClassPending(pPamClass);
- pamScheme.setPamSchedulePending(pPamSchedule);
- isChanged = true;
- }
- }
- else
- {
- if (pDelete
- || pamScheme.getPamClass() == null || pamScheme.getPamClass().getIDI() != pPamClass.getIDI()
- || pPamSchedule == null && pamScheme.getPamSchedule() != null
- || pPamSchedule != null && (pamScheme.getPamSchedule() == null
- || pamScheme.getPamSchedule().getIDI() != pPamSchedule.getIDI()))
- {
- if (!pamScheme.isCloneForUpdate())
- {
- pamScheme = pamScheme.getInstanceForUpdate();
- }
- pamScheme.setPamClassPending(pPamClass);
- pamScheme.setPamSchedulePending(pPamSchedule);
- pamScheme.setCounterPending(pDelete ? 0 : 1);
- isChanged = true;
- }
- }
- if (isChanged)
- {
- pamScheme.setTaskI(null);
- return pamScheme;
- }
- return null;
- }
- /**
- * 377727_E08_U16
- * Register all schemes which are affected by a PAM default Schedule change
- *
- * @param pPamClass
- * @param pPamSchedule
- * @param pCpe
- */
- protected void registerPamScheduleChanges(PamSchedule pNewPamSchedule, ContractedProductElement pCpe)
- {
- Vector<ContractPamScheme> pamSchemes = getPamSchemes();
- for (ContractPamScheme pamScheme : pamSchemes)
- {
- int pendingCounter = pamScheme.getCounterPending();
- int currentCounter = pamScheme.getCounter();
- if (pamScheme.getPamClassPending() != null)
- {
- if (pendingCounter == 0)
- {
- // check if another PAM scheme exists with the new PAM schedule ...
- ContractPamScheme existingPamScheme = getPamSchemeCurrent(pamScheme.getPamClass(), pNewPamSchedule);
- if (null == existingPamScheme)
- {
- // .. if not, the complete scheme has changed e.g. in case of the PAM info service
- // to indicate this to GMD, reset pending to current counter and set new PAM schedule pending
- pamScheme.setCounterPending(currentCounter);
- pamScheme.setPamSchedulePending(pNewPamSchedule);
- }
- }
- else if (pendingCounter < currentCounter)
- {
- // new PAM scheme might be created ...
- ContractPamScheme newPamScheme = registerPamScheme(pamScheme.getPamClass(), pNewPamSchedule, false);
- int newPendingCounter = newPamScheme.getCounterPending();
- // ... if the scheme already exists it contains the correct counterPending value
- // but if it is new its counter is '0'. In this case the new scheme gets services the old scheme has lost.
- if (newPendingCounter == 0)
- {
- newPamScheme.setCounterPending(currentCounter - pendingCounter);
- }
- pCpe.getProvisionableChildrenList().add(newPamScheme);
- }
- pamScheme.setTaskI(null);
- }
- }
- }
- /**
- * 377727_E08_U16
- * Count Schemes which are affected by the PAM Schedule Change
- *
- * @param pPamClass
- * @param pPamSchedule
- * @param pCpe
- */
- protected void countPamScheduleChange(PamClass pPamClass, PamSchedule pOldPamSchedule, PamSchedule pNewPamSchedule, ContractedProductElement pCpe)
- {
- // check for an existing PAM scheme and decrease its pending counter if the new PAM Schedule is different from the old one
- if ((pOldPamSchedule != null && pNewPamSchedule == null) || (pOldPamSchedule == null && pNewPamSchedule != null)
- || (pOldPamSchedule != null && pNewPamSchedule != null && (pOldPamSchedule.getIDI() != pNewPamSchedule.getIDI())))
- {
- ContractPamScheme pamOldScheme = getPamSchemeCurrent(pPamClass, pOldPamSchedule);
- if (pamOldScheme != null)
- {
- // this scheme is affected -> set the pending values
- pamOldScheme.setPamClassPending(pPamClass);
- pamOldScheme.setPamSchedulePending(pOldPamSchedule);
- // decrease and set new pending counter
- int counterPending = pamOldScheme.getCounterPending();
- if (NullConversion.isNull(counterPending))
- {
- counterPending = pamOldScheme.getCounter();
- }
- counterPending -= 1;
- pamOldScheme.setCounterPending(counterPending);
- pCpe.getProvisionableChildrenList().add(pamOldScheme);
- }
- }
- // increase the pending counter for existing schemes
- ContractPamScheme pamNewScheme = getPamSchemeCurrent(pPamClass, pNewPamSchedule);
- if (pamNewScheme != null)
- {
- // scheme is affected
- pamNewScheme.setPamClassPending(pPamClass);
- pamNewScheme.setPamSchedulePending(pNewPamSchedule);
- int newCounterPending = pamNewScheme.getCounterPending();
- if (NullConversion.isNull(newCounterPending))
- {
- if (pamNewScheme.getPamClass() == null)
- {
- newCounterPending = 0; // this is a real new PAM Scheme
- }
- else {
- newCounterPending = pamNewScheme.getCounter(); // the Scheme already exists
- }
- }
- newCounterPending += 1;
- pamNewScheme.setCounterPending(newCounterPending);
- pCpe.getProvisionableChildrenList().add(pamNewScheme);
- }
- }
- /**
- * Registers the PAM scheme for the purpose 'BillCycle'.
- *
- * @param pPamClass
- * @param pPamSchedule
- * @param pCpe
- */
- protected void registerPamSchemeBillCycle(PamClass pPamClass, PamSchedule pPamSchedule, ContractedProductElement pCpe)
- {
- ContractPamScheme pamScheme = null;
- if (pPamClass == null)
- {
- // PAM Info service is being removed. The PAM scheme must be removed, too.
- pamScheme = registerPamSchemeBillCycle(null, null, true);
- }
- else
- {
- pamScheme = registerPamSchemeBillCycle(pPamClass, pPamSchedule, false);
- }
- if (pamScheme != null)
- {
- pCpe.getProvisionableChildrenList().add(pamScheme);
- }
- }
- /**
- * Searches for the assigned PAM scheme with PAM purpose 'BillCycle'.
- *
- * @return
- */
- public ContractPamScheme getPamSchemeBillCycle()
- {
- Vector<ContractPamScheme> pamSchemes = getPamSchemes();
- for (ContractPamScheme pamScheme : pamSchemes)
- {
- if (pamScheme.getPamClass() != null && pamScheme.getPamClass().getPamPurpose().isBillCycle()
- || pamScheme.getPamClass() == null
- && pamScheme.getPamClassPending() != null && pamScheme.getPamClassPending().getPamPurpose().isBillCycle())
- {
- return pamScheme;
- }
- }
- return null;
- }
- /**
- * Refreshes the contract's PAM schemes.
- */
- protected void refreshPamSchemes()
- {
- List<ContractPamScheme> pamSchemes = this.getPamSchemes();
- for (ContractPamScheme pam : pamSchemes)
- {
- if (pam.isPending())
- {
- pam.refreshObject();
- }
- }
- ArrayList<Long> lParams = new ArrayList<Long>(1);
- lParams.add(Long.valueOf(_id));
- Vector<ContractPamScheme> pamSchemesFree = AbstractFactory.readObjectsByQueryI(
- ContractPamScheme.class, PContractPamScheme.READ_CONTRACT_PAM_SCHEMES_FREE, lParams);
- // FWValueHolder.setValue( _pamSchemesFree, pamSchemesFree, this );
- _pamSchemesFree.setValue(pamSchemesFree);
- }
- /**
- * Checks whether the contract has pending PAM schemes.
- */
- protected boolean hasPendingPamScheme()
- {
- Vector<ContractPamScheme> pamSchemes = getPamSchemes();
- for (ContractPamScheme pamScheme : pamSchemes)
- {
- if (pamScheme.isPending())
- {
- return true;
- }
- }
- return false;
- }
- /**
- * Gets the PAM Schedule from the contract holder's bill cycle.
- *
- */
- public PamSchedule getPamScheduleFromBillCycle()
- {
- return getContractHolderI().getCustomerAccountI().getBillSpecificationI().getBillCycleI().getPamSchedule();
- }
- /**
- * 377727_E08_U16
- *
- * @return Pam Schedule of Pam Info service if exists otherwise null
- */
- private PamSchedule getPamScheduleFromBillCycleScheme()
- {
- PamSchedule pamSchedule = null;
- ContractPamScheme pamSchemeBillCycle = getPamSchemeBillCycle();
- if (pamSchemeBillCycle != null)
- {
- pamSchedule = pamSchemeBillCycle.getPamSchedule();
- if (null == pamSchedule)
- {
- pamSchedule = pamSchemeBillCycle.getPamSchedulePending();
- }
- }
- return pamSchedule;
- }
- /**
- * Returns shared account package assigments for a contract.
- *
- * @return list of shared account package assignments for a contract
- */
- public List<SharedAccountPackageAssignment> getSharedAccountPackageAssignments()
- {
- return FWValueHolder.getValue(_sharedAccountPackageAssignments);
- }
- /**
- * Returns the list of current and future shared account package assignments.
- * @return list of current and future shared account package assignments
- */
- public List<SharedAccountPackageAssignment> getActiveSharedAccountPackageAssignments()
- {
- return getActiveSharedAccountPackageAssignmentsFiltered(null);
- }
- /**
- * Returns the list of current and future shared account package assignments.
- * @param pFilter - defines if assignemnt of a specified role should be returned, null - no filtering
- * @return list of current and future shared account package assignments matching the filter
- */
- public List<SharedAccountPackageAssignment> getActiveSharedAccountPackageAssignmentsFiltered(Role pFilter)
- {
- List<SharedAccountPackageAssignment> lActiveSharedAccountPackageAssignments = new ArrayList<SharedAccountPackageAssignment>();
- List<SharedAccountPackageAssignment> lSharedAccountPackageAssignments = getSharedAccountPackageAssignments();
- for (SharedAccountPackageAssignment sharedAccountAssignment : lSharedAccountPackageAssignments)
- {
- if (sharedAccountAssignment.isExpired())
- {
- continue;
- }
- if (pFilter != null)
- {
- if (pFilter.isOwner() && !sharedAccountAssignment.isOwner())
- {
- continue;
- }
- if (pFilter.isParticipant() && !sharedAccountAssignment.isParticipation())
- {
- continue;
- }
- }
- lActiveSharedAccountPackageAssignments.add(sharedAccountAssignment);
- }
- return lActiveSharedAccountPackageAssignments;
- }
- /**
- * Returns shared account package assigments for a contract.
- * I.e. ownership assignments and participation assignemts for this contract.
- * @param pSharedAccountPackageAssignments
- */
- public void setSharedAccountPackageAssignments(List<SharedAccountPackageAssignment> pSharedAccountPackageAssignments)
- {
- FWValueHolder.setValue(_sharedAccountPackageAssignments, pSharedAccountPackageAssignments, this);
- }
- /**
- * Checks whether the contract is a shared account owner.
- *
- * @return <code>true</code> if the contract is a shared account owner; otherwise <code>false</code>
- */
- public boolean isSharedAccountPackageOwner()
- {
- List<SharedAccountPackageAssignment> lSharedAccountPackageAssignments = getActiveSharedAccountPackageAssignmentsFiltered(Role.OWNER);
- return !lSharedAccountPackageAssignments.isEmpty();
- }
- /**
- * Checks if contract can be deactivated from shared account package perspective
- * If not, throws a ComponentException
- */
- private void checkSharedAccountPackageAssignmentsForContractDeactivation()
- {
- List<SharedAccountPackageAssignment> sharedAccountPackageAssignments = getActiveSharedAccountPackageAssignmentsFiltered(Role.OWNER);
- for (SharedAccountPackageAssignment assignment : sharedAccountPackageAssignments)
- {
- if (assignment.hasParticipants())
- {
- throw new ComponentException( "CMS.Contract.DeactivationOfSharedAccountOwner", assignment.getSharedAccountPackage().getShdes());
- }
- }
- }
- /**
- * Get contract extraction tag value, e.g. "Postpaid", "Prepaid".
- *
- * @param pExtractionIndicator
- * the input contract extraction tag.
- * @return String _extractionTag
- */
- public String getExtractionTag()
- {
- return _extractionTag;
- }
- /**
- * Set contract extraction tag value, e.g. "Postpaid", "Prepaid". This extraction tag value will be maintained by operator, and
- * will be used in TEH and GMD to decide whether the contract and relevent RDR should be extracted/generated and loaded into
- * shared memory or not.
- *
- * @param pExtractionTag
- * - the input contract extraction tag.
- */
- public void setExtractionTag(String pExtractionTag)
- {
- if (LicenseUtilsFacade.checkLicense(LicenseFeature.LHS_BSCS_DYNAMIC_CONFIGURATION_IN_TEH.getName()))
- {
- _extractionTag = pExtractionTag;
- _extractionTagModifiedDate = ServerTime.getCurrentTime();
- }
- }
- } // end of class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement