All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mel.camel-salesforce-codegen.3.19.0.source-code.sobject-pojo.vm Maven / Gradle / Ivy

There is a newer version: 4.9.0
Show newest version
## ------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements.  See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License.  You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ------------------------------------------------------------------------
## sobject-pojo.vm
/*
 * Salesforce DTO generated by camel-salesforce-maven-plugin.
 */
package $packageName;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Generated;

#set ( $hasPicklists = $utility.hasPicklists($desc) )
#set ( $hasMultiSelectPicklists = $utility.hasMultiSelectPicklists($desc) )
#if ( $hasPicklists && !$useStringsForPicklists )
#end
#if ( $hasMultiSelectPicklists )
#if ( $useStringsForPicklists )
import org.apache.camel.component.salesforce.api.StringMultiSelectPicklistDeserializer;
import org.apache.camel.component.salesforce.api.StringMultiSelectPicklistSerializer;
#else
import org.apache.camel.component.salesforce.api.MultiSelectPicklistDeserializer;
import org.apache.camel.component.salesforce.api.MultiSelectPicklistSerializer;
#end
#end
import org.apache.camel.component.salesforce.api.dto.AbstractDescribedSObjectBase;
import org.apache.camel.component.salesforce.api.dto.Attributes;
import org.apache.camel.component.salesforce.api.dto.ChildRelationShip;
import org.apache.camel.component.salesforce.api.dto.InfoUrls;
import org.apache.camel.component.salesforce.api.dto.NamedLayoutInfo;
import org.apache.camel.component.salesforce.api.dto.RecordTypeInfo;
import org.apache.camel.component.salesforce.api.dto.SObjectDescription;
import org.apache.camel.component.salesforce.api.dto.SObjectDescriptionUrls;
import org.apache.camel.component.salesforce.api.dto.SObjectField;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.annotation.JsonTypeResolver;
import org.apache.camel.component.salesforce.api.utils.AsNestedPropertyResolver;
#if ( $hasMultiSelectPicklists )
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
#end

/**
 * Salesforce DTO for SObject $desc.Name
 */
@Generated("org.apache.camel.maven.CamelSalesforceMojo")
public class $desc.Name extends AbstractDescribedSObjectBase {

    public ${desc.Name}() {
        getAttributes().setType("$desc.Name");
    }

    private static final SObjectDescription DESCRIPTION = createSObjectDescription();

#foreach ( $field in $desc.Fields )
#set ( $fieldType = $utility.getFieldType($desc, $field) )
#if ( ($utility.notBaseField($field.Name)) && ($fieldType) )
#set ( $fieldName = $field.Name )
#set ( $isMultiSelectPicklist = $utility.isMultiSelectPicklist($field) )
#if ( $utility.isBlobField($field) )
#set ( $propertyName = $fieldName + "Url" )
#else
#set ( $propertyName = $fieldName )
#end
    private $fieldType $propertyName;

    @JsonProperty("$fieldName")
#if ( $isMultiSelectPicklist )
#if ( $useStringsForPicklists )
    @JsonSerialize(using = StringMultiSelectPicklistSerializer.class)
#else
    @JsonSerialize(using = MultiSelectPicklistSerializer.class)
#end
#end
    public $fieldType get$propertyName() {
        return this.$propertyName;
    }

    @JsonProperty("$fieldName")
#if ( $isMultiSelectPicklist )
#if ( $useStringsForPicklists )
    @JsonDeserialize(using = StringMultiSelectPicklistDeserializer.class)
#else
    @JsonDeserialize(using = MultiSelectPicklistDeserializer.class)
#end
#end
    public void set$propertyName($fieldType $propertyName) {
        this.$propertyName = $propertyName;
    }

#end
#if ( $field.type == "reference" && $utility.notNull($field.relationshipName) )## IS LOOKUP $hasDescription
#if ( $field.getReferenceTo().size() > 1 )
#set ( $propertyType = "AbstractDescribedSObjectBase")
    @JsonTypeResolver(AsNestedPropertyResolver.class)
    @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "attributes.type",
        defaultImpl = AbstractDescribedSObjectBase.class)
    @JsonSubTypes({
#foreach ( $sob in $field.getReferenceTo() )
#if ($utility.hasDescription($sob))
        @JsonSubTypes.Type(value = ${sob}.class, name = "$sob")#if( $foreach.hasNext ),#end
#end
#end
    })
#elseif ( $sObjectNames.contains($field.getReferenceTo().get(0)) )
#set ( $propertyType = $field.getReferenceTo().get(0) )
#else
#set ( $propertyType = "AbstractDescribedSObjectBase")
#end
#set( $jsonPropertyName = $field.relationshipName )
    private $propertyType $jsonPropertyName;

    @JsonProperty("${jsonPropertyName}")
    public $propertyType get${jsonPropertyName}() {
        return this.$jsonPropertyName;
    }

    @JsonProperty("${jsonPropertyName}")
    public void set${jsonPropertyName}($propertyType $jsonPropertyName) {
        this.${jsonPropertyName} = $jsonPropertyName;
    }
#end## END IS LOOKUP
#end##foreach field
#foreach ( $rel in $desc.childRelationships )
#set (  $hasDescription = $sObjectNames.contains($rel.childSObject) )
#if ( $utility.notNull($rel.relationshipName) && $hasDescription )
    private QueryRecords${rel.childSObject} ${rel.relationshipName}${childRelationshipNameSuffix};

    @JsonProperty("$rel.relationshipName")
    public QueryRecords${rel.childSObject} get${rel.relationshipName}${childRelationshipNameSuffix}() {
        return ${rel.relationshipName}${childRelationshipNameSuffix};
    }

    @JsonProperty("$rel.relationshipName")
    public void set${rel.relationshipName}${childRelationshipNameSuffix}(QueryRecords${rel.childSObject} ${rel.relationshipName}) {
        this.${rel.relationshipName}${childRelationshipNameSuffix} = ${rel.relationshipName};
    }
#end
#end

##
## macro to generate source code based on Java beans (supports SObjectDescription properties)
##
#macro( generateSource $obj )## MACRO
#foreach ( $p in $utility.propertiesOf($obj) )## PROPERTY LOOP
#if ( $utility.notNull(${p.value}) )## VALUE DEFINED CONDITION
#if ( ${p.value.class.name} == "java.lang.String" )## STRING CONDITION
        ${utility.current()}.set${p.key}("$esc.escapeJava(${p.value})");
#elseif ( ${utility.isPrimitiveOrBoxed(${p.value})} )## PRIMITIVE OR BOXED CONDITION
        ${utility.current()}.set${p.key}(${p.value});
#elseif ( ${p.value.class.name} == "java.util.ArrayList" )## LIST CONDITION
#if ( ${utility.includeList(${p.value}, ${p.key})} )## VALUE NOT EMPTY CONDITION
#set ( $var = ${utility.variableName(${p.key})} )

        final List<${p.value[0].class.simpleName}> ${var} = new ArrayList<>();
        ${utility.current()}.set${p.key}(${var});
${utility.push($var)}
#if ( ${p.value[0].class.name} == "java.lang.String" )## STRING LIST ELEMENTS
#foreach ( $i in ${p.value} )## STRING LIST LOOP
        ${utility.current()}.add("${i}");
#end## END STRING LIST LOOP
${utility.pop()}
#else
#foreach ( $i in ${p.value} )## BEAN LIST LOOP
#set ( $var = ${utility.variableName(${i.class.simpleName})} )
#if ( ${i.class.simpleName} == "SObjectField" )
        final ${i.class.simpleName} $var = createField("${i.name}", "${utility.javaSafeString(${i.label})}", "${i.type}", "${i.soapType}", ${i.length}, ${i.unique}, ${i.nillable}, ${i.nameField}, ${i.externalId}, ${i.custom}, ${i.caseSensitive}, ${i.idLookup});
        ${utility.current()}.add(${var});
#else
        final ${i.class.simpleName} $var = new ${i.class.simpleName}();
        ${utility.current()}.add(${var});
${utility.push($var)}
#generateSource( ${i} )
${utility.pop()}
#end## SObjectField CONDITION
#end## END BEAN LIST LOOP
${utility.pop()}
#end## END STRING LIST ELEMENTS
#end## END VALUE NOT EMPTY CONDITION
#else
#set ( $var = ${utility.variableName(${p.value.class.simpleName})} )
${utility.push($var)}
        final ${p.value.class.simpleName} $var = new ${p.value.class.simpleName}();
#generateSource( ${p.value} )
${utility.pop()}        ${utility.current()}.set${p.key}(${var});
#end## END TYPE CONDITION
#end## VALUE DEFINED CONDITION
#end## END PROPERTY LOOP
#end## END MACRO
    @Override
    public final SObjectDescription description() {
        return DESCRIPTION;
    }

    private static SObjectDescription createSObjectDescription() {
        final SObjectDescription description = new SObjectDescription();

$utility.start("description")
#generateSource( $desc )

        return description;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy