Class ModelService

java.lang.Object
java.util.AbstractMap<String,Object>
org.apache.ofbiz.service.ModelService
All Implemented Interfaces:
Serializable, Map<String,Object>

public class ModelService extends AbstractMap<String,Object> implements Serializable
Generic Service Model Class
See Also:
  • Field Details

  • Constructor Details

    • ModelService

      public ModelService()
    • ModelService

      public ModelService(ModelService model)
  • Method Details

    • setName

      public void setName(String name)
      Sets name.
      Parameters:
      name - the name
    • setDefinitionLocation

      public void setDefinitionLocation(String definitionLocation)
      Sets definition location.
      Parameters:
      definitionLocation - the definition location
    • setDescription

      public void setDescription(String description)
      Sets description.
      Parameters:
      description - the description
    • setEngineName

      public void setEngineName(String engineName)
      Sets engine name.
      Parameters:
      engineName - the engine name
    • setNameSpace

      public void setNameSpace(String nameSpace)
      Sets name space.
      Parameters:
      nameSpace - the name space
    • setAction

      public void setAction(String action)
      Sets action.
      Parameters:
      action - the action
    • setLocation

      public void setLocation(String location)
      Sets location.
      Parameters:
      location - the location
    • setInvoke

      public void setInvoke(String invoke)
      Sets invoke.
      Parameters:
      invoke - the invoke
    • setDefaultEntityName

      public void setDefaultEntityName(String defaultEntityName)
      Sets default entity name.
      Parameters:
      defaultEntityName - the default entity name
    • setFromLoader

      public void setFromLoader(String fromLoader)
      Sets from loader.
      Parameters:
      fromLoader - the from loader
    • setAuth

      public void setAuth(boolean auth)
      Sets auth.
      Parameters:
      auth - the auth
    • setExport

      public void setExport(boolean export)
      Sets export.
      Parameters:
      export - the export
    • setDebug

      public void setDebug(boolean debug)
      Sets debug.
      Parameters:
      debug - the debug
    • setValidate

      public void setValidate(boolean validate)
      Sets validate.
      Parameters:
      validate - the validate
    • setUseTransaction

      public void setUseTransaction(boolean useTransaction)
      Sets use transaction.
      Parameters:
      useTransaction - the use transaction
    • setRequireNewTransaction

      public void setRequireNewTransaction(boolean requireNewTransaction)
      Sets require new transaction.
      Parameters:
      requireNewTransaction - the require new transaction
    • setTransactionTimeout

      public void setTransactionTimeout(int transactionTimeout)
      Sets transaction timeout.
      Parameters:
      transactionTimeout - the transaction timeout
    • setMaxRetry

      public void setMaxRetry(int maxRetry)
      Sets max retry.
      Parameters:
      maxRetry - the max retry
    • setModelPermission

      public void setModelPermission(ModelPermission modelPermission)
      Sets model permission.
      Parameters:
      modelPermission - the model permission
    • setSemaphore

      public void setSemaphore(String semaphore)
      Sets semaphore.
      Parameters:
      semaphore - the semaphore
    • setSemaphoreWait

      public void setSemaphoreWait(int semaphoreWait)
      Sets semaphore wait.
      Parameters:
      semaphoreWait - the semaphore wait
    • setSemaphoreSleep

      public void setSemaphoreSleep(int semaphoreSleep)
      Sets semaphore sleep.
      Parameters:
      semaphoreSleep - the semaphore sleep
    • setHideResultInLog

      public void setHideResultInLog(boolean hideResultInLog)
      Sets hide result in log.
      Parameters:
      hideResultInLog - the hide result in log
    • getDefinitionLocation

      public String getDefinitionLocation()
      Gets definition location.
      Returns:
      the definition location
    • setImplServices

      public void setImplServices(Set<ModelServiceIface> implServices)
      Sets impl services.
      Parameters:
      implServices - the impl services
    • setOverrideParameters

      public void setOverrideParameters(Set<ModelParam> overrideParameters)
      Sets override parameters.
      Parameters:
      overrideParameters - the override parameters
    • setPermissionGroups

      public void setPermissionGroups(List<ModelPermGroup> permissionGroups)
      Sets permission groups.
      Parameters:
      permissionGroups - the permission groups
    • setNotifications

      public void setNotifications(List<ModelNotification> notifications)
      Sets notifications.
      Parameters:
      notifications - the notifications
    • setInternalGroup

      public void setInternalGroup(GroupModel internalGroup)
      Sets internal group.
      Parameters:
      internalGroup - the internal group
    • setDeprecatedUseInstead

      public void setDeprecatedUseInstead(String deprecatedUseInstead)
      Sets deprecated use instead.
      Parameters:
      deprecatedUseInstead - the deprecated use instead
    • setDeprecatedSince

      public void setDeprecatedSince(String deprecatedSince)
      Sets deprecated since.
      Parameters:
      deprecatedSince - the deprecated since
    • setDeprecatedReason

      public void setDeprecatedReason(String deprecatedReason)
      Sets deprecated reason.
      Parameters:
      deprecatedReason - the deprecated reason
    • setContextInfo

      public void setContextInfo(Map<String,ModelParam> contextInfo)
      Sets context info.
      Parameters:
      contextInfo - the context info
    • setContextParamList

      public void setContextParamList(List<ModelParam> contextParamList)
      Sets context param list.
      Parameters:
      contextParamList - the context param list
    • setInheritedParameters

      public void setInheritedParameters(boolean inheritedParameters)
      Sets inherited parameters.
      Parameters:
      inheritedParameters - the inherited parameters
    • setMetrics

      public void setMetrics(Metrics metrics)
      Sets metrics.
      Parameters:
      metrics - the metrics
    • getDescription

      public String getDescription()
      Gets description.
      Returns:
      the description
    • getNameSpace

      public String getNameSpace()
      Gets name space.
      Returns:
      the name space
    • getAction

      public String getAction()
      Gets action.
      Returns:
      the action
    • getDefaultEntityName

      public String getDefaultEntityName()
      Gets default entity name.
      Returns:
      the default entity name
    • getFromLoader

      public String getFromLoader()
      Gets from loader.
      Returns:
      the from loader
    • isExport

      public boolean isExport()
      Is export boolean.
      Returns:
      the boolean
    • getSemaphoreWait

      public int getSemaphoreWait()
      Gets semaphore wait.
      Returns:
      the semaphore wait
    • getSemaphoreSleep

      public int getSemaphoreSleep()
      Gets semaphore sleep.
      Returns:
      the semaphore sleep
    • getImplServices

      public Set<ModelServiceIface> getImplServices()
      Gets impl services.
      Returns:
      the impl services
    • getOverrideParameters

      public Set<ModelParam> getOverrideParameters()
      Gets override parameters.
      Returns:
      the override parameters
    • getPermissionGroups

      public List<ModelPermGroup> getPermissionGroups()
      Gets permission groups.
      Returns:
      the permission groups
    • getNotifications

      public List<ModelNotification> getNotifications()
      Gets notifications.
      Returns:
      the notifications
    • getInternalGroup

      public GroupModel getInternalGroup()
      Gets internal group.
      Returns:
      the internal group
    • getDeprecatedUseInstead

      public String getDeprecatedUseInstead()
      Gets deprecated use instead.
      Returns:
      the deprecated use instead
    • getDeprecatedSince

      public String getDeprecatedSince()
      Gets deprecated since.
      Returns:
      the deprecated since
    • getDeprecatedReason

      public String getDeprecatedReason()
      Gets deprecated reason.
      Returns:
      the deprecated reason
    • getContextInfo

      public Map<String,ModelParam> getContextInfo()
      Gets context info.
      Returns:
      the context info
    • getContextParamList

      public List<ModelParam> getContextParamList()
      Gets context param list.
      Returns:
      the context param list
    • isInheritedParameters

      public boolean isInheritedParameters()
      Is inherited parameters boolean.
      Returns:
      the boolean
    • getName

      public String getName()
      Gets name.
      Returns:
      the name
    • getInvoke

      public String getInvoke()
      Gets invoke.
      Returns:
      the invoke
    • isHideResultInLog

      public boolean isHideResultInLog()
      Is hide result in log boolean.
      Returns:
      the boolean
    • getMetrics

      public Metrics getMetrics()
      Gets metrics.
      Returns:
      the metrics
    • isAuth

      public boolean isAuth()
      Is auth boolean.
      Returns:
      the boolean
    • isValidate

      public boolean isValidate()
      Is validate boolean.
      Returns:
      the boolean
    • getModelPermission

      public ModelPermission getModelPermission()
      Gets model permission.
      Returns:
      the model permission
    • isUseTransaction

      public boolean isUseTransaction()
      Is use transaction boolean.
      Returns:
      the boolean
    • isRequireNewTransaction

      public boolean isRequireNewTransaction()
      Is require new transaction boolean.
      Returns:
      the boolean
    • getTransactionTimeout

      public int getTransactionTimeout()
      Gets transaction timeout.
      Returns:
      the transaction timeout
    • getMaxRetry

      public int getMaxRetry()
      Gets max retry.
      Returns:
      the max retry
    • getEngineName

      public String getEngineName()
      Gets engine name.
      Returns:
      the engine name
    • getLocation

      public String getLocation()
      Gets location.
      Returns:
      the location
    • isDebug

      public boolean isDebug()
      Is debug boolean.
      Returns:
      the boolean
    • getSemaphore

      public String getSemaphore()
      Gets semaphore.
      Returns:
      the semaphore
    • get

      public Object get(Object name)
      Specified by:
      get in interface Map<String,Object>
      Overrides:
      get in class AbstractMap<String,Object>
    • entrySet

      public Set<Map.Entry<String,Object>> entrySet()
      Specified by:
      entrySet in interface Map<String,Object>
      Specified by:
      entrySet in class AbstractMap<String,Object>
    • put

      public Object put(String o1, Object o2)
      Specified by:
      put in interface Map<String,Object>
      Overrides:
      put in class AbstractMap<String,Object>
    • toString

      public String toString()
      Overrides:
      toString in class AbstractMap<String,Object>
    • debugInfo

      public String debugInfo()
      Debug info string.
      Returns:
      the string
    • inheritedParameters

      public boolean inheritedParameters()
      Test if we have already inherited our interface parameters
      Returns:
      boolean
    • getParam

      public ModelParam getParam(String name)
      Gets the ModelParam by name
      Parameters:
      name - The name of the parameter to get
      Returns:
      ModelParam object with the specified name
    • addParam

      public void addParam(ModelParam param)
      Adds a parameter definition to this service; puts on list in order added then sorts by order if specified.
    • addParamClone

      public void addParamClone(ModelParam param)
      Adds a clone of a parameter definition to this service
    • getAllParamNames

      public Set<String> getAllParamNames()
      Gets all param names.
      Returns:
      the all param names
    • getInParamNames

      public Set<String> getInParamNames()
      Gets in param names.
      Returns:
      the in param names
    • getInParamNamesMap

      public Map<String,String> getInParamNamesMap()
      Creates a map of service IN parameters using Name as key and Type as value. Skips internal parameters
      Returns:
      Map of IN parameters
    • getOutParamNamesMap

      public Map<String,String> getOutParamNamesMap()
      Creates a map of service OUT parameters using Name as key and Type as value. Skips internal parameters
      Returns:
      Map of OUT parameters
    • getDefinedInCount

      public int getDefinedInCount()
      Gets defined in count.
      Returns:
      the defined in count
    • getOutParamNames

      public Set<String> getOutParamNames()
      Gets out param names.
      Returns:
      the out param names
    • getDefinedOutCount

      public int getDefinedOutCount()
      only returns number of defined parameters (not internal)
    • updateDefaultValues

      public void updateDefaultValues(Map<String,Object> context, String mode)
      Update default values.
      Parameters:
      context - the context
      mode - the mode
    • validate

      public void validate(Map<String,Object> context, String mode, Locale locale) throws ServiceValidationException
      Validates a Map against the IN or OUT parameter information
      Parameters:
      context - the context
      mode - Test either mode IN or mode OUT
      locale - the actual locale to use
      Throws:
      ServiceValidationException
    • validate

      public void validate(List<ModelParam> modelParamList, Map<String,Object> context, String mode, Locale locale) throws ServiceValidationException
      Validates a Map against the IN or OUT parameter information for a given list of modelParam this is used for recursive validation of map and list modelParam in service definition
      Parameters:
      modelParamList - List of paramList to validate
      context - the context
      mode - Test either mode IN or mode OUT
      locale - the actual locale to use
      Throws:
      ServiceValidationException
    • isValid

      public boolean isValid(Map<String,Object> context, Locale locale)
      Check a Map against the IN parameter information, uses the validate() method for that Always called with only IN_PARAM, so to be called before the service is called with the passed context
      Parameters:
      context - the passed context
      locale - the actual locale to use
      Returns:
      boolean True is the service called with these IN_PARAM is valid
    • validate

      public void validate(Map<String,ModelParam> modelParamMap, Map<String,?> values, boolean reverse, ModelService model, String mode, Locale locale) throws ServiceValidationException
      Validates a map of name, object types to a map of name, objects
      Parameters:
      modelParamMap - The map of name, modelParam
      values - The map to test its value types.
      reverse - Test the maps in reverse.
      Throws:
      ServiceValidationException
    • typeValidate

      public static boolean typeValidate(org.apache.ofbiz.service.ModelParam.ModelParamValidator vali, Object testValue) throws GeneralException
      Throws:
      GeneralException
    • getParameterNames

      public List<String> getParameterNames(String mode, boolean optional, boolean internal)
      Gets the parameter names of the specified mode (IN/OUT). The parameters will be returned in the order specified in the file. Note: IN and OUT will also contains INOUT parameters.
      Parameters:
      mode - The mode (IN/OUT)
      optional - True if to include optional parameters
      internal - True to include internal parameters
      Returns:
      List of parameter names
    • getParameterNames

      public List<String> getParameterNames(String mode, boolean optional)
      Gets parameter names.
      Parameters:
      mode - the mode
      optional - the optional
      Returns:
      the parameter names
    • makeValid

      public Map<String,Object> makeValid(Map<String,? extends Object> source, String mode)
      Creates a new Map based from an existing map with just valid parameters. Tries to convert parameters to required type.
      Parameters:
      source - The source map
      mode - The mode which to build the new map
    • makeValid

      public Map<String,Object> makeValid(Map<String,? extends Object> source, String mode, boolean includeInternal, List<Object> errorMessages)
      Creates a new Map based from an existing map with just valid parameters. Tries to convert parameters to required type.
      Parameters:
      source - The source map
      mode - The mode which to build the new map
      includeInternal - When false will exclude internal fields
    • makeValid

      public Map<String,Object> makeValid(Map<String,? extends Object> source, String mode, boolean includeInternal, List<Object> errorMessages, Locale locale)
      Creates a new Map based from an existing map with just valid parameters. Tries to convert parameters to required type.
      Parameters:
      source - The source map
      mode - The mode which to build the new map
      includeInternal - When false will exclude internal fields
      locale - Locale to use to do some type conversion
    • makeValid

      public Map<String,Object> makeValid(Map<String,? extends Object> source, String mode, boolean includeInternal, List<Object> errorMessages, TimeZone timeZone, Locale locale)
      Creates a new Map based from an existing map with just valid parameters. Tries to convert parameters to required type.
      Parameters:
      source - The source map
      mode - The mode which to build the new map
      includeInternal - When false will exclude internal fields
      errorMessages - List of errorMessages
      timeZone - The TimeZone
      locale - Locale to use to do some type conversion
      Returns:
    • makeValid

      public Map<String,Object> makeValid(List<ModelParam> modelParams, Map<String,? extends Object> source, String mode, boolean includeInternal, List<Object> errorMessages, TimeZone timeZone, Locale locale)
      Creates a new Map based from an existing map with just valid parameters. Tries to convert parameters to required type.
      Parameters:
      modelParams - Model parameters to validate
      source - The source map
      mode - The mode which to build the new map
      includeInternal - When false will exclude internal fields
      errorMessages - the list of error messages
      timeZone - TimeZone to use to do some type conversion
      locale - Locale to use to do some type conversion
    • containsPermissions

      public boolean containsPermissions()
      Contains permissions boolean.
      Returns:
      the boolean
    • evalPermission

      public Map<String,Object> evalPermission(DispatchContext dctx, Map<String,? extends Object> context)
      Evaluates permission-service for this service.
      Parameters:
      dctx - DispatchContext from the invoked service
      context - Map containing userLogin and context information
      Returns:
      result of permission service invocation
    • evalNotifications

      public void evalNotifications(DispatchContext dctx, Map<String,? extends Object> context, Map<String,Object> result)
      Evaluates notifications
    • evalPermissions

      public Map<String,Object> evalPermissions(DispatchContext dctx, Map<String,? extends Object> context)
      Evaluates permissions for a service.
      Parameters:
      dctx - DispatchContext from the invoked service
      context - Map containing userLogin information
      Returns:
      Map if all permissions evaluate return success else return the error message list.
    • getInParameterSequence

      public List<Object> getInParameterSequence(Map<String,? extends Object> source)
      Gets a list of required IN parameters in sequence.
      Returns:
      A list of required IN parameters in the order which they were defined.
    • getModelParamList

      public List<ModelParam> getModelParamList()
      Returns a list of ModelParam objects in the order they were defined when the service was created.
    • getInModelParamList

      public List<ModelParam> getInModelParamList()
      Returns a list of ModelParam objects in the order they were defined when the service was created.
    • interfaceUpdate

      public void interfaceUpdate(DispatchContext dctx) throws GenericServiceException
      Run the interface update and inherit all interface parameters
      Parameters:
      dctx - The DispatchContext to use for service lookups
      Throws:
      GenericServiceException
    • informIfDeprecated

      public void informIfDeprecated()
      if the service is declare as deprecated, create a log warning with the reason
    • toWSDL

      public Document toWSDL(String locationURI) throws javax.wsdl.WSDLException
      To wsdl document.
      Parameters:
      locationURI - the location uri
      Returns:
      the document
      Throws:
      javax.wsdl.WSDLException - the wsdl exception
    • getWSDL

      public void getWSDL(javax.wsdl.Definition def, String locationURI) throws javax.wsdl.WSDLException
      Gets wsdl.
      Parameters:
      def - the def
      locationURI - the location uri
      Throws:
      javax.wsdl.WSDLException - the wsdl exception
    • getTypes

      public javax.wsdl.Types getTypes(Document document, javax.wsdl.Definition def)
      Gets types.
      Parameters:
      document - the document
      def - the def
      Returns:
      the types