MDO Enterprise Data Platform / Technical Development / API Framework / Standards to Develop an API in MDO

Standards to Develop an API in MDO

API STANDARDS

1.Custom Utility Interface List 

In order to fetch the data from the database, the custom utility interface library should be imported. Import the library at the top. Also, an object of Custom Utility type needs to be created before writing a query. 

Custom Utility Interfaces List: 

String getUniqueObjectNumber(String prefixint length); 
boolean createObject(String objectType, String userName, String clientId, StringlangHashMap fieldValuesboolean workflowRequired,String plantCode); 
boolean createObjectWithGridData(String objectType, String userNameStringclientId, String langHashMap fieldValues, HashMap<String, Object> gridDatabooleanworkflowRequired); 
boolean createObject(String objectNumber, String objectType, String userName,String clientId,String langHashMap fieldValuesboolean workflowRequired); 
String createObjectAndRtnObjNo(String objectType, String userName, String clientId,String langHashMap fieldValuesboolean workflowRequired); 
String createObjectAndRtnObjNo(String objectType, String userName, String clientId,String langHashMap fieldValuesboolean workflowRequiredbooleanexecuteAfterDataSave); 
String createObjectAndRtnObjNo(String objectType, String userName, String clientId, String langHashMap fieldValuesboolean workflowRequired, String plantCode); 
String changeObject(String objectNumber, String objectType, String userName, StringclientId,String langHashMap fieldValuesboolean workflowRequired); 
String changeObject(String objectNumber, String objectType, String userNameStringclientId, String langHashMap fieldValuesboolean workflowRequired, String plantCode); 
String changeObjectWithChangeLog(String objectNumber, String objectType, StringuserName,String clientId,String langHashMap fieldValuesboolean workflowRequired); 
String changeObjectWithGridData(String objectNumber, String objectTypeStringuserName, String clientId, String langHashMap fieldValues, HashMap<String, Object>gridDataboolean workflowRequired); 
void integrate(String objectType, String objectNumber, String clientIdStringevent, String plantCode); 
executeQuery(String selectQuery, Collection<String> columnsintfetchSizeint fetchCount); 
Collection<Map>executeQuery(String selectQuery,Collection<String> columns); 
Collection<MapexecuteQuery(String selectQuery, Object[] args); 
int executeUpdate(String query); 
JSONArray executeQuery(String selectQuery, LinkedList<String> columns); 
int executeUpdate(String query); 
int executeUpdate(String query, Object[] args); 
boolean executeStoreProcedureBak(String name, Map<String, String> params); 
boolean executeStoreProcedure(String name, Map<String, String> params); 
String crateMaterialUsingRfc(String rfcNameHashMap fieldValueHash); 
HashMap<String,String>crateMaterialUsingRfc_retunsWithStatus(String rfcName,HashMap fieldValueHash); 
void haltWorkflow(String workflowPath, String stepId, String objectNumberStringobjectType, String taskId); 
void resumeWorkflow(String taskId, String stepId, String objectType, StringobjectNumber); 
void map(String mdoNumber, String externalNumber, String systemStringobjectType); 
HashMap executeRFC(String rfcName, HashMap<String, String> importParameters, HashMap<String, Collection<HashMap<String, String>>> importTablesArrayList<String>outputParams, HashMap<String, ArrayList<String>> outputTables, HashMap<String, ArrayList<String>> outputStructures); 
HashMap executeRFC(String rfcName, HashMap<String, String> importParameters, HashMap<String, HashMap<String, String>> importStructures, HashMap<String, Collection<HashMap<String, String>>> importTablesArrayList<String> outputParams, HashMap<String, ArrayList<String>> outputTables, HashMap<String, ArrayList<String>>outputStructures, String transactionCommitBapiName); 
HashMap<String,StringgetReferenceFieldMappingByObjectIdFieldName(LinkedList<String> fieldsStringrefObjectIdthrows Exception; 
HashMap<String, String> mapHashtoRefHash(HashMap<String, String> perentHash, HashMap<String, String> refrenceHash); 
String sendMail(boolean mailForTyp, String from, String subject, String message, Object[] recipientsboolean tlsEnabled); 
String sendAsyncMail(boolean mailForTyp, String from, String subjectStringmessage, Object[] recipientsboolean tlsEnabled); 
String sendAsyncMail(boolean mailForTyp, String from, String subjectStringmessage, Object[] recipientsboolean tlsEnabled,String plantCode); 
void maintainLogForWOrkflow(String taskId, String type, String messageStringstepIdlong timeInMilisecond); 
HashMap<String,StringcallMessageRFC(String rfcName, String retunsTypeStringretunsParameterNameHashMap fieldValueHash); 
String addZeros(String str, String msgtype); 
String getMdoNumber(String objectType, String criteriafieldStringcriteriaFieldValue, String plantCode); 
String generateMaterialNumber(String criteriaField, String criteriaValueStringobjectId, String preFix, String startIndex, String endIndex, String length); 
HashMap<String,ObjectreadNounXML(String xml); 
Boolean insertIntoGrids(String objectType, String fieldId, String msgFnStringobjectNumber, String userName, String clientIdHashMap fieldValues); 
void maintainIntegrationLog(String objectNumber, String objectType, String eventId, String status); 
boolean checkRoleProcessEvent(String objectType, String event_idStringprocess_event, String role); 
String getEventIdForFatalError(String objectNumber, String objectType); 
String getTaskIdForLastError(String objectNumber, String objectType); 
String removeIntegrationLog(String objectNumber, String objectType); 
void registerCustomerSendMail(String fName, String lName, String emailIdStringobjectNumber, String objectId, String userId, String clientId, String langBooleanisSSfUser, Boolean shootMail, Collection<String> ssfObjId); 
void sendSms(String msg, String userIdthrows IOException; 
boolean createNotification(String senderUID, String receiverUIDStringsenderEmailId, String receiverEmailId, String headerText, String contentText); 
boolean createNotificationAsync(String senderUID, String receiverUIDStringsenderEmailId, String receiverEmailId, String headerText, String contentTextStringmailBody); 
boolean createNotificationWithObjectId(String senderUID, String receiverUIDStringsenderEmailId, String receiverEmailId, String headerText, String contentTextStringobjectId, String objectTypeboolean acknowledgement); 
void configurableSendMails(boolean isConfigurableboolean mailForTyp, String from, String subject, String message, String signature, HashMap<String, String> toCCBccArrayList<String> attachmentsboolean secureChannel, HashMap<String, String>channelProperties, String clientId); 
void sendAsynCustomMail(boolean isConfigurableboolean mailForTyp, String from, String subject, String message, String signature, HashMap<String, String> toCCBccArrayList<String> attachmentsboolean secureChannel, HashMap<String, String>channelProperties, String clientId); 
void sendAsynCustomMail(boolean isConfigurableboolean mailForTyp, String from, String subject, String message, String signature, HashMap<String, String> toCCBccArrayList<String> attachmentsboolean secureChannel, HashMap<String, String>channelProperties, String clientId,String plantCode); 
Long saveDefaultUrlFromMap(String ecId, Long urlId, HashMap<String, String>defaultMap); 
List<OCIURLModelgetURLForEcId(String ecId); 
String encodeURl(String orignalString); 
String decodeURl(String decodedString); 
void createSelfServiceUser(String userId, String sSUser, String userTypeStringobjectId, String eCIdthrows Exception; 
Collection<MapexecuteQueryObject(String selectQuery, Collection<String> columns); 
void updateObjectNumber(String MDOnmbr, String SAPnmbr, String clientidStringObjectid); 
String objectInWorkFlow(String objectnumber, String objType, String clientId, String userId, String roleId, String plantCode, String eventId, String objedStringlang); 
String getPath(); 
Double getConvertedAmount(String sourceCurrency, String destinationCurrencyDoublesourceValuelong fromDate); 
boolean createNotificationWithObjectId(String senderUID,String receiverUIDStringsenderEmailId, String receiverEmailId,String headerText, String contentTextStringobjectId,String objectTypeboolean acknowledgementboolean sendSms); 
boolean createNotification(String senderUID, String receiverUID,StringsenderEmailId, String receiverEmailId, String headerText,String contentTextbooleansendSms); 
boolean createNotification(String senderUID, String receiverUID,StringsenderEmailId, String receiverEmailId, String headerText,String contentTextStringmailBodyboolean sendSms); 
DataObject fetchDataObject(String objectNumber, String objectType); 
boolean deleteAllData(String objectNumber,String objectType, String userId); 
boolean validateFinancialYearDate(String dateValue,String plantCode); 
String generateMaterialNumber(String criteriaField, String criteriaValueStringobjectId, String preFix, String startIndex, String endIndex, String lengthStringplantCode); 
void configurableSendMailswithAttachment(boolean isConfigurable,boolean mailForTyp, String from, String subject, String message,String signature, HashMap<String,String>toCCBcc,ArrayList<String> attachments,HashMap<String, byte[]> attachmentbooleansecureChannel, HashMap<String, String> channelProperties, String clientId); 
boolean createNotification(String senderUID, String receiverUIDStringsenderEmailId, String receiverEmailId, String headerText, String contentTextStringmailId, String downloadLink); 
Map<String, Long> uploadBulkFiles(Map<String, byte[]> fileData, Map<String, String>fileTypes, Map<String, String> fileDescription); 
Collection<Map>executeQueryByConnString(String DriverClass,String connString, String user,String pwd,String selectQuery, Collection<String> columns); 
int JDBCexecuteUpdate(String DriverClass,String connString, String user,Stringpwd,String query); 
JSONObject validateData(String objectNumber,String objectTypeStringuserName,String role,String templateCode,String plantCode,String lang,String eventId,HashMap fieldValues,Map<String, JSONArraygridData); 
public JSONObject createRecord(String objectType, String userName,String roleId , String eventId, String langHashMap fieldValuesJSONObject gridData,String plantCode,boolean workflowRequired,boolean isDraft,String objectNumber,boolean validation); 
public JSONObject createRecord(String objectType, String userName,String roleId , String eventId, String langHashMap fieldValuesJSONObject gridData,String plantCode,boolean workflowRequired,boolean isDraft,String objectNumber,booleanvalidation,JSONObject hierarchyData); 
public PdfGenerateUtility getPdfGenerateUtility(); 
public IntegrationUtility getIntegrationUtility(); 
public ReportAPIUtility getReportAPIUtility(); 
public Map<Long,List<String>> validateDataWithScehma(String objectTypeStringuserName,String role,String templateCode ,String plantCode,String lang,String eventId,HashMap fieldValues,Map<String, JSONArraygridData,Long schemaId); 
public JSONObject applySchema(String objectType, String userName,String role,StringtemplateCode ,String plantCode,String lang,String eventId,Long schemaId); 
public JSONObject createRecord(String objectType, String userName,String roleId , String eventId, String langHashMap fieldValuesJSONObject gridData,String plantCode,boolean workflowRequired,boolean isDraft,String objectNumber,booleanvalidation,JSONObject hierarchyData,boolean integrate,String processingId); 

} 

2. Use Logger Logs rather thanSysoutSystem.out.println() and similar statements are not accepted. Logger logs help in keeping the logs of the APIs. Import logger and logger factory library at the top and make its object. 

3. Everychange willchange the class name: Whenever any modification in API is done and saved, then class will change.  

4. Parameters:Parameters that come under function are Object Number, Object Type and Values. Object Number is the record number created in MDO.The object type is the module id and values can have group of User Id, Role Id and all the values which are entered in the form. The format is given below: 

public HashMap execute (String objectNumber, String objectType, HashMap values) 

5. Modularized code:For better management make modularized code by using more functions. 

6. Do not change the method signature:Do not make changes in the signature of execute method. If changes are needed, create new. 

 

Standard Java API code generated by the system: 

import java.util.ArrayList; 

import java.util.Collection; 

import java.util.HashMap; 

import org.slf4j.Logger; 

import org.slf4j.LoggerFactory; 

import com.prospecta.mdo2.statics.staticliterals.StringLiterals; 

import com.prospecta.mdo2.utility.utilityClasses.AMdoApiMap; 

/** 

* API Template. Modify this to include description and purpose of the API. 

*/ 

public class DYN7231384 extends AMdoApiMap { 

  /** 

* Usage LOGGER_API.info(“message”); 

* Usage LOGGER_API.warn(“message”); 

* Usage LOGGER_API.error(“message”); 

 

* Info will be logged into ExternalAPI.log file according to log level. 

* Warning and Errors will be logged into ExternalAPI.log file and API_LOGS table in database according to log level. 

* System (.) out (.) println() and similar sop statements are not accepted. 

*/ 

  private static final Logger LOGGER_API = LoggerFactory.getLogger(DYN7231384.class); 

  public DYN7231384() { 

  } 

  /* Dont change method signature */ 

 @SuppressWarnings({ “unchecked”, “rawtypes“, “unused” }) 

  public HashMap execute(String objectNumber, String objectType, HashMap values) { 

   HashMap result = new HashMap(); 

   String userId = (String) values.get(“USER_ID”); 

    /* 

* Write your own code.  

* For better management make modularized code by using more functions. 

*/ 

    return result; 

  } 

 

Javascript API Example: 

function Validation840747943123293672() { 

  var startDate = document.getElementById(“PROJECT_START_DATE”).value; 

  var endDate=document.getElementById(“PROJECT_END_DATE”).value; 

  console.log(“end date “+endDate); 

  console.log(” Start date”+startDate); 

  if(startDate !== ” && startDate !== null) 

  { 

    startDate = startDate.split(“.”)[1]+’/’+startDate.split(“.”)[0]+’/’+startDate.split(“.”)[2]; 

    startDate = new Date(startDate); 

    endDate = endDate.split(“.”)[1]+’/’+endDate.split(“.”)[0]+’/’+endDate.split(“.”)[2]; 

    endDate = new Date(endDate); 

    if(startDate>endDate){ 

      Mdo.MessageBox.alert(‘Error’,’StartDate must be less than EndDate‘); 

      return false; 

    } 

  } 

  return true; 

}