public Field[] getObjectFields( String objectName ) throws KettleException { DescribeSObjectResult describeSObjectResult = null; try { // Get object describeSObjectResult = getBinding().describeSObject( objectName ); if ( describeSObjectResult == null ) { return null; } if ( !describeSObjectResult.isQueryable() ) { throw new KettleException( BaseMessages.getString( PKG, "SalesforceInputDialog.ObjectNotQueryable", this.module ) ); } else { // we can query this object return describeSObjectResult.getFields(); } } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "SalesforceInput.Error.GettingModuleFields", this.module ), e ); } finally { if ( describeSObjectResult != null ) { describeSObjectResult = null; } } }
boolean _equals; _equals = true && this.activateable == other.isActivateable() && ((this.childRelationships == null && other.getChildRelationships() == null) || (this.childRelationships != null && java.util.Arrays.equals(this.childRelationships, other.getChildRelationships()))) && this.createable == other.isCreateable() && this.custom == other.isCustom() && this.customSetting == other.isCustomSetting() && this.deletable == other.isDeletable() && this.deprecatedAndHidden == other.isDeprecatedAndHidden() && this.feedEnabled == other.isFeedEnabled() && ((this.fields == null && other.getFields() == null) || (this.fields != null && java.util.Arrays.equals(this.fields, other.getFields()))) && ((this.keyPrefix == null && other.getKeyPrefix() == null) || (this.keyPrefix != null && this.keyPrefix.equals(other.getKeyPrefix()))) && ((this.label == null && other.getLabel() == null) || (this.label != null && this.label.equals(other.getLabel()))) && ((this.labelPlural == null && other.getLabelPlural() == null) || (this.labelPlural != null && this.labelPlural.equals(other.getLabelPlural()))) && this.layoutable == other.isLayoutable() && this.mergeable == other.isMergeable() && ((this.name == null && other.getName() == null) || (this.name != null && this.name.equals(other.getName()))) &&
private void filterObjectAndReferences(Set<String> objectNameSet) { // Subtract any objects that we've already fetched objectNameSet.removeAll(filteredResultNames); if (objectNameSet.isEmpty()) return; Set<String> objectReferencesSet = new HashSet<String>(); for (String objectName : objectNameSet) { DescribeSObjectResult dsr; if ((dsr = objectMap.get(objectName)) != null) { // Gather all the references for this object for (Field field : dsr.getFields()) { if (field.getType() == FieldType.reference) { objectReferencesSet.addAll(Arrays.asList(field.getReferenceTo())); } } filteredResultNames.add(dsr.getName()); filteredResult.add(dsr); } } // Here, we'll recursively fetch all the object references we found. filterObjectAndReferences(objectReferencesSet); } }
@Override public List<Field> filter(DescribeSObjectResult dsr) { if (dsr == null) return null; return Lists.newArrayList(dsr.getFields()); }
for (Field field : result.getFields()) { String columnName = field.getName().toLowerCase(); ColumnImpl column = new ColumnImpl(columnName, field); ChildRelationship[] relationships = result.getChildRelationships(); for (ChildRelationship cr : relationships) { String relationshipName = cr.getRelationshipName();
@Override public List<Field> filter(DescribeSObjectResult dsr) { List<Field> filteredFields = Lists.newArrayList(dsr.getFields()); for (FieldFilter filter : filterList) { filteredFields = filter.filter(dsr); dsr.setFields(filteredFields.toArray(new Field[filteredFields.size()])); } return filteredFields; }
/** * Determines if a Force.com object has all standard Force.com fields. * * @param dsr a Force.com {@code DescribeSObjectResult} of the object * to be tested * @return {@code true} if and only if the given object contains all * common Force.com fields * @see ForceJPAClassGeneratorUtils#STANDARD_OBJECT_COMMON_FIELDS */ public static boolean hasAllCommonFields(DescribeSObjectResult dsr) { // Custom objects always have all common fields if (dsr.isCustom()) return true; // Gather up all the field names for this standard object Set<String> fieldNameSet = new HashSet<String>(); for (Field field : dsr.getFields()) { fieldNameSet.add(field.getName().toLowerCase()); } return fieldNameSet.containsAll(STANDARD_OBJECT_COMMON_FIELDS); }
private void getColumnsAndRelationships(List<String> names) throws TranslatorException { DescribeSObjectResult objectMetadatas[] = connection.getObjectMetaData(names.toArray(new String[names.size()])); for (DescribeSObjectResult objectMetadata : objectMetadatas) { getRelationships(objectMetadata); Table table = this.tableMap.get(objectMetadata.getName()); boolean hasUpdateableColumn = addColumns(objectMetadata, table); // Some SF objects return true for isUpdateable() but have no updateable columns. if(objectMetadata.isDeletable() || (hasUpdateableColumn && (objectMetadata.isUpdateable() || objectMetadata.isCreateable()))) { table.setSupportsUpdate(true); } } names.clear(); }
@Override public List<DescribeSObjectResult> filter(List<DescribeSObjectResult> dsrs) { List<DescribeSObjectResult> filteredResult = new ArrayList<DescribeSObjectResult>(); for (DescribeSObjectResult dsr : dsrs) { // include => objectNames.contains(name) // exclude => !objectNames.contains(name) if (include == objectNames.contains(dsr.getName())) { filteredResult.add(dsr); } } return filteredResult; }
private void getRelationships(DescribeSObjectResult objectMetadata) { ChildRelationship[] children = objectMetadata.getChildRelationships(); if(children != null && children.length > 0) { this.relationships.put(objectMetadata.getName(), children); } }
DescribeSObjectResult dsr = new DescribeSObjectResult(); dsr.setName(referenceTo[0]);
private String renderSuperClassName(DescribeSObjectResult dsr) { if (dsr.isCustom()) return BaseForceCustomObject.class.getName(); // If the standard object doesn't contain *all* the common // standard object fields, just extend the generic base class (e.g. User, UserLicense) if (!ForceJPAClassGeneratorUtils.hasAllCommonFields(dsr)) return BaseForceObject.class.getName(); return BaseForceStandardObject.class.getName(); }
@Override public com.sforce.soap.partner.IDescribeSObjectResult newIDescribeSObjectResult() { return new com.sforce.soap.partner.DescribeSObjectResult(); }
_hashCode += (isActivateable() ? Boolean.TRUE : Boolean.FALSE).hashCode(); if (getChildRelationships() != null) { for (int i = 0; i < java.lang.reflect.Array.getLength(getChildRelationships()); i++) { java.lang.Object obj = java.lang.reflect.Array.get(getChildRelationships(), i); if (obj != null && !obj.getClass().isArray()) { _hashCode += (isCreateable() ? Boolean.TRUE : Boolean.FALSE).hashCode(); _hashCode += (isCustom() ? Boolean.TRUE : Boolean.FALSE).hashCode(); _hashCode += (isCustomSetting() ? Boolean.TRUE : Boolean.FALSE).hashCode(); _hashCode += (isDeletable() ? Boolean.TRUE : Boolean.FALSE).hashCode(); _hashCode += (isDeprecatedAndHidden() ? Boolean.TRUE : Boolean.FALSE).hashCode(); _hashCode += (isFeedEnabled() ? Boolean.TRUE : Boolean.FALSE).hashCode(); if (getFields() != null) { for (int i = 0; i < java.lang.reflect.Array.getLength(getFields()); i++) { java.lang.Object obj = java.lang.reflect.Array.get(getFields(), i); if (obj != null && !obj.getClass().isArray()) { if (getKeyPrefix() != null) { _hashCode += getKeyPrefix().hashCode(); if (getLabel() != null) { _hashCode += getLabel().hashCode();
@Override public List<Field> filter(DescribeSObjectResult dsr) { List<Field> fieldList = Lists.newArrayList(dsr.getFields()); Iterator<Field> fieldIter = fieldList.iterator(); while (fieldIter.hasNext()) { Field field = fieldIter.next(); if (field.getType() == FieldType.reference) { for (String referenceTo : field.getReferenceTo()) { // Remove if there exists a reference to object for which: // // include and referenceObjectNames does not contain name // OR // exclude and referenceObjectNames contains name if (include != referenceObjectNames.contains(referenceTo)) { fieldIter.remove(); break; } } } } return fieldList; }
for (Field field : result.getFields()) { String columnName = field.getName().toLowerCase(); ColumnImpl column = new ColumnImpl(columnName, field); ChildRelationship[] relationships = result.getChildRelationships(); for (ChildRelationship cr : relationships) { String relationshipName = cr.getRelationshipName();
@Override public List<DescribeSObjectResult> filter(List<DescribeSObjectResult> dsrs) { for (DescribeSObjectResult dsr : dsrs) { objectMap.put(dsr.getName(), dsr); } filterObjectAndReferences(objectNames); return filteredResult; }
@Override public List<Field> filter(DescribeSObjectResult dsr) { if (dsr.isCustom()) { // Skip all fields common to Force.com custom objects return filterInternal(dsr, CUSTOM_OBJECT_COMMON_FIELDS); } else if (ForceJPAClassGeneratorUtils.hasAllCommonFields(dsr)) { // Skip all fields common to Force.com standard objects return filterInternal(dsr, STANDARD_OBJECT_COMMON_FIELDS); } // Skip all fields common to all Force.com objects return filterInternal(dsr, ALL_OBJECT_COMMON_FIELDS); }