private boolean isIdField( Field field ) { return field.getType() == ID_FIELD_TYPE ? true : false; }
private boolean isReferenceField( Field field ) { return field.getType() == REFERENCE_FIELD_TYPE ? true : false; }
private void addField( Field field ) { String fieldType = field.getType().toString(); String fieldLength = null; String fieldPrecision = null; if ( !fieldType.equals( "boolean" ) && !fieldType.equals( "datetime" ) && !fieldType.equals( "date" ) ) { fieldLength = Integer.toString( field.getLength() ); fieldPrecision = Integer.toString( field.getPrecision() ); } addFieldToTable( field.getLabel(), field.getName(), field.isIdLookup(), field.getType().toString(), fieldLength, fieldPrecision ); }
if ( dateType.equals( fields[ i ].getType() ) ) {
/** * Returns the Force.com API field type for this column. * * @return Force.com API field type */ public FieldType getType() { if (field == null) return null; FieldType type = field.getType(); if (type == FieldType._double && field.getScale() == 0) { type = FieldType._int; } return type; }
/** * Returns the Force.com API field type for this column. * * @return Force.com API field type */ public FieldType getType() { if (field == null) return null; FieldType type = field.getType(); if (type == FieldType._double && field.getScale() == 0) { type = FieldType._int; } return type; }
@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; }
public String getSelectFieldName() { return field != null && field.getType() == FieldType.reference ? getForceApiRelationshipName() : getFieldName(); }
/** * Determines if a Java name should be constructed from the given * Force.com API {@code Field} object's relationship name. * * @param field the Force.com API {@code Field} object to test * @return {@code true} if and only if the given {@code Field} * object is a reference field and has a non {@code null} relationship * name and only references exactly one other Force.com object */ public static boolean useRelationshipName(Field field) { return field.getType() == FieldType.reference && field.getRelationshipName() != null // With more than one reference, we'll revert back to the field name (and String type) && field.getReferenceTo().length == 1; }
public String getSelectFieldName() { return field != null && field.getType() == FieldType.reference ? getForceApiRelationshipName() : getFieldName(); }
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); } }
/** * Derives the LDM type from the SFDC type * * @param fields SFDC object metadata * @param fieldName the field name * @return LDM type */ protected static String getColumnType(Map<String, Field> fields, String fieldName) { String type = SourceColumn.LDM_TYPE_ATTRIBUTE; Field f = fields.get(fieldName); if (f != null) { FieldType t = f.getType(); if (t.getValue().equalsIgnoreCase("id")) type = SourceColumn.LDM_TYPE_CONNECTION_POINT; else if (t.getValue().equalsIgnoreCase("string")) type = SourceColumn.LDM_TYPE_ATTRIBUTE; else if (t.getValue().equalsIgnoreCase("currency")) type = SourceColumn.LDM_TYPE_FACT; else if (t.getValue().equalsIgnoreCase("boolean")) type = SourceColumn.LDM_TYPE_ATTRIBUTE; else if (t.getValue().equalsIgnoreCase("reference")) type = SourceColumn.LDM_TYPE_REFERENCE; else if (t.getValue().equalsIgnoreCase("date")) type = SourceColumn.LDM_TYPE_DATE; else if (t.getValue().equalsIgnoreCase("datetime")) type = SourceColumn.LDM_TYPE_DATE; } return type; }
private String renderFieldType(Field field) { FieldType type = field.getType(); if (type == FieldType._boolean || type == FieldType.combobox) {
private String renderFieldComments(Field field, JavaCommentBuilder builder) { if (field.getType() == FieldType.reference && field.getReferenceTo().length > 1) { builder.add(renderJavaName(field, true) + " possible references:"); for (String refTo : field.getReferenceTo()) { builder.add(refTo); } } return builder.toString(); }
private String renderGetterAnnotation(Field field, JPAAnnotationBuilder builder) { FieldType type = field.getType(); if (type == FieldType.id) { builder.add(Id.class);
/** * * Appends an in-progress SOQL select string with the right name for this field. * * @param queryHelper the expression builder that is currently in progress * @param acmd the class metadata for the entity this field belongs to * @param fieldNum the number of this field in DataNucleus * @param appendComma whether to append a comma before the field * @param prefix the prefix to prepend, if necessary * @return true if something was appended to the query */ public boolean appendSelectString(ExpressionBuilderHelper queryHelper, AbstractClassMetaData acmd, int fieldNum, boolean appendComma, String prefix) { if (field != null && field.getType() == FieldType.reference && !queryHelper.isJoinQuery()) { if (queryHelper.skipRelationship(acmd, fieldNum)) return false; appendPrefix(queryHelper, appendComma, null); // just append comma queryHelper.appendRelationship(acmd, fieldNum, this, prefix, false); } else { appendPrefix(queryHelper, appendComma, prefix); queryHelper.getBuilder().append(getFieldName()); } return true; }
/** * * Appends an in-progress SOQL select string with the right name for this field. * * @param queryHelper the expression builder that is currently in progress * @param acmd the class metadata for the entity this field belongs to * @param fieldNum the number of this field in DataNucleus * @param appendComma whether to append a comma before the field * @param prefix the prefix to prepend, if necessary * @return true if something was appended to the query */ public boolean appendSelectString(ExpressionBuilderHelper queryHelper, AbstractClassMetaData acmd, int fieldNum, boolean appendComma, String prefix) { if (field != null && field.getType() == FieldType.reference && !queryHelper.isJoinQuery()) { if (queryHelper.skipRelationship(acmd, fieldNum)) return false; appendPrefix(queryHelper, appendComma, null); // just append comma queryHelper.appendRelationship(acmd, fieldNum, this, prefix, false); } else { appendPrefix(queryHelper, appendComma, prefix); queryHelper.getBuilder().append(getFieldName()); } return true; }
final String columnLabel = field.getLabel(); final Boolean nillable = field.isNillable(); final FieldType type = field.getType(); final Integer columnSize = field.getLength(); final ColumnType columnType = toColumnType(type);
final String columnLabel = field.getLabel(); final Boolean nillable = field.isNillable(); final FieldType type = field.getType(); final Integer columnSize = field.getLength(); final ColumnType columnType = toColumnType(type);
final String columnLabel = field.getLabel(); final Boolean nillable = field.isNillable(); final FieldType type = field.getType(); final Integer columnSize = field.getLength(); final ColumnType columnType = toColumnType(type);