Class PropertyBuilder


  • public class PropertyBuilder
    extends Object

    Provides a property value builder service.

    Examples

    Example scripts are provided below.

    Create/Update Form Property

    The example below will create or update a "Product Codes" form version property against specified forms current form version. The property value may be use in Form Prefill or Dynamic Data services.

     import com.avoka.tm.svc.*
    
     String value = "product codes data..."
    
     new PropertyBuilder()
         .setName("Product Codes")
         .setValue(value)
         .setFormCode("PDS-12")
         .build() 

    Create/Update Organization Property

    The example below will create or update a "Loan Types" Organization property.

     import com.avoka.tm.svc.*
    
     String value = "loan types data..."
    
     new PropertyBuilder()
         .setName("Loan Types")
         .setValue(value)
         .setClientCode("maguire")
         .build() 

    Create/Update Form Space Property

    The example below will create or update a "Locale Messages" Form Space property.

     import com.avoka.tm.svc.*
    
     String value = "locale messages data..."
    
     new PropertyBuilder()
         .setName("Locale Messages")
         .setValue(value)
         .setSpaceName("Work Space")
         .build() 

    Reference Data Loading Example

    The example below is show a Fluent Groovy service provide a REST service endpoint for uploading an Orgs "Product Catalog" reference data set via a mult-part post request. This Fluent Groovy service is exposed via the REST Groovy Service Invoker API.

     import com.avoka.tm.svc.*
     import com.avoka.tm.vo.*
     import javax.servlet.http.*
     import org.apache.commons.fileupload.FileItem
    
     class FluentGroovyService {
    
         // Injected at runtime
         public Logger logger
    
         Object invoke(SvcDef svcDef, HttpServletRequest request, User user, Map params) {
    
             // Get the products file upload file item
             FileItem fileItem = (FileItem) params.products
    
             logger.info "loading file: " + fileItem.name
    
             // Convert the fileItem binary data to CSV text
             String productsCSV = new String(fileItem.get(), "UTF-8")
    
             // Create or update the Organizations "Product Catalog" property
             new PropertyBuilder()
                 .setName("Product Catalog")
                 .setValue(productsCSV)
                 .setClientCode(svcDef.clientCode)
                 .build()
    
             String msg = "Imported '" + fileItem.name + "' file into 'Product Catalog' organization property"
             logger.info msg
    
             return msg
         }
     } 
    Since:
    5.0.0
    • Constructor Detail

      • PropertyBuilder

        public PropertyBuilder()
    • Method Detail

      • setName

        public PropertyBuilder setName​(String name)
        Set the property name parameter.
        Parameters:
        name - the property name
        Returns:
        the property builder
      • setValue

        public PropertyBuilder setValue​(String value)
        Set the property value parameter.
        Parameters:
        value - the property value
        Returns:
        the property builder
      • setClientCode

        @FluentSecurityPermission(permissions="organization-property-edit")
        public PropertyBuilder setClientCode​(String clientCode)
        Set the property organization client code parameter.
        Parameters:
        clientCode - the property organization client code
        Returns:
        the property builder
      • build

        public void build()
        Create or update the property based on the specified parameter.