Class SalesItemsTree

java.lang.Object
com.imc.iss.groovy.salesitem.SalesItemsTree

public class SalesItemsTree extends Object
This is a class representing a quote for use by groovy scripts

Inside the script, an instance of this class, containing the data of the quote that the script will be run on, will be provided automatically and can be accessed as a variable named salesItemsTree

See Also:
  • Method Details

    • addAttachmentFile

      public void addAttachmentFile(InputStream attachmentStream, String fileName, long fileSize, String attachmentType) throws IMCException
      Adds the attachment file as line item attachment
      Parameters:
      attachmentStream - Input File Stream
      fileName - Name of the file to be added
      fileSize - Size of the File to be added
      attachmentType - type of attachment File
      Throws:
      IMCException
    • addChildByProductErpId

      public SalesItemNode addChildByProductErpId(String productErpId) throws IMCException
      Adds a new line item under this object by specifying its ERP ID.

      The validity of the given ERP ID will only be evaluated after the script has completed its execution and returns control back to the main application.

      Parameters:
      productErpId - The ERP ID of the product to be added as the new line item
      Returns:
      The SalesItemNode object representing the newly added line item
      Throws:
      IMCException
    • addChildByProductURI

      public SalesItemNode addChildByProductURI(String productURI) throws IMCException
      Adds a new line item under this object by specifying its Product URI.

      The validity of the given URI will only be evaluated after the script has completed its execution and returns control back to the main application.

      Parameters:
      productURI - The URI of the product to be added as the new line item. The full path has to be provided.
      Returns:
      The SalesItemNode object representing the newly added line item
      Throws:
      IMCException
    • addNewPriceItem

      public SalesItemsTree addNewPriceItem(PriceItemData priceItemData) throws IMCException
      Create and Add Price Item data to salesItem, without triggering SSC pricing. Should not be used unless that is the intention
      Parameters:
      priceItemData - as PriceItemData. See PriceItemData
      Returns:
      SalesItemNode
      Throws:
      IMCException
    • addPartnerFunctions

      public SalesItemsTree addPartnerFunctions(Collection<PartnerFunctionRecord> partnerFunctionRecords)
      Add partner function records into quote's Partner Function.
      Parameters:
      partnerFunctionRecords - . The partner function records to add into a quote.
      Returns:
      The SalesItemsTree instance.
    • deletePartnerFunctions

      public SalesItemsTree deletePartnerFunctions(Collection<BusinessObject> partnerFunctionRecords)
      remove partner function records into quote's Partner Function.
      Parameters:
      partnerFunctionRecords - . The partner function records to remove into a quote.
      Returns:
      The SalesItemsTree instance.
    • deletePriceItem

      public SalesItemsTree deletePriceItem(PriceItemData priceItem) throws IMCException
      Remove Price Item data from salesItem, without triggering SSC pricing. Should not be used unless that is the intention
      Parameters:
      priceItemData - as PriceItemData. See PriceItemData
      Returns:
      SalesItemsTree
      Throws:
      IMCException
    • filterChildrenByDynamicAttribute

      public List<SalesItemNode> filterChildrenByDynamicAttribute(String dynamicAttributeName, List<Object> dynamicAttributeValues) throws IMCException
      Retrieves the list of child line items that has dynamic attribute of one of the specified values
      Parameters:
      dynamicAttributeName - The object name of the dynamic attribute. It can be either Dynamic Symbolic Attribute (DSA) or Dynamic Data Attribute (DDA). Note that only the object name can be used here, not the language-specific labels
      dynamicAttributeValues - The list of acceptable values for the dynamic attribute. For DSA, only the object name of the ranges can be used here, not the language-specific labels
      Returns:
      All SalesItemNode objects directly under this object that meets the filter criteria
      Throws:
      IMCException
    • filterChildrenByDynamicAttribute

      public List<SalesItemNode> filterChildrenByDynamicAttribute(String dynamicAttributeName, Object dynamicAttributeValue) throws IMCException
      Retrieves the list of child line items that has dynamic attribute of a specific value
      Parameters:
      dynamicAttributeName - The object name of the dynamic attribute. It can be either Dynamic Symbolic Attribute (DSA) or Dynamic Data Attribute (DDA). Note that only the object name can be used here, not the language-specific labels
      dynamicAttributeValue - The accepted value for the dynamic attribute. For DSA, only the object name of the ranges can be used here, not the language-specific labels
      Returns:
      All SalesItemNode objects directly under this object that meets the filter criteria
      Throws:
      IMCException
    • filterChildrenByProductERPID

      public List<SalesItemNode> filterChildrenByProductERPID(List<String> productERPIDs)
      Retrieves the list of child line items that has one of the specified ERP IDs.
      Parameters:
      productERPIDs - The list of accepted values of ERP ID
      Returns:
      All SalesItemNode objects directly under this object that meets the filter criteria
    • filterChildrenByProductName

      public List<SalesItemNode> filterChildrenByProductName(List<String> productNames)
      Retrieves the list of child line items that has one of the specified objectName
      Parameters:
      productNames - The list of accepted values of product object name
      Returns:
      All SalesItemNode objects directly under this object that meets the filter criteria
    • filterChildrenByProductType

      public List<SalesItemNode> filterChildrenByProductType(String productTypeURI)
      Retrieves the list of child line items that belongs to a particular Product Type only
      Parameters:
      productTypeURI - The URI of the product type. The full path has to be provided.
      Returns:
      All SalesItemNode objects directly under this object that meets the filter criteria
    • getAllSalesItemBO

      public Collection<BusinessObject> getAllSalesItemBO(GroovyCtxUtil ctx) throws IMCException
      Get all salesItem business objects as a Collection for a quote.
      Parameters:
      ctx - The groovy context GroovyCtxUtil .
      Returns:
      Collection <BusinessObject>.
      Throws:
      IMCException - the platform exception
    • getAllSubSalesItems

      public List<SalesItemNode> getAllSubSalesItems() throws IMCException
      Get all SalesItemNodes as a List for a quote.
      Returns:
      List <SalesItemNode>. The SalesItemNode.
      Throws:
      IMCException - the platform exception
    • getAttachmentFile

      public AttachmentData getAttachmentFile(String fileName) throws IMCException
      Get a attachement file by file name. @see AttachmentData.
      Parameters:
      fileName - as String the name of the file.
      Returns:
      AttachmentData.
      Throws:
      IMCException
    • getAttachmentFiles

      public List<AttachmentData> getAttachmentFiles() throws IMCException
      Get the list of the attachement file. @see AttachmentData.
      Returns:
      AttachmentData in List.
      Throws:
      IMCException
    • getAttachmentFilesByType

      public List<AttachmentData> getAttachmentFilesByType(String fileType) throws IMCException
      Get the list of the attachement file by file type. @see AttachmentData.
      Parameters:
      fileType - as String. The file type.
      Returns:
      AttachmentData in List.
      Throws:
      IMCException
    • getAttachmentFolder

      public AttachmentFolderData getAttachmentFolder(String folderName) throws IMCException
      Get an attachement folder by folder name. @see AttachmentFolderData.
      Parameters:
      folderName - the name of the folder.
      Returns:
      AttachmentFolderData.
      Throws:
      IMCException
    • getAttachmentFolders

      public List<AttachmentFolderData> getAttachmentFolders() throws IMCException
      Get the list of the attachment folder.
      Returns:
      AttachmentFolderData in List.
      Throws:
      IMCException
    • getChildren

      public List<SalesItemNode> getChildren()
      Retrieves the immediate line items.
      Returns:
      All SalesItemNode objects directly under this object
    • getCurrencyName

      public String getCurrencyName() throws IMCException
      To get the name of the currency used by the quote
      Returns:
      the currencyName
      Throws:
      IMCException
    • getCurrencyUri

      public String getCurrencyUri() throws IMCException
      To get the URI of the currency used by the quote
      Returns:
      the currencyUri
      Throws:
      IMCException
    • getDocumentHeaderDataAttributeValue

      public Object getDocumentHeaderDataAttributeValue(String attributeURI) throws IMCException
      Throws:
      IMCException
    • getPartnerErpId

      public String getPartnerErpId(String PartnerFunctionURI) throws IMCException
      To get the ERPId of the partner function by partner function URI.
      Parameters:
      PartnerFunctionURI - the URI of the partner function.
      Returns:
      The partner function ERPId as String. null if not found.
      Throws:
      IMCException
    • getPartnerObjectId

      public String getPartnerObjectId(String partnerFunctionURI) throws IMCException
      To get the object Id of the partner function by partner function URI.
      Parameters:
      partnerFunctionURI - the URI of the partner function.
      Returns:
      The partner function object Id as String. null if not found.
      Throws:
      IMCException
    • getPartnerObjectName

      public String getPartnerObjectName(String partnerFunctionURI) throws IMCException
      To get the object Name of the partner function by partner function URI.
      Parameters:
      partnerFunctionURI - the URI of the partner function.
      Returns:
      The partner function object Id as String. null if not found.
      Throws:
      IMCException
    • getPartners

      public Map<String,List<AbstractObjectDTO>> getPartners() throws IMCException
      Retrieves the partner functions of the quote.
      Returns:
      The partners as Map<String, List<AbstractObjectDTO>> with the uri of the partner function as key (eg: http://www.inmindcloud.com/application/schema.owl#BUYER_PARTY)
      Throws:
      IMCException
    • getPartnersErpId

      public List<String> getPartnersErpId(String partnerFunctionURI) throws IMCException
      To get all the ERPId for a type of partner function.
      Parameters:
      partnerFunctionURI - the URI of the partner function.
      Returns:
      List of erpId in String.
      Throws:
      IMCException
    • getPartnersObjectId

      public List<String> getPartnersObjectId(String partnerFunctionURI) throws IMCException
      To get all the object Id for a type of partner function.
      Parameters:
      partnerFunctionURI - the URI of the partner function.
      Returns:
      List of object Id in String.
      Throws:
      IMCException
    • getPartnersObjectName

      public List<String> getPartnersObjectName(String partnerFunctionURI) throws IMCException
      To get all the object names for a type of partner function.
      Parameters:
      partnerFunctionURI - the URI of the partner function.
      Returns:
      List of object name in String.
      Throws:
      IMCException
    • getPartnersURI

      public List<String> getPartnersURI(String partnerFunctionURI) throws IMCException
      To get all the object URI for a type of partner function.
      Parameters:
      partnerFunctionURI - the URI of the partner function.
      Returns:
      List of object URI in String.
      Throws:
      IMCException
    • getPartnerURI

      public String getPartnerURI(String PartnerFunctionURI) throws IMCException
      To get the object URI of a partner function
      Parameters:
      PartnerFunctionURI - as String. The URI of the type of partner function.
      Returns:
      The object URI of the partner function as String. null if not found.
      Throws:
      IMCException
    • getPriceItemByTypeName

      public PriceItemData getPriceItemByTypeName(String name) throws IMCException
      To get the price Item data by name. PriceItemData
      Parameters:
      name - as String the name of the price item.
      Returns:
      PriceItemData.
      Throws:
      IMCException
    • getPriceItemByTypeUri

      public PriceItemData getPriceItemByTypeUri(String uri) throws IMCException
      To get the price Item data by URI. PriceItemData
      Parameters:
      uri - as String the uri of the price item.
      Returns:
      PriceItemData.
      Throws:
      IMCException
    • getPriceItemByUri

      public PriceItemData getPriceItemByUri(String uri) throws IMCException
      To get the price Item data by price item URI. PriceItemData
      Parameters:
      uri - as String the uri of the price item.
      Returns:
      PriceItemData.
      Throws:
      IMCException
    • getPriceItemsByTypeName

      public List<PriceItemData> getPriceItemsByTypeName(String name) throws IMCException
      To get all the price Item data by the name of the price item type. PriceItemData
      Parameters:
      name - as String the name of the price item type.
      Returns:
      PriceItemData.
      Throws:
      IMCException
    • getPriceItemsByTypeUri

      public List<PriceItemData> getPriceItemsByTypeUri(String uri) throws IMCException
      To get all the price Item data by price item URI. PriceItemData
      Parameters:
      uri - as String the URI of the price item type.
      Returns:
      PriceItemData in List
      Throws:
      IMCException
    • getPriceItemsJustified

      public List<PriceItemData> getPriceItemsJustified(String justificationURI) throws IMCException
      To get all user justified price Item data. PriceItemData.
      Returns:
      PriceItemData in List
      Throws:
      IMCException
    • getQuoteAccountName

      public String getQuoteAccountName() throws IMCException
      Retrieves the name of the account that the quote belongs to
      Returns:
      The account name of the quote
      Throws:
      IMCException
    • getQuoteCountryErpId

      public String getQuoteCountryErpId() throws IMCException
      Retrieves the erp id of the country that the quote belongs to The relationship is as follows: quote -> includesAddress -> hasCountry
      Returns:
      The country erp id
      Throws:
      IMCException
    • getQuoteDataAttributeValue

      public Object getQuoteDataAttributeValue(String attributeURI) throws IMCException
      To get the value of a quote data attribute by attribute URI.
      Parameters:
      attributeURI - as String. The URI of the quote data attribute.
      Returns:
      the value of the quote data attribute as Object.
      Throws:
      IMCException
    • getQuoteID

      public String getQuoteID() throws IMCException
      Retrieves the ID of the quote
      Returns:
      The quote ID
      Throws:
      IMCException
    • getQuoteRelationAttributeErpId

      public String getQuoteRelationAttributeErpId(String attributeURI) throws IMCException
      To get the ERPID of a quote relation attribute by attribute URI.
      Parameters:
      attributeURI - as String. The URI of the quote relation attribute.
      Returns:
      the ERPId of the quote relation attribute as String.
      Throws:
      IMCException
    • getQuoteRelationAttributeObjectId

      public String getQuoteRelationAttributeObjectId(String attributeURI) throws IMCException
      To get the object Id of a quote relation attribute by attribute URI.
      Parameters:
      attributeURI - as String. The URI of the quote relation attribute.
      Returns:
      the objectId of the quote relation attribute as String.
      Throws:
      IMCException
    • getQuoteRelationAttributeObjectName

      public String getQuoteRelationAttributeObjectName(String attributeURI) throws IMCException
      To get the object name of a quote relation attribute by attribute URI.
      Parameters:
      attributeURI - as String. The URI of the quote relation attribute.
      Returns:
      the object name of the quote relation attribute as String.
      Throws:
      IMCException
    • getQuoteRelationAttributeURI

      public String getQuoteRelationAttributeURI(String attributeURI) throws IMCException
      To get the URI of a quote relation attribute by attribute URI.
      Parameters:
      attributeURI - as String. The URI of the quote relation attribute.
      Returns:
      the object URI of the quote relation attribute as String.
      Throws:
      IMCException
    • getQuoteTitle

      public String getQuoteTitle() throws IMCException
      Retrieves the title of this quote
      Returns:
      The quote title as String
      Throws:
      IMCException
    • getQuoteURI

      public String getQuoteURI()
      Retrieves the URI of this quote
      Returns:
      The quote URI as String
    • getQuoteVersion

      public Integer getQuoteVersion() throws IMCException
      Retrieves the latest version of this quote
      Returns:
      The quote version as Integer
      Throws:
      IMCException
    • getRoutedUsers

      public List<User> getRoutedUsers() throws IMCException
      Retrieve only routed users using the current transaction context (no HTTP call required).
      Returns:
      Collection
      Throws:
      IMCException
    • getTotalPrice

      public BigDecimal getTotalPrice() throws IMCException
      To get the total price.
      Returns:
      the totalPrice as BigDecimal.
      Throws:
      IMCException
    • getUsersForRouting

      public List<User> getUsersForRouting() throws IMCException
      Retrieve routing users using the current transaction context (no HTTP call required).
      Returns:
      Collection
      Throws:
      IMCException
    • isCommerce

      public boolean isCommerce()
      Indicates the context that Quote object is created from
      Returns:
      the isCommerce as boolean. Return TRUE if it is commerce Inquiry.
    • isQuoteAgreement

      public boolean isQuoteAgreement()
      Indicates the context that Quote object is created from
      Returns:
      the isQuoteAgreement as boolean. Return TRUE if it is Agreement.
    • recallRouting

      public void recallRouting(Collection<String> userIds) throws IMCException
      Recall routing for the given users within the current transaction to avoid nested HTTP calls/locks.
      Parameters:
      userIds - as userUrisBase64 of users to recall from routing.
      Throws:
      IMCException
    • recallRouting

      public void recallRouting(String userId) throws IMCException
      Recall routing for the given users within the current transaction to avoid nested HTTP calls/locks.
      Parameters:
      userId - as userUrisBase64 of user to recall from routing.
      Throws:
      IMCException
    • setPriceItemByTypeName

      public SalesItemsTree setPriceItemByTypeName(String priceItemTypeName, BigDecimal baseAmount) throws IMCException
      Create or Update price item with baseAmount only.

      Note that this method assumes that there can only be one Price Item of a given type. Thus, if a Price Item of that type already exists it will update it, otherwise it will create a new Price Item. If there are already multiple Price Items of the given type, only the first one will be updated.
      Parameters:
      priceItemTypeName - as String. The name of the price item type.
      baseAmount - as BigDecimal. The baseAmount to update / create.
      Returns:
      The SalesItemsTree
      Throws:
      IMCException
    • setQuoteDataAttribute

      public SalesItemsTree setQuoteDataAttribute(String attributeURI, Object value) throws IMCException
      To set a value for the quote data attribute.
      Parameters:
      attributeURI - as String. The URI of the quote data attribute.
      value - as Object. The value for the quote data attribute.
      Returns:
      The SalesItemsTree
      Throws:
      IMCException - the platform exception
    • setQuoteRelationAttribute

      public SalesItemsTree setQuoteRelationAttribute(String attributeURI, String valueURI) throws IMCException
      To set a value for the quote relation attribute.
      Parameters:
      attributeURI - as String. The URI of the quote relation attribute.
      valueURI - as Object. The value for the quote relation attribute.
      Returns:
      The SalesItemsTree
      Throws:
      IMCException - the platform exception
    • toString

      public String toString()
      Returns a string representation of the quote, which prints all the line items in hierarchical manner
      Overrides:
      toString in class Object
      Returns:
      A string representation of the quote.
    • updatePriceItemBaseAmount

      public SalesItemsTree updatePriceItemBaseAmount(String priceItemURI, BigDecimal baseAmount) throws IMCException
      Update BaseAmount with targetCurrency of a Price Item
      Parameters:
      priceItemURI - as String. The URI of the price item to be updated.
      baseAmount - as BigDecimal. The BaseAmount of the price item.
      Returns:
      SalesItemNode
      Throws:
      IMCException
    • updatePriceItemBaseCurrency

      public SalesItemsTree updatePriceItemBaseCurrency(String priceItemURI, String baseCurrencyUri) throws IMCException
      Update baseCurrencyUri of a Price Item
      Parameters:
      priceItemURI - as String. The URI of the price item to be updated.
      baseCurrencyUri - as String. The base Currency Uri of the price item.
      Returns:
      SalesItemsTree
      Throws:
      IMCException
    • updatePriceItemBaseQuantity

      public SalesItemsTree updatePriceItemBaseQuantity(String priceItemURI, BigDecimal baseQuantity) throws IMCException
      Update BaseQuantity with UoM of a Price Item
      Parameters:
      priceItemURI - as String. The URI of the price item to be updated.
      baseQuantity - as BigDecimal. The Base Quantity value (base condition unit) of the price item.
      Returns:
      SalesItemsTree
      Throws:
      IMCException
    • updatePriceItemBaseUnitUoM

      public SalesItemsTree updatePriceItemBaseUnitUoM(String priceItemURI, String baseUnitUoMUri, String baseUnitUoMName) throws IMCException
      Update baseUnitUoMUri and baseUnitUoMName of a Price Item
      Parameters:
      priceItemURI - as String. The URI of the price item to be updated.
      baseUnitUoMUri - as String. The base unit UoM Uri of the price item.
      baseUnitUoMName - as String. The base unit UoM Name of the price item.
      Returns:
      SalesItemsTree
      Throws:
      IMCException
    • updatePriceItemConditionIsInactive

      public SalesItemsTree updatePriceItemConditionIsInactive(String priceItemURI, boolean conditionIsInactive) throws IMCException
      Update sequence of a Price Item
      Parameters:
      priceItemURI - as String. The URI of the price item to be updated.
      sequenceID - as int. The sequence of the price item.
      Returns:
      SalesItemsTree
      Throws:
      IMCException
    • updatePriceItemJustification

      public SalesItemsTree updatePriceItemJustification(String priceItemURI, String uri) throws IMCException
      Update Justification of a Price Item
      Parameters:
      priceItemURI - as String. The URI of the price item to be updated.
      uri - as String. The URI of the justification. (http://www.inmindcloud.com/application/schema.owl#UserJustified or http://www.inmindcloud.com/application/schema.owl#SystemJustifiedERP)
      Returns:
      SalesItemsTree
      Throws:
      IMCException
    • updatePriceItemSequence

      public SalesItemsTree updatePriceItemSequence(String priceItemURI, int sequenceID) throws IMCException
      Update sequence of a Price Item
      Parameters:
      priceItemURI - as String. The URI of the price item to be updated.
      sequenceID - as int. The sequence of the price item.
      Returns:
      SalesItemsTree
      Throws:
      IMCException
    • updatePriceItemTargetAmount

      public SalesItemsTree updatePriceItemTargetAmount(String priceItemURI, BigDecimal targetAmount) throws IMCException
      Update TargetAmount of a Price Item
      Parameters:
      priceItemURI - as String. The URI of the price item to be updated.
      targetAmount - as BigDecimal. The targetAmount of the price item.
      Returns:
      SalesItemsTree
      Throws:
      IMCException
    • updatePriceItemTargetCurrency

      public SalesItemsTree updatePriceItemTargetCurrency(String priceItemURI, String targetCurrencyUri) throws IMCException
      Update TargetCurrency of a Price Item
      Parameters:
      priceItemURI - as String. The URI of the price item to be updated.
      targetCurrencyUri - as String. The target Currency Uri of the price item.
      Returns:
      SalesItemsTree
      Throws:
      IMCException