ALDSP Control Static Mediator API Code Reference This page last changed on Jun 23, 2008. .stickable, h1, h2, h3, h4, h5 false true Show Sticky notes Hide Sticky notes sticky_configuringtheldapserverinformation sticky_associatingcustomconditionallogicwithfunctions sticky_aldspapplicationdevelopmentbestpractices sticky_configuringthesampleapplicationtousetheembeddedldapserver sticky_acloserlook Save Cancel edocs Home > BEA AquaLogic Data Services Platform 3.0/3.2 Documentation > ALDSP 3.2 New Features Documentation ## ALDSP Control Static Mediator API Code Reference This topic describes the advanced sample project that uses the Static Mediator API to call data service operations from ALDSP Controls using a variety of argument and return types.
| Source: `DSPClientSamplesControlStatic/Java Resources/src/dspControl/DspControlController.java`
#### Topic Map ALDSP Control Static Mediator API Code Reference Using a Complex Argument Using a Complex Argument List Using a Complex Argument with Create-Read-Update-Delete Operations Returning a Simple Element Including Auditing Related Topics Advanced API Samples - Mediator, Web Services, and DSP Controls ### Using a Complex Argument You can call ALDSP data service operations using a complex argument type. The example in this section creates a `profileService` object and populates the object with customer information using type-safe setter methods. The sample then calls the `getServiceCase` method using the complex argument, which retrieves the CASE information through the identically-named ALDSP operation. ##### Calling an Operation Using a Complex Argument
    retailer.PROFILE_SERVICE profileService = (retailer.PROFILE_SERVICE)factory.create(retailer.PROFILE_SERVICE.class );

    com.bea.dsp.sdo.SDOUtil.setElementName(profileService, "urn:retailer", "PROFILE");
    retailertype.PROFILE_TYPE profile = profileService.createPROFILE();
    profile.setCustomerID("CUSTOMER4");
    profile.setFirstName("dummyFirstName");
    profile.setLastName("dummyLastName");
    profile.setCustomerSince( "2001-01-01");
    profile.setEmailAddress( "dummyEmailAddress");
    profile.setTelephoneNumber("8885551212");

    retailer.CASE_SERVICE[] cases=DSPControlFile.getServiceCase(profileService);
### Using a Complex Argument List You can call ALDSP data service operations using an argument consisting of a list of complex types. The example in this section creates two `profileService` objects and populates the objects with customer information using type-safe setter methods. The sample then calls the `getServiceCase` method using the argument consisting of the list of complex objects, retrieving the CASE information through the identically-named ALDSP operation. ##### Calling an Operation Using a List of Complex Arguments
    retailer.PROFILE_SERVICES profileService =(retailer.PROFILE_SERVICES)factory.create("urn:retailer", "PROFILE_SERVICES");

    com.bea.dsp.sdo.SDOUtil.setElementName(profileService, "urn:retailer", "PROFILES");
    retailertype.PROFILE_TYPE profile = profileService.createPROFILE();
    profile.setCustomerID("CUSTOMER4");
    profile.setFirstName("dummyFirstName");
    profile.setLastName("dummyLastName");
    profile.setCustomerSince( "2001-01-01");
    profile.setEmailAddress( "dummyEmailAddress");
    profile.setTelephoneNumber("8885551212");

    profile = profileService.createPROFILE();
    profile.setCustomerID("CUSTOMER6");
    profile.setFirstName("dummyFirstName");
    profile.setLastName("dummyLastName");
    profile.setCustomerSince( "2001-01-01");
    profile.setEmailAddress( "dummyEmailAddress");
    profile.setTelephoneNumber("8885551212");

    retailer.CASE_SERVICE[] cases = DSPControlFile.getServiceCases(profileService);
### Using a Complex Argument with Create-Read-Update-Delete Operations You can call multiple ALDSP data service operations, each with a complex argument type, to perform a series of tasks including calling create, read, update, and delete operations in the data service. The example in this section creates two `profileService` objects and populates the objects with "dummy" customer information using type-safe setter methods. The sample then calls the `getCustomerByCustID` method using a complex argument and checks whether the customer information is already stored. If not, the sample calls the `createPROFILE` method to create the customer profile. If a record already exists for the customer, the sample calls the `updatePROFILE` method to store the new information in the `profileService` object. If an existing record does not match, the sample calls the `deletePROFILE` method to remove the customer profile. ##### Calling Multiple Operations Using Complex Argument
    retailer.PROFILE_SERVICE[] profileServices = new retailer.PROFILE_SERVICE[2];

    retailer.PROFILE_SERVICE profileService1 =(retailer.PROFILE_SERVICE)factory.create("urn:retailer", "PROFILE_SERVICE");

    com.bea.dsp.sdo.SDOUtil.setElementName(profileService1, "urn:retailer", "PROFILE");

    profileServices[0]=profileService1;

    retailertype.PROFILE_TYPE profile1 = profileService1.createPROFILE();
    profile1.setCustomerID("CUSTOMER44");
    profile1.setFirstName("dummyFirstName");
    profile1.setLastName("dummyLastName44");
    profile1.setCustomerSince( "2001-01-01");
    profile1.setEmailAddress( "dummyEmailAddress");
    profile1.setTelephoneNumber("8885551212");

    retailer.PROFILE_SERVICE profileService2 =(retailer.PROFILE_SERVICE)factory.create("urn:retailer", "PROFILE_SERVICE");
    com.bea.dsp.sdo.SDOUtil.setElementName(profileService2, "urn:retailer", "PROFILE");

    profileServices[1]=profileService2;
    retailertype.PROFILE_TYPE profile2 = profileService2.createPROFILE();
    profile2.setCustomerID("CUSTOMER55");
    profile2.setFirstName("dummyFirstName");
    profile2.setLastName("dummyLastName55");
    profile2.setCustomerSince( "2001-01-01");
    profile2.setEmailAddress( "dummyEmailAddress");
    profile2.setTelephoneNumber("8885551212");

    retailer.PROFILE_SERVICE[] returnedProfileServices=DSPControlFile.getCustomerByCustID("CUSTOMER44");

    outputString="";
    if(returnedProfileServices.length==0) {
       outputString=outputString +"ADDING: \n";
       DSPControlFile.createPROFILE(profileServices);
       outputString=outputString + dataObjectsToString(profileServices);
    } else {
       retailer.PROFILE_SERVICE dObj= returnedProfileServices[0];
       if("dummyLastName44".equals(dObj.get("PROFILE/LastName"))) {
          outputString=outputString +"UPDATING: \n";
          outputString=outputString + dataObjectsToString(profileServices);
          com.bea.dsp.sdo.SDOUtil.enableChanges(dObj);
          dObj.set("PROFILE/LastName", "Smith");
          DSPControlFile.updatePROFILE(new retailer.PROFILE_SERVICE[]{dObj});
       } else {
          outputString=outputString +"DELETING: \n";
          outputString=outputString + dataObjectsToString(returnedProfileServices);

          DSPControlFile.deletePROFILE(new retailer.PROFILE_SERVICE[]{dObj});
          returnedProfileServices=DSPControlFile.getCustomerByCustID("CUSTOMER55");

          if(returnedProfileServices.length>0) {
             dObj = returnedProfileServices[0];
             outputString=outputString + dataObjectsToString(returnedProfileServices);
             DSPControlFile.deletePROFILE(new retailer.PROFILE_SERVICE[]{dObj});
          }
       }
    }
### Returning a Simple Element You can call ALDSP data service operations that return simple types. The example in this section determines the number of orders by calling the `getOrderCount` and `getOrderCounts` methods and assigning the results to variables of type `java.math.BigInteger`. ##### Calling an Operation that Returns a Simple Type
    java.math.BigInteger count = DSPControlFile.getOrderCount("CUSTOMER4");
    outputString=outputString + dataObjectsToString(new Object[]{count});
    java.math.BigInteger[] counts = DSPControlFile.getOrderCounts("CUSTOMER4");
    outputString=outputString + dataObjectsToString(counts);
### Including Auditing You can audit calls to ALDSP data service operations and later retrieve the audit information for further processing. The example in this section creates a `RequestConfig` object and enables the data service audit feature (RETURN_DATA_SERVICE_AUDIT). After enabling audit, the example includes the instance of the `RequestConfig` object as an argument when calling methods corresponding to data service operations. The example then retrieves the audit records and iterates through the results to output for display. ##### Auditing Operations
    com.bea.dsp.RequestConfig reqConfig = new com.bea.dsp.RequestConfig();
    reqConfig.enableFeature(com.bea.dsp.RequestConfig.RETURN_DATA_SERVICE_AUDIT);
    reqConfig.setStringArrayAttribute(com.bea.dsp.RequestConfig.RETURN_AUDIT_PROPERTIES, attributes);

    retailer.PROFILE_SERVICE profileService[] = DSPControlFile.getCustomerByLoginID("Steve", reqConfig);
    outputString=dataObjectsToString(profileService);

    com.bea.ld.DataServiceAudit dsAudit = reqConfig.retrieveDataServiceAudit();
    if (dsAudit != null) {
       List l = dsAudit.getAllRecords();
       for (Iterator it = l.iterator(); it.hasNext();) {
          com.bea.ld.DSPAuditRecord auditRec = (com.bea.ld.DSPAuditRecord) it.next();
          Map propMap = auditRec.getAuditProperties();
          for (Iterator pit = propMap.keySet().iterator(); pit.hasNext();) {
             String key = (String) pit.next();
             outputString=outputString + "Audit Information: " + key + " = " + propMap.get(key)+"\n";
          }
       }
    }
## Related Topics ##### Concepts Advanced API Samples - Mediator, Web Services, and DSP Controls Understanding the Advanced Static Mediator API Sample ##### How Tos Setting Up the Advanced API Sample Projects Running the Mediator API Sample Projects ##### Reference Static Mediator API Code Reference Dynamic Mediator API Code Reference ALDSP Control Dynamic Mediator API Code Reference

Document generated by Confluence on Nov 26, 2008 13:06