Search in sources :

Example 1 with DescribeGlobalSObjectResult

use of com.salesforce.soap.partner.DescribeGlobalSObjectResult in project tdi-studio-se by Talend.

the class SObjectsToSchema method generateSchema.

void generateSchema(String inputFileName, String outputFileName) throws IOException {
    File inputFile = new File(inputFileName);
    File outputFile = new File(outputFileName);
    StringBuffer inputContent = new StringBuffer();
    // StringBuffer deleteContent = new StringBuffer();
    StringBuffer insertContent = new StringBuffer();
    StringBuffer updateContent = new StringBuffer();
    StringBuffer upsertContent = new StringBuffer();
    DescribeGlobalResult describeGlobalResult = null;
    describeGlobalResult = binding.describeGlobal();
    DescribeGlobalSObjectResult[] sobjectResults = describeGlobalResult.getSobjects();
    for (int i = 0; i < sobjectResults.length; i++) {
        String moduleName = sobjectResults[i].getName();
        DescribeSObjectResult descSObjectRslt;
        descSObjectRslt = binding.describeSObject(moduleName);
        if (descSObjectRslt != null) {
            // Report object level information
            if (!descSObjectRslt.isCustom()) {
                // if (descSObjectRslt.isQueryable()) {
                //mark
                inputContent.append(generateInputTable(moduleName, descSObjectRslt));
                // }
                // if (descSObjectRslt.isCreateable()) {
                insertContent.append(generateOutputTable(moduleName, descSObjectRslt, INSERT));
                // }
                // if (descSObjectRslt.isUpdateable()) {
                updateContent.append(generateOutputTable(moduleName, descSObjectRslt, UPDATE));
                // }
                // if(descSObjectRslt.isUpdateable()&&descSObjectRslt.isCreateable()){
                upsertContent.append(generateOutputTable(moduleName, descSObjectRslt, UPSERT));
            // }
            // if (descSObjectRslt.isDeletable()) {
            //
            // }
            }
        }
    }
    BufferedWriter inOutput = new BufferedWriter(new FileWriter(inputFile));
    inOutput.write(inputContent.toString());
    inOutput.close();
    String sepLint = "<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->";
    BufferedWriter OuOutput = new BufferedWriter(new FileWriter(outputFile));
    OuOutput.write(insertContent.toString() + "\r\n" + sepLint + "\r\n" + updateContent.toString() + "\r\n" + sepLint + "\r\n" + upsertContent.toString());
    OuOutput.close();
}
Also used : DescribeGlobalResult(com.salesforce.soap.partner.DescribeGlobalResult) DescribeGlobalSObjectResult(com.salesforce.soap.partner.DescribeGlobalSObjectResult) DescribeSObjectResult(com.salesforce.soap.partner.DescribeSObjectResult) FileWriter(java.io.FileWriter) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Example 2 with DescribeGlobalSObjectResult

use of com.salesforce.soap.partner.DescribeGlobalSObjectResult in project tdi-studio-se by Talend.

the class SObjectsToSchema method generateModuleName.

private void generateModuleName(String fileName) throws IOException {
    File f = new File(fileName);
    StringBuffer content = new StringBuffer();
    DescribeGlobalResult describeGlobalResult = null;
    describeGlobalResult = binding.describeGlobal();
    DescribeGlobalSObjectResult[] sobjectResults = describeGlobalResult.getSobjects();
    for (int i = 0; i < sobjectResults.length; i++) {
        if (!sobjectResults[i].isCustom()) {
            String moduleName = sobjectResults[i].getName();
            // System.out.println(sobjectResults[i].getName());
            content.append("<ITEM NAME=\"");
            content.append(moduleName);
            content.append("\" VALUE=\"");
            content.append(moduleName);
            content.append("\" />");
            content.append("\r\n");
        }
    }
    BufferedWriter output = new BufferedWriter(new FileWriter(f));
    output.write(content.toString());
    output.close();
}
Also used : DescribeGlobalResult(com.salesforce.soap.partner.DescribeGlobalResult) DescribeGlobalSObjectResult(com.salesforce.soap.partner.DescribeGlobalSObjectResult) FileWriter(java.io.FileWriter) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Aggregations

DescribeGlobalResult (com.salesforce.soap.partner.DescribeGlobalResult)2 DescribeGlobalSObjectResult (com.salesforce.soap.partner.DescribeGlobalSObjectResult)2 BufferedWriter (java.io.BufferedWriter)2 File (java.io.File)2 FileWriter (java.io.FileWriter)2 DescribeSObjectResult (com.salesforce.soap.partner.DescribeSObjectResult)1