Upload File Using Parse to Pega 7

This mail service shows how a Service and a File Listener rule tin be used to automatically populate a data tabular array based on an input text file (comma-separated values). During processing, the delimited text file is parsed and for each row, a record is created in the target data table. This setup saves manual labor when large input files are used to populate information tables.

  • Creating an Auto-Complete Control Backed by a Information Table
  • Using a Data Folio for a Dropdown and Sorting the Options with a Information Transform in Pega 7.1.9
  • Source Dropdown Options from a Data Page and Group past a Property in Pega 7.1.9
  • Case of Cascading Dropdowns with Linked Class Primal Property in Pega 7.i.6
  1. Setup of Data Table in Pega 7 and Description of CSV File Format
  2. Creating the Service Rule using the Pega 7 Service Accelerator
  3. Implementing the Service Dominion to Parse and Process CSV Files in Pega 7
  4. File Listener Configuration in Pega 7
  5. Running the File Listener
  6. Motion CSV Files to Source Location and Run File Listener and Service in Pega 7

In this example, an existing information table for a class named ABC-Insurance-Data-Adjuster is populated automatically. The information table serves equally a reference for claims adjusters that are contracted for investigating insurance claims. This class has the post-obit properties:

ID of type Identifier

Firstname of blazon Text

pyLabel of type TextPega standard holding will be used for the last name

HourlyRate of type Decimal

PhoneNumber of type Text

  • The screen shot beneath shows the configuration page when this data table was created using the Information Table Wizard.
  • Note that the cheque box CREATE Defended DATABASE TABLE? is checked so that this static reference data can exist migrated with the awarding.

Pega Data Table Wizard - Create New Data Table

  • Initially, in that location is no data in the data table and the row count shows 0 in the data table view.

Pega 7 Designer Studio - Data Model - Show Data Tables

  • The gear icon in the Edit column can be used to manually insert instances.
  • However, in this case, a Service and File Listener rule are used to automatically insert instances from a sample CSV text file shown below.

Example CSV File adjusters.csv

  • Each delimited row in the file represents a claims adjuster (a person that reviews an insurance merits).
  • The construction of the rows must friction match the properties divers in the data table into which instances will exist inserted.
  • In addition, the input file has a header row where the fields match the belongings names of the form of the target data tabular array.

A Service dominion needs to be created. This dominion volition read and parse the input CSV file(s) and so use an action to insert instances into the specified data table for each input row.

  • Navigate to Designer Studio > Integration > Services > Service Wizard to open up the Service Accelerator tool.

Pega 7 Designer Studio - Accessing the Service Wizard

  • Select Process input or output data for the Service purpose and File for the service blazon, then click the Next button.

Pega 7 Service Accelerator (Service Wizard) - Select Service Purpose

  • This stride requires the pick of the appropriate data course, i.e. the class name of the information table into which instances will be inserted.
  • In this case, the data grade is ABC-Insurance-Data-Adjuster. The service proper name in this example is InsertAdjusters and the magician will use this proper name for the generated Service.
  • Click on the Next button to go along.

Pega 7 Service Accelerator (Service Wizard) - Provide Service Details and Select Data Class

  • This stride is used to define the master input and output properties. Click on the 2 check boxes labeled Select FIELD NAME in the Primary Folio Input Properties and Primary Page Output Properties sections.
  • The belongings pyLabel is not listed hither since it is inherited. This omission volition NOT be a trouble subsequently. Click on Side by side to go on.

Pega 7 Service Accelerator (Service Wizard) - Customize Service Data

  • Specify a ruleset and ruleset version for the motorcar-generated service rules. In this case, the ruleset proper noun is Insurance and the ruleset version is 01-01-01.
  • Use the default options Configure a new service package and Configure a new service listener and click on Next to go along.

Pega 7 Service Accelerator (Service Wizard) - Select Service Resources

  • The next screen is used to configure the new service listener. The listener needs to be configured to monitor a specified file system directory for CSV input files. In this case, the directory on the Pega (vii.ane.6) instance, where input files will exist located is:
          /usr/share/tomcat7/webapps/prweb/data        
  • This folder may exist dissimilar for Pega versions other than seven.1.6.
  • The Source Name Mask is *.csv and specifies that only csv files will exist picked up past the File Listener for processing.

Pega 7 Service Accelerator (Service Wizard) - Configure Data Records

  • Review the configuration of the Service and File Listener rules. Individual sections tin be expanded by clicking on the plus (+) signs next to the labels.
  • In this case, the service blazon is Rule-Service-File (see Rule-Service-File at Pega Help).
  • The service package is AdjusterDataService and the final activity that will exist called from the service implementation is called InsertAdjusters (…to insert a record into the data table).

Pega 7 Service Accelerator (Service Wizard) - Review and Save

  • Scroll down in the dialog to view details of the Concluding Action as shown below.
  • Note that the Access Grouping specifies what privileges the generated Services will have.
  • The processing mode is specified as stateless, which means that each transaction (i.e. each record read from the file and inserted into the DB table) is isolated and not related to whatever previous one.

Pega 7 Service Accelerator (Service Wizard) - Review and Save (continued 2)

  • Since the option Configure a new service listener was selected earlier, the Service Accelerator will also generate a service listener rule. See screen shot beneath for details.
  • The File Listener will monitor a specified binder on the Pega host'southward file system:
          /usr/share/tomcat7/webapps/prweb/data        
  • …and automatically read files that friction match the specified blueprint, here: *.csv.
  • In this instance, the listener is named AdjusterDataListener.
  • The boolean Disable Startup? parameter specifies whether the listener will be started automatically when PRPC is started or whether it has to be started manually through the System Direction Application (SMA).

Pega 7 Service Accelerator (Service Wizard) - Review and Save (continued 3)

  • After reviewing the configuration, click on the Finish push to complete the configuration procedure and to run the Service Accelerator. At this point, the Service and all associated rules will be generated.

Pega 7 Service Accelerator (Service Wizard) - The service configuration process is now complete

  • A final confirmation screen, indicating the successful execution of the Service Accelerator, will exist shown. Note that Pega 7.1.6 was used for this example and it seems to yet use the Pega six UI theme for this confirmation screen.

Open the Service rule by entering its name in the search field in the Designer Studio. In this instance, the name InsertAdjusters was used during configuration.

  • The Chief PAGE section shows the page class and the page name.
  • The PROCESSING OPTIONS section shows the execution fashion. It is prepare to Execute synchronously, meaning that the service processes one file at a time.
  • The other execution modes allow asynchronous processing of input files (east.chiliad.: placing files into a queue for groundwork processing).

Pega 7 Edit Service File - Service Tab - Set Execution Mode Execute Synchronously

  • This tab used to configure how PRPC detects and processes records in the input file.
  • Processing Method: is set to tape at a time, which specifies that each row in an input file is parsed and so inserted into the data table immediately.
  • Record Terminator: a row in the CSV file is delimited past a railroad vehicle return and new line grapheme, so \r\due north is used hither.
  • Character Encoding: UTF-viii is selected here since this is the graphic symbol encoding of the input text file. During processing, PRPC converts the input characters from the specified encoding to Java String encoding (16-bit Unicode).

Pega 7 Edit Service File - Method Tab - Set Processing Method, Record Terminator and Encoding

  • This tab is used to specify the Parse Segments. Past default, the properties of the page grade are listed hither and aFinal Activity is listed.
  • The concluding activeness will be called each time a tape from the input file has been parsed.
  • In this case, information technology volition be used to insert the record into a information table.

Pega 7 Edit Service File - Request Tab - Parse Segments and Final Activity

  • Of import: In this example, a Delimited ParseRule, instead of the default parse segment settings, will be used for parsing.
  • Manually remove the parse segments: Click on one of the text fields in a parse segment and and then click on the X icon that appears to the far right of the segment row.
  • Besides remove the entry in the Final Activeness field.

Pega 7 Edit Service File - Request Tab - Remove Parse Segments

  • In the Map To machine-complete field of the empty parse segment row, select Delimited ParseRule.
  • The Map To Key text field is used to specify the name of the delimited parse rule.
  • The naming convention of the delimited parse dominion is <namespace>.<file-extension>(case sensitive)
  • It will exist practical for each row in the input file. The namespace has to friction match the terminal role of the page form, east.thou.: ABC-Insurance-Information-Adjuster .
  • The file extension volition be CSV and in this case, the Map To Key value will be Adjuster.CSV.
  • In the Activity text field, identify the activity that will be called later on the current row is parsed and the information is available on the clipboard.
  • Here, the activity InsertAdjusters, which was created past the service accelerator, is chosen.
  • Click on the Save button to salve the current settings.

Pega 7 Edit Service File - Request Tab - Map to Delimited ParseRule

  • The next step requires the configuration of the Delimited ParseRule.
  • Click on the magnifying drinking glass icon next to the text field in the Map To Fundamental column. This volition open a new dialog window to create the rule.

Pega 7 Edit Service File - Request Tab - Open Delimited ParseRule

  • The label, identifier and record type are pre-filled based on the Map To Primal value.
  • Click on Create and open to go on.

Pega 7 Designer Studio - Create Parse Delimited Rule

  • The screen shot below shows the configuration of the parse rule. SelectComma-Separated Values (CSV)for the Field Format.
  • In the Parsing Details section, create a row for each field in the input file. The guild of the parsing rows has to match the order of the fields in the input file.

Pega 7 Designer Studio - Edit Parse Delimited Rule - Set Field Format to Comma-Separated Values (CSV) and Map To Clipboard

  • Then, in the file below, the cavalcade ID will be mapped in the start row, the column Firstname will be mapped in the second row and so on.

Example CSV File to be Parsed

  • The description does not have to match the header values in the input file.
  • Select Clipboard in the Map To auto-complete field and then select the belongings in the page class rule to which the electric current field volition exist mapped.
  • Make sure the checkbox in the Required column is checked. Complete this activity for each field in the input file as shown below.
  • Annotation that the Lastname field from the input file is mapped to the inherited property pyLabel. This field can exist used instead of creating a separate property for the last proper noun.
  • Click on Save to salve the Parse Delimited rule and and so shut the dialog.

Pega 7 Designer Studio - Edit Parse Delimited Rule - Parsing Details

  • Information technology is also necessary to implement the insert activeness rule that was specified earlier on the Request tab of the Service rule.
  • Again, the activity is named InsertAdjusters. The Service > Request screen is shown below again. Click on the magnifying glass to open the activeness rule.
  • Note that this activity will be called for each row in the input file, i.e. it will read one row from the file and then insert one record into the data table.

Pega 7 Designer Studio - Edit Service File - Open Parse Segment Activity

  • Open the activity and navigate to the Pages & Classes tab. A page of the class for which instances volition be inserted into the data table needs to be alleged here.
  • In this case, instances of the classABC-Insurance-Information-Adjuster are inserted.

Pega 7 Designer Studio - Edit Activity - Insert Activity Pages and Classes

  • Next, navigate to Steps and use the Page-New method in the showtime step to create a new clipboard page of this class.
  • In the 2nd stride, select the Property-Fix method and enter the name of the page (Step Folio) that was created in row 1.
  • Under Method Parameters, link the properties of the step folio to the properties on the primary clipboard folio
  • E.g.: .ID refers to the property of the stride page and Primary refers to the clipboard page that will be populated by the parse delimited rule for each record in the input file.

Pega 7 Designer Studio - Edit Activity - Steps

  • In the third stride, the Obj-Salvage method is used to save the step page, hither the ABC-Insurance-Data-Adjuster, into the data table.
  • The parameter WriteNow will cause the system to immediately commit the insert functioning. Make sure to save the action rule.

The last part of the setup concerns the configuration of the File Listener rule that was created earlier, when the Service Accelerator was run. The File Listener will exist configured to automatically monitor a specified directory on the PRPC file system for input files, in this case files that match the design .CSV.

  • If a new file is found, the File Listener will automatically invoke the Service file rule to procedure the input CSV file.
  • The screen shot below shows the File Listener details from the before Service Accelerator execution.

Pega 7 Service Accelerator (Service Wizard) - Review and Save - New Service Listener

  • Open the File Listener past searching for the listener name, in this case, the Service Accelerator created a File Listener rule called AdjusterDataListener.
  • The properties tab shows the listener properties and is pre-filled based on the selections fabricated when the Service Accelerator was run.
  • Brand certain that the Source Location directory is set properly. This is the directory, the File Listener will monitor for input files.
  • In this example, PRPC is running as a Personal Virtual Server, utilizing the VMWare Player (Pega 7.1.vi CSA Exercise System from Pega Academy).
  • A FTP client can be used to load input files to the file system of the virtual server.
  • For an example on how to setup FTP access to a Pega 7.1.6 CSA Exercise System running on VMWare, see: Example of FTP Connection to Pega 7 PRPC for Private Virtual Server Installations.
  • Click on theExamination Connectivity push button to confirm that the listener is configured properly and that the file source location is accessible.

Pega 7 Designer Studio - Edit File Listener - Properties Tab - Set Source Location, Source Name Mask, Service Package, Service Class and Service Method

  • A confirmation dialog as shown beneath should announced and display the message Connectivity examination successful.

Pega 7 Designer Studio - Edit File Listener - Test Connectivity

  • If the connectivity test fails: For Private Virtual Server installations: Use the VMWare player to log into the virtual machine (architect, password or root, install) and create the input file directory and set appropriate access privileges using the commands:
          sudo mkdir /usr/share/tomcat7/webapps/prweb/data        
          sudo chmod 777 /usr/share/tomcat7/webapps/prweb/data        
  • In the beneath instance, the data directory is now accessible by possessor, group and everybody for reading and writing.

Pega 7 - File Listener - VMWare Ubuntu - Source Directory File Permissions

  • The File Listener will kickoff monitoring the source location as presently as it is started (…when running the Service Accelerator, at that place is an option to specify whether the listener will showtime automatically when PRPC is started. In this case this option was set up to faux.).
  • To start the File Listener, open the System Management Awarding (SMA) past navigating to Designer Studio > System > Tools > System Direction Application

Pega 7 Designer Studio - Opening the System Management Application

  • In the list of Nodes, click on a node proper name to load the configuration for that node. In this case, in that location is merely one node called localhost.
  • If the list of nodes is empty, the Pega node under which the Service and File Listener rules were created needs to be added.
  • This can exist done by clicking on the plus (+) icon in the upper left hand corner of the SMA window.
  • In lodge to start the File Listener, click on Listener Management in the navigation bill of fare that appears once a node is selected.
  • Then select the listener from the Bachelor Listeners driblet-down control and click on the Starting time button in the section above it.
  • In one case the listener is running, it will be listed in the Running Listeners department equally shown below.

Pega 7 System Management Application - Listener Management

  • Note: The File Listener tin can exist configured further: the Process tab allows to specify the polling interval, i.east. how often the listener volition check the source location for new input files.
  • The Generate written report file? cheque box can be checked to have the listener create an XML based study file (in the specified source location). The written report shows details regarding input file processing such every bit parsing errors.
  • The File Performance parameter in the CLEANUP section tin exist used to specify what the listener does with input files that have been candy. In the below screen shot Delete is selected so that the listener will remove the input files from the organisation.

Pega 7 Edit File Listener - Process Tab - Set polling interval, generate report file and cleanup activity

  • If changes are made while the listener is running, it is required to restart the listener in order for the changes to take effect.

At this signal, there are no input files in the directory the File Listener is monitoring. A FTP client such equally FileZilla or the command line can be used to re-create input files to the directory. In this case, PRPC is installed as a Personal Virtual Server, then the PRPC instance is running in a virtual car with its ain IP address, here 192.168.241.128.

  • By default, the virtual machine is running a FTP server and the default architect, password or root, install credentials can be used to connect to it via FTP.
  • The screen shot below shows the FileZilla configuration to connect via FTP to the virtual automobile.
  • For an example on how to setup FTP access to a Pega vii.1.6 CSA Practise System running on VMWare, run across: Example of FTP Connection to Pega 7 PRPC for Individual Virtual Server Installations.

FileZilla Site Manager - Configure FTP access to PRPC instance on virtual machine

  • Copy the input CSV file(s) to the source location that was specified earlier. Here information technology is:
          /usr/share/tomcat7/webapps/prweb/data        
  • The listener volition pick up the file(s) and invoke the Service to parse and process it.

FileZilla File Listener Source Folder - File Listener report

  • After processing has been completed, the same directory may incorporate XML files (in the example of processing errors). These files can exist used to debug parsing errors etc.
  • In the Organization Management Application, the Asking Count in theRunning Listeners department volition show how many files the listener has processed since it was started.

System Management Application - File Listener Request Count

  • Finally, when the Information Tables view is reloaded, the Row Count for the target data table will reflect the records that were inserted.

Pega 7 Designer Studio - Data Model - Data Tables - Updated row countshowing row count

  • Clicking on the gear icon to the right of the row count will open the data table and show the inserted records.

Pega 7 Designer Studio - View Data Table Instances

  • These match the four records from the CSV input file.
  • The data tabular array can be used to populate UI controls such equally auto-complete and drop down fields. For an example see: Creating an Machine-Complete Command Backed by a Information Table.

Example CSV file adjusters.csv

  • Note: If the listener was configured to generate a report file (see Process tab > Generate report file?), it will be available in the same input file directory in a subfolder called written report.
  • The report file will accept the proper noun of the input file with the file extension .rpt.
  • A sample report file is shown in the screen shot beneath. The written report contains data such every bit the number of rows that were inserted into the data tabular array, the verbal file size in byte and the listener proper name that processed the input file.

Pega 7 File Listener Report File in XML Format

  • Note: If needed, an activity tin also be created to purge existing data in the data table before new information from a CSV file is imported.
  • This cleanup activeness can be called using the Initial Activity field in the PROCESSING PROLOG section of the Service rule equally shown below.

Pega 7 Designer Studio - Edit Service File - Request Tab - Processing Prolog Initial Activity


madrigaluponeet.blogspot.com

Source: https://www.pegaxchange.com/2016/01/18/read-csv-file-pega-7/

0 Response to "Upload File Using Parse to Pega 7"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel