Package com.imc.iss.groovy
Class GroovyCtxUtil
java.lang.Object
com.imc.iss.groovy.GroovyCtxUtil
Utility class to retrieve data from context inside groovy script
- Since:
- 1811
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidMethod call to deprecate CalculationGraphExecute 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 variablefilterSalesItemsToExport(Collection<BusinessObject> salesItems) 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.findBO(BusinessType type, BusinessAttribute attribute, Object value) Get object given the business type, attribute and value.findBO(BusinessType type, BusinessAttribute attribute, Object value, boolean isLoadDirectlyFromDB) Get object given the business type, attribute and value.findBOFromERPId(BusinessType type, String erpId) Get object of the given type by ERP Id.findBOFromERPId(BusinessType type, String erpId, boolean isLoadDirectlyFromDB) Get object of the given type by ERP IdfindCurrencyBO(String currencyCode) Get currency business object by currency ERPIdfindPlantBO(String plantCode) Get a plant business object by plant ERPIdfindProduct(String objectERPId, String eccDestination) Get product ERPIdfindProductFinder(BusinessObject productBO, Resource[] businessAttributes) getAllVersionOfQuoteDataAttrValue(String quoteURI, String predicate) Retrieve all version of quote's data attribute valuegetAllVersionOfQuoteRelAttrValue(String quoteURI, String predicate) Retrieve all version of quote's relation attribute valuegetBusinessType(BusinessObject bo, boolean isDirect) To get the business type of a business objectbooleangetConfigItemError(SalesItemNode salesItemNode) Get the config item error status for the specified SalesItemNodegetConfigStructure(String quoteURI, SalesItemNode salesItemNode) Get the configuration structure of the SalesItemNode, if it has any.getConfigStructure(String quoteURI, SalesItemNode salesItemNode, Locale locale) Get the configuration structure of the SalesItemNode, if it has any, with any localized strings in the given locale.getDataAttrObj(BusinessObject bo, BusinessDataAttribute bda) Generic method to get single data attribute value as object.getDataAttrObjs(BusinessObject bo, BusinessDataAttribute bda) Generic method to get multiple data attribute values as object collection.getDataAttrStr(BusinessObject bo, BusinessDataAttribute bda) Generic method to get single data attribute value as String.GraphSSCGet SSC graph from contextGeneric method to get a single meta attribute value as object.Get object ERP ID of business object.Get the Organization Unit hierarchygetPriceItemType(String priceItemTypeName, BusinessDataAttribute bda) Get priceItemType by business data attribute (Schema.objectName, Schema.objectERPId)Get List of product types which are bom creation relevant.getQuoteAccount(BusinessObject quoteBO) Get account of the quote.getQuoteOpportunity(BusinessObject quoteBO) Get opportunity of the quote.Generic method to get single relation attribute value.Generic method to get multiple relation attribute values.getSalesText(String quoteURI, SalesItemNode salesItemNode) Get the sales text of the SalesItemNode, if it has any.getSalesText(String quoteURI, SalesItemNode salesItemNode, Locale locale) Get the sales text of the SalesItemNode in the given locale, if it has any.getSettingValueBO(BusinessObject settingBo) Get BusinessObject SettingValue from context.getSettingValueBoolean(BusinessObject settingBo) Get boolean SettingValue from context.getSettingValueNumeric(BusinessObject settingBo) Get Numeric SettingValue from context.getSettingValueString(BusinessObject settingBo) Get String SettingValue from context.getSSCConfigId(BusinessObject salesItemBO) Return ssc config id of related sales itemList<IInstanceData>getSSCConfigInstances(BusinessObject salesItemBO) Get configuration instances of sales item from SSC.booleanCheck if the user is from commerce user or mxvoidloadBO(BusinessObject bo) Load BusinessObject dynamicallyvoidloadSalesItemProductCategories(SalesItemsTree salesItemTree) Load product categories's data points of all the sales items within given sales item tree.booleanreconnectSSC(String quoteUri) Reconnect SSC.voidremoveRelAttrValues(BusinessObject bo, Collection<BusinessObject> removedBOs, BusinessRelationAttribute bra) Remove Relation Attributes Values.voidsetDefaultPartnerFunctions(SalesItemsTree salesItemsTree) Sets the default Partner Functions from the Account of the Quote.voidsetQuotePricingRequired(BusinessObject quoteBO, boolean flag) Update quotePricingRequired
-
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 ScriptpreCheckTypes-- 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 asBusinessTypeattribute-BusinessDataAttributeorBusinessRelationAttributevalue- 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 asBusinessTypeattribute-BusinessDataAttributeorBusinessRelationAttributevalue- value of the attributeisLoadDirectlyFromDB- 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
Get object of the given type by ERP Id.- Parameters:
type- type asBusinessTypeerpId- 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 asBusinessTypeerpId- object ERP ID as StringisLoadDirectlyFromDB- 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
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
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
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 quotepredicate- 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 quotepredicate- 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 BusinessObjectisDirect- true to only get the direct business type.- Returns:
- Collection of BusinessType
- Throws:
IMCException- the platform exception
-
getConfigItemError
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
Generic method to get single data attribute value as object. Returns null if not existed.- Parameters:
bo- : businessObjectbda- : 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 businessObjectbda- Any businessDataAttribute- Returns:
- Collection Collection of Object
- Throws:
IMCException- the platform exception
-
getDataAttrStr
Generic method to get single data attribute value as String. Returns empty string "" if not existed.- Parameters:
bo- : businessObjectbda- : businessDataAttribute- Returns:
- String
- Throws:
IMCException- the platform exception
-
getGraphSSC
public GraphSSC getGraphSSC()Get SSC graph from context- Returns:
- graphSSC SSC Graph
-
getMetaAttrObj
Generic method to get a single meta attribute value as object.- Parameters:
se- : semantic entitybma- : business meta attribute- Returns:
- Object
- Throws:
IMCException- the platform exception
-
getObjectERPId
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
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 priceItemTypebda- as BusinessDataAttribute. The BusinessDataAttribute to match the priceItemTypeName- Returns:
- BusinessObject
- Throws:
IMCException
-
getProductTypesForBOMItem
Get List of product types which are bom creation relevant.- Returns:
- List of String : List of Product Type
- Throws:
IMCException- the IMC exception
-
getQuoteAccount
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
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
public BusinessObject getRelAttr(BusinessObject bo, BusinessRelationAttribute bra) throws IMCException Generic method to get single relation attribute value. Returns null if not existed.- Parameters:
bo- : businessObjectbra- : BusinessRelationAttribute- Returns:
- BusinessObject
- Throws:
IMCException- the platform exception
-
getRelAttrs
public Collection<BusinessObject> getRelAttrs(BusinessObject bo, BusinessRelationAttribute bra) throws IMCException Generic method to get multiple relation attribute values. Returns empty collection if not existed.- Parameters:
bo- Any BusinessObjectbra- Any BusinessRelationAttribute- Returns:
- Collection of BusinessObject
- Throws:
IMCException- the platform exception
-
getSalesText
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
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
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
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
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
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- IpcCommandExceptionIMCException- 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
Load BusinessObject dynamically- Parameters:
bo- BusinessObject to load- Throws:
IMCException- the platform exception
-
loadSalesItemProductCategories
Load product categories's data points of all the sales items within given sales item tree.- Parameters:
salesItemTree- as SalesItemsTree- Throws:
IMCException
-
reconnectSSC
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
Sets the default Partner Functions from the Account of the Quote. Mainly for newly created Quote.- Parameters:
salesItemsTree- TheSalesItemsTreerepresenting the Quote data- Throws:
IMCException- the platform exception
-
setQuotePricingRequired
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
-