Package com.sforce.soap.partner.wsc

Examples of com.sforce.soap.partner.wsc.DescribeSObjectResult


    }

    @Override
    public void loadAdditionalComponentAttributes() throws FactoryException, JAXBException {
        com.salesforce.ide.api.metadata.types.ReportType reportType = null;
        DescribeSObjectResult primaryObject = null;
        DescribeObjectRegistry describeObjectRegistry = null;

        try {
            reportType = (com.salesforce.ide.api.metadata.types.ReportType) component.getDefaultMetadataExtInstance();
            describeObjectRegistry = getComponentFactory().getConnectionFactory().getDescribeObjectRegistry();
            // BaseObject here is plural form save from user inpurt in Ui
            primaryObject =
                    describeObjectRegistry.getCachedDescribeByPluralLabel(getProject(), reportType.getBaseObject());
        } catch (InstantiationException e) {
            logger.warn("Unable to instantiate default metadataExt instance for Report Type", e);
        } catch (IllegalAccessException e) {
            logger.warn("Unable to instantiate default metadataExt instance for Report Type", e);
        } catch (Exception e) {
            logger.warn("Unable to get describeObject for " + reportType.getBaseObject(), e);
        }

        if (Utils.isEmpty(primaryObject)) {
            logger.error("Unable to load additional component attributes for Report Type '" + reportType.getLabel()
                    + "' due to unable to locate primary object '" + reportType.getBaseObject()
                    + "' from DescribeObjectRegistry");
            return;
        }
        // load all fields & sections from primary object
        ReportLayoutSection section = new ReportLayoutSection();
        section.setMasterLabel(primaryObject.getLabelPlural()); // Master label is plural label of describeObject

        // exclude fields that describeSObject returned as extra: default + sobject specific set.
        List<String> excludeFieldList = new ArrayList<String>();
        List<String> defaultExcludeFieldList =
                describeObjectRegistry.getExcludedCrtFields().get(DEFAULT_EXCLUDED_FIELD_KEY);
        excludeFieldList.addAll(defaultExcludeFieldList);
        List<String> sObjectSpecificExcludedList =
                describeObjectRegistry.getExcludedCrtFields().get(primaryObject.getName());
        if (Utils.isNotEmpty(sObjectSpecificExcludedList)) {
            excludeFieldList.addAll(sObjectSpecificExcludedList);
        }

        String tableName = primaryObject.getName(); // Table label is name of describeSObject
        Field[] fields = primaryObject.getFields();
        for (Field field : fields) {
            if (excludeFieldList.contains(field.getName()))
                continue;

            // skip Person Account related fields
            if (tableName.equalsIgnoreCase("Account")
                    && (field.getName().contains("Person") || field.getName().endsWith("__pc")))
                continue;

            String fieldName = field.getName();
            // use relationshipName instead when soapType is Id
            if (field.getType() == com.sforce.soap.partner.wsc.FieldType.reference
                    && !field.getName().equalsIgnoreCase("Id")) {
                // if relationshipName is null then use fieldName but remove trailing "Id"
                fieldName =
                        Utils.isNotEmpty(field.getRelationshipName()) ? field.getRelationshipName() : fieldName
                                .substring(0, fieldName.length() - 2);
            }
            ReportTypeColumn column = new ReportTypeColumn();
            column.setCheckedByDefault(false);
            column.setField(fieldName);
            column.setTable(tableName);
            section.getColumns().add(column);
        }
        reportType.getSections().clear(); // spring bean, reportTypeMetadata is singleton; therefore, content from
        // previous session won't be clean-up.
        reportType.getSections().add(section);
        reportType.setBaseObject(primaryObject.getName()); // replace Ui input string which is in plural label form
        // with name of describeSObject.

        // unmarshall component and init componet body
        saveMetadata(component);
        if (logger.isDebugEnabled()) {
View Full Code Here


        // need to construct the object label because that's used in the default layout name.
        String objectLabel = null;

        //get the object from the cache based on the object api name
        DescribeObjectRegistry describeObjectRegistry = ContainerDelegate.getInstance().getFactoryLocator().getConnectionFactory().getDescribeObjectRegistry();
        DescribeSObjectResult cachedDescribeSObject = null;
        try {
            cachedDescribeSObject =
                    describeObjectRegistry.getCachedDescribeSObjectByApiName(getComponentWizardModel().getProject()
                            .getName(), objectAPIName);
        } catch (Exception e) {
            logger.error("Unable to get object given the object name: " + e.getMessage());
            throw new InvocationTargetException(e);
        }
        //get the label
        String tempobjectLabel = Utils.isNotEmpty(cachedDescribeSObject) ? cachedDescribeSObject.getLabel() : null;

        //set the object label
        objectLabel =
                (Utils.isNotEmpty(tempobjectLabel) && cachedDescribeSObject.getCustom()) ? tempobjectLabel
                        : objectAPIName;

        String defaultLayoutName = objectAPIName + "-" + objectLabel + " " + Constants.LAYOUT;
        defaulLayout.setName(defaultLayoutName);
View Full Code Here

            Connection connection, String projectName) throws ForceConnectionException, ForceRemoteException {
        List<String> filteredCrtableObjectNamesPluralLabel = new ArrayList<String>();
        SortedSet<String> cachedGlobalDescribeTypes = getCachedGlobalDescribeTypes(connection, projectName);
        for (String crtableObjectName : crtableObjectNames) {
            if (cachedGlobalDescribeTypes.contains(crtableObjectName)) {
                DescribeSObjectResult cachedSObject = getCachedDescribe(connection, projectName, crtableObjectName);
                filteredCrtableObjectNamesPluralLabel.add(cachedSObject.getLabelPlural());
            }
        }
        if (logger.isDebugEnabled() && Utils.isNotEmpty(filteredCrtableObjectNamesPluralLabel)) {
            logger.debug("Cross check CrtableObjectNamesList to see DescribeSObject supported. The list after filtered '"
                    + filteredCrtableObjectNamesPluralLabel + "'");
View Full Code Here

            throws ForceConnectionException, ForceRemoteException {
        if (Utils.isEmpty(projectName) || Utils.isEmpty(componentType)) {
            return null;
        }

        DescribeSObjectResult describeSObjectResult = null;
        Hashtable<String, DescribeSObjectResult> describeCache = getDescribeCacheForProject(projectName);

        if (Utils.isNotEmpty(describeCache)) {
            String type = componentType.toLowerCase();
View Full Code Here

        return describeSObject(sComponentType, true);
    }

    public DescribeSObjectResult describeSObject(String sComponentType, boolean withClientId)
            throws ForceConnectionException, InsufficientPermissionsException {
        DescribeSObjectResult result = null;

        if (!withClientId) {
            setNonCallOptions();
        }
View Full Code Here

        }

        listFields.removeAll();
        Hashtable<String, String> mergeFieldObjects = componentTypes.get(selection);
        if (Utils.isEmpty(mergeFieldObjects)) {
            DescribeSObjectResult describeSObjectResult =
                    getDescribeObjectRegistry().getCachedDescribe(project, selection);
            mergeFieldObjects = new Hashtable<String, String>(describeSObjectResult.getFields().length);

            Field[] fields = describeSObjectResult.getFields();
            if (Utils.isNotEmpty(fields)) {
                Arrays.sort(fields, new Comparator<Field>() {
                    public int compare(Field o1, Field o2) {
                        String name1 = (o1).getLabel();
                        String name2 = (o2).getLabel();
View Full Code Here

            } else {
                childFieldType = SchemaBrowser.CHILD_RELATIONSHIP_FIELD;
                childFieldsNode = SchemaBrowser.CHILD_FIELDS_NODE;
                fieldPrefix = ((ChildRelationship) crRoot.getData("relationship")).getRelationshipName();
            }
            DescribeSObjectResult dr = null;
            IProject project = file.getProject();
            Connection connection = getConnectionFactory().getConnection(project);
            // get describe object w/o client id
            dr = connection.describeSObject(crRoot.getText(), false);

            Field[] fields = dr.getFields();
            TreeItem childFields = createTreeItemChild(crRoot, "Fields", true, 0, true, childFieldsNode);

            SubProgressMonitor spm = new SubProgressMonitor(monitor, 1);
            spm.beginTask("Getting relationship definitions...", fields.length);
            for (Field element : fields) {
View Full Code Here

        if (!describeCache.containsKey(componentType.toLowerCase())) {
            IProject project = file.getProject();
            Connection connection = getConnectionFactory().getConnection(project);

            // get describe object w/o client id
            DescribeSObjectResult describeSObject = connection.describeSObject(componentType, false);
            describeCache.put(componentType.toLowerCase(), describeSObject);
        }
        return describeCache.get(componentType.toLowerCase());
    }
View Full Code Here

TOP

Related Classes of com.sforce.soap.partner.wsc.DescribeSObjectResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.