Class GroovyCtxUtil

java.lang.Object
com.imc.iss.groovy.GroovyCtxUtil

public class GroovyCtxUtil extends Object
Utility class to retrieve data from context inside groovy script
Since:
1811
  • Constructor Details

    • GroovyCtxUtil

      public GroovyCtxUtil(BaseContext ctx)
  • Method Details

    • deprecateCalculationGraph

      public void deprecateCalculationGraph()
      Method call to deprecate CalculationGraph
    • executeClassifiedProductsFromConfiguration

      public Map<CheckBeforeQuoteSubmitCommand.PreCheckType,Object> executeClassifiedProductsFromConfiguration(String quoteURI) throws IMCException
      Execute the Pre Submit check having PreCheckType, CONFIGURABLE_TO_CLASSIFIED_PRODUCTS inside the Groovy Script to obtain the result of check so that it can be stored in groovy script result variable
      Parameters:
      quoteURI - URI of the current quote accessible by the Groovy Script
      preCheckTypes -
      Throws:
      IMCException - the platform exception
    • filterSalesItemsToExport

      public Collection<BusinessObject> filterSalesItemsToExport(Collection<BusinessObject> salesItems) throws IMCException
      Filter sales items to export to ERP Criteria are whether product is exported to ERP, system created sales items, ERP ID existed and optional sales items. FilterSalesItemToExportCommand
      Parameters:
      salesItems - Unfiltered sales item bo collection
      Returns:
      Filtered sales item bo collection
      Throws:
      IMCException - the platform exception
    • findBO

      public BusinessObject findBO(BusinessType type, BusinessAttribute attribute, Object value) throws IMCException
      Get object given the business type, attribute and value.
      Parameters:
      type - type as BusinessType
      attribute - BusinessDataAttribute or BusinessRelationAttribute
      value - value of the attribute
      Returns:
      If an object is found, return object as BusinessObject, else null
      Throws:
      IMCException - the platform exception
    • findBO

      public BusinessObject findBO(BusinessType type, BusinessAttribute attribute, Object value, boolean isLoadDirectlyFromDB) throws IMCException
      Get object given the business type, attribute and value.
      Parameters:
      type - type as BusinessType
      attribute - BusinessDataAttribute or BusinessRelationAttribute
      value - value of the attribute
      isLoadDirectlyFromDB - if {@link true}, a direct database call is fired to find the BO
      Returns:
      If an object is found, return object as BusinessObject, else null
      Throws:
      IMCException - the platform exception
    • findBOFromERPId

      public BusinessObject findBOFromERPId(BusinessType type, String erpId) throws IMCException
      Get object of the given type by ERP Id.
      Parameters:
      type - type as BusinessType
      erpId - object ERP ID as String
      Returns:
      If an object is found, return object as BusinessObject, else null.
      Throws:
      IMCException - the platform exception
    • findBOFromERPId

      public BusinessObject findBOFromERPId(BusinessType type, String erpId, boolean isLoadDirectlyFromDB) throws IMCException
      Get object of the given type by ERP Id
      Parameters:
      type - type as BusinessType
      erpId - object ERP ID as String
      isLoadDirectlyFromDB - if {@link true}, a direct database call is fired to find the BO
      Returns:
      If an object is found, return object as BusinessObject, else null
      Throws:
      IMCException - the platform exception
    • findCurrencyBO

      public BusinessObject findCurrencyBO(String currencyCode) throws IMCException
      Get currency business object by currency ERPId
      Parameters:
      currencyCode - as String. The objectERPId of the currency to match.
      Returns:
      value as BusinessObject, otherwise, return null
      Throws:
      IMCException - the platform exception
    • findPlantBO

      public BusinessObject findPlantBO(String plantCode) throws IMCException
      Get a plant business object by plant ERPId
      Parameters:
      plantCode - as String. The objectERPId of the plant to match.
      Returns:
      value as BusinessObject, otherwise, return null.
      Throws:
      IMCException - the platform exception
    • findProduct

      public BusinessObject findProduct(String objectERPId, String eccDestination) throws IMCException
      Get product ERPId
      Parameters:
      objectERPId - as String. Product ObjectERPId to match.
      Returns:
      value as BusinessObject, otherwise, return null.
      Throws:
      IMCException - the platform exception
    • findProductFinder

      public Collection<BusinessObject> findProductFinder(BusinessObject productBO, Resource[] businessAttributes) throws IMCException
      Throws:
      IMCException
    • getAllVersionOfQuoteDataAttrValue

      public Map<Integer,Object> getAllVersionOfQuoteDataAttrValue(String quoteURI, String predicate) throws IMCException
      Retrieve all version of quote's data attribute value
      Parameters:
      quoteURI - as String. The URI of the quote
      predicate - as String. The URI of the predicate
      Returns:
      Map<Integer, String>. Return document version number as map key and the object value as map value
      Throws:
      IMCException - the platform exception
    • getAllVersionOfQuoteRelAttrValue

      public Map<Integer,Object> getAllVersionOfQuoteRelAttrValue(String quoteURI, String predicate) throws IMCException
      Retrieve all version of quote's relation attribute value
      Parameters:
      quoteURI - as String. The URI of the quote
      predicate - as String. The URI of the predicate
      Returns:
      Map<Integer, String>. Return document version number as map key and the object URI as map value
      Throws:
      IMCException - the platform exception
    • getBusinessType

      public Collection<BusinessType> getBusinessType(BusinessObject bo, boolean isDirect) throws IMCException
      To get the business type of a business object
      Parameters:
      bo - Any BusinessObject
      isDirect - true to only get the direct business type.
      Returns:
      Collection of BusinessType
      Throws:
      IMCException - the platform exception
    • getConfigItemError

      public boolean getConfigItemError(SalesItemNode salesItemNode) throws IMCException
      Get the config item error status for the specified SalesItemNode
      Returns:
      context as BaseContext
      Throws:
      IMCException
    • getConfigStructure

      public List<GroupData> getConfigStructure(String quoteURI, SalesItemNode salesItemNode) throws IMCException
      Get the configuration structure of the SalesItemNode, if it has any.
      Parameters:
      quoteURI -
      salesItemNode -
      Returns:
      Collection of GroupData
      Throws:
      IMCException - the platform exception
    • getConfigStructure

      public List<GroupData> getConfigStructure(String quoteURI, SalesItemNode salesItemNode, Locale locale) throws IMCException
      Get the configuration structure of the SalesItemNode, if it has any, with any localized strings in the given locale.
      Parameters:
      quoteURI -
      salesItemNode -
      locale -
      Returns:
      Collection of GroupData
      Throws:
      IMCException - the platform exception
    • getDataAttrObj

      public Object getDataAttrObj(BusinessObject bo, BusinessDataAttribute bda) throws IMCException
      Generic method to get single data attribute value as object. Returns null if not existed.
      Parameters:
      bo - : businessObject
      bda - : businessDataAttribute
      Returns:
      Object
      Throws:
      IMCException - the platform exception
    • getDataAttrObjs

      public Collection<Object> getDataAttrObjs(BusinessObject bo, BusinessDataAttribute bda) throws IMCException
      Generic method to get multiple data attribute values as object collection. Returns empty collection if not existed.
      Parameters:
      bo - Any businessObject
      bda - Any businessDataAttribute
      Returns:
      Collection Collection of Object
      Throws:
      IMCException - the platform exception
    • getDataAttrStr

      public String getDataAttrStr(BusinessObject bo, BusinessDataAttribute bda) throws IMCException
      Generic method to get single data attribute value as String. Returns empty string "" if not existed.
      Parameters:
      bo - : businessObject
      bda - : businessDataAttribute
      Returns:
      String
      Throws:
      IMCException - the platform exception
    • getGraphSSC

      public GraphSSC getGraphSSC()
      Get SSC graph from context
      Returns:
      graphSSC SSC Graph
    • getMetaAttrObj

      public Object getMetaAttrObj(SemanticEntity se, BusinessMetaAttribute bma) throws IMCException
      Generic method to get a single meta attribute value as object.
      Parameters:
      se - : semantic entity
      bma - : business meta attribute
      Returns:
      Object
      Throws:
      IMCException - the platform exception
    • getObjectERPId

      public String getObjectERPId(BusinessObject bo) throws IMCException
      Get object ERP ID of business object. Returns empty string "" if not existed.
      Parameters:
      bo - Any BusinessObject
      Returns:
      objectERPID objectERPID of input bo
      Throws:
      IMCException - the platform exception
    • getOrgUnitHierarchy

      public OrgUnitHierarchy getOrgUnitHierarchy() throws IMCException
      Get the Organization Unit hierarchy
      Returns:
      OrgUnitHierarchy
      Throws:
      IMCException
    • getPriceItemType

      public BusinessObject getPriceItemType(String priceItemTypeName, BusinessDataAttribute bda) throws IMCException
      Get priceItemType by business data attribute (Schema.objectName, Schema.objectERPId)
      Parameters:
      priceItemTypeName - as String. The name of the priceItemType
      bda - as BusinessDataAttribute. The BusinessDataAttribute to match the priceItemTypeName
      Returns:
      BusinessObject
      Throws:
      IMCException
    • getProductTypesForBOMItem

      public List<String> getProductTypesForBOMItem() throws IMCException
      Get List of product types which are bom creation relevant.
      Returns:
      List of String : List of Product Type
      Throws:
      IMCException - the IMC exception
    • getQuoteAccount

      public BusinessObject getQuoteAccount(BusinessObject quoteBO) throws IMCException
      Get account of the quote. Returns null if not existed.
      Parameters:
      quoteBO - Quote BusinessObject
      Returns:
      accountBO Account BusinessObject of Quote if exists, otherwise, return null.
      Throws:
      IMCException - the platform exception
    • getQuoteOpportunity

      public BusinessObject getQuoteOpportunity(BusinessObject quoteBO) throws IMCException
      Get opportunity of the quote. Returns null if not existed.
      Parameters:
      quoteBO - Quote BusinessObject
      Returns:
      opportunityBO Opportunity BusinessObject of Quote if exists, otherwise return null.
      Throws:
      IMCException - the platform exception
    • getRelAttr

      Generic method to get single relation attribute value. Returns null if not existed.
      Parameters:
      bo - : businessObject
      bra - : BusinessRelationAttribute
      Returns:
      BusinessObject
      Throws:
      IMCException - the platform exception
    • getRelAttrs

      Generic method to get multiple relation attribute values. Returns empty collection if not existed.
      Parameters:
      bo - Any BusinessObject
      bra - Any BusinessRelationAttribute
      Returns:
      Collection of BusinessObject
      Throws:
      IMCException - the platform exception
    • getSalesText

      public String getSalesText(String quoteURI, SalesItemNode salesItemNode) throws IMCException
      Get the sales text of the SalesItemNode, if it has any.
      Parameters:
      quoteURI -
      salesItemNode -
      Returns:
      The Product Sales Text for the sales item
      Throws:
      IMCException - the platform exception
    • getSalesText

      public String getSalesText(String quoteURI, SalesItemNode salesItemNode, Locale locale) throws IMCException
      Get the sales text of the SalesItemNode in the given locale, if it has any.
      Parameters:
      quoteURI -
      salesItemNode -
      locale -
      Returns:
      The Product Sales Text for the sales item
      Throws:
      IMCException - the platform exception
    • getSettingValueBO

      public BusinessObject getSettingValueBO(BusinessObject settingBo) throws IMCException
      Get BusinessObject SettingValue from context. Returns null if not existed.
      Parameters:
      settingBo - as BusinessObject
      Returns:
      value as BusinessObject, otherwise, return null.
      Throws:
      IMCException - the platform exception
    • getSettingValueBoolean

      public Boolean getSettingValueBoolean(BusinessObject settingBo) throws IMCException
      Get boolean SettingValue from context. Returns false if not existed.
      Parameters:
      settingBo - as BusinessObject
      Returns:
      value as boolean, otherwise, return false.
      Throws:
      IMCException - the platform exception
    • getSettingValueNumeric

      public BigDecimal getSettingValueNumeric(BusinessObject settingBo) throws IMCException
      Get Numeric SettingValue from context. Returns null if not existed.
      Parameters:
      settingBo - as BusinessObject
      Returns:
      value as Decimal, otherwise, return null.
      Throws:
      IMCException - the platform exception
    • getSettingValueString

      public String getSettingValueString(BusinessObject settingBo) throws IMCException
      Get String SettingValue from context. Returns null if not existed.
      Parameters:
      settingBo - as BusinessObject
      Returns:
      value as String, otherwise, return null.
      Throws:
      IMCException - the platform exception
    • getSSCConfigId

      public String getSSCConfigId(BusinessObject salesItemBO) throws IMCException
      Return ssc config id of related sales item
      Parameters:
      salesItemBO - SalesItem BusinessObject
      Returns:
      config ID in SSC
      Throws:
      IMCException - the platform exception
    • getSSCConfigInstances

      public List<IInstanceData> getSSCConfigInstances(BusinessObject salesItemBO) throws IpcCommandException, IMCException
      Get configuration instances of sales item from SSC. Returns empty array list if not existed.
      Parameters:
      salesItemBO - SalesItem BusinessObject
      Returns:
      List of IInstanceData if exists, otherwise, return empty list.
      Throws:
      IpcCommandException - IpcCommandException
      IMCException - the platform exception
    • isCommerce

      public boolean isCommerce()
      Check if the user is from commerce user or mx
      Returns:
      value as boolean true, otherwise, return false.
    • loadBO

      public void loadBO(BusinessObject bo) throws IMCException
      Load BusinessObject dynamically
      Parameters:
      bo - BusinessObject to load
      Throws:
      IMCException - the platform exception
    • loadSalesItemProductCategories

      public void loadSalesItemProductCategories(SalesItemsTree salesItemTree) throws IMCException
      Load product categories's data points of all the sales items within given sales item tree.
      Parameters:
      salesItemTree - as SalesItemsTree
      Throws:
      IMCException
    • reconnectSSC

      public boolean reconnectSSC(String quoteUri) throws IMCException
      Reconnect SSC. This method will disconnect ssc engine and reconnect it. If quote has unsaved changes, it will throw exception. This will prevent future data loss.
      Parameters:
      quoteUri - as String.
      Returns:
      true if quote reconnection is successful, otherwise, returns false;
      Throws:
      IMCException
    • removeRelAttrValues

      public void removeRelAttrValues(BusinessObject bo, Collection<BusinessObject> removedBOs, BusinessRelationAttribute bra) throws IMCException
      Remove Relation Attributes Values.
      Parameters:
      bo - as BusinessObject. The business object of the subject.
      removedBOs - as Collection. The list of business object to be removed.
      bra - as BusinessRelationAttribute. The BusinessRelationAttribute linking the subject and the object.
      Throws:
      IMCException - the platform exception
    • setDefaultPartnerFunctions

      public void setDefaultPartnerFunctions(SalesItemsTree salesItemsTree) throws IMCException
      Sets the default Partner Functions from the Account of the Quote. Mainly for newly created Quote.
      Parameters:
      salesItemsTree - The SalesItemsTree representing the Quote data
      Throws:
      IMCException - the platform exception
    • setQuotePricingRequired

      public void setQuotePricingRequired(BusinessObject quoteBO, boolean flag) throws IMCException
      Update quotePricingRequired
      Parameters:
      quoteBO - as BusinessObject. The business object of the quote.
      flag - as boolean. The boolean value to indicate quotePricingRequired
      Throws:
      IMCException - the platform exception