/** * INTERNAL: * Returns the set of fields that should be selected to build this mapping's value(s). * This is used by expressions to determine which fields to include in the select clause for non-object expressions. */ public Vector getSelectFields() { return getFields(); }
/** * INTERNAL: * Returns the set of fields that should be selected to build this mapping's value(s). * This is used by expressions to determine which fields to include in the select clause for non-object expressions. */ public Vector getSelectFields() { return getFields(); }
/** * INTERNAL: * Returns the set of fields that should be selected to build this mapping's value(s). * This is used by expressions to determine which fields to include in the select clause for non-object expressions. */ public Vector getSelectFields() { return getFields(); }
/** * Return the field used for the query key name. */ public DatabaseField getFieldForQueryKeyName(String name) { QueryKey key = this.descriptor.getQueryKeyNamed(name); if (key == null) { DatabaseMapping mapping = getMappingForAttributeName(name); if (mapping == null) { return null; } if (mapping.getFields().isEmpty()) { return null; } return mapping.getFields().get(0); } if (key.isDirectQueryKey()) { return ((DirectQueryKey)key).getField(); } return null; }
/** * Return the field used for the query key name. */ public DatabaseField getFieldForQueryKeyName(String name) { QueryKey key = this.descriptor.getQueryKeyNamed(name); if (key == null) { DatabaseMapping mapping = getMappingForAttributeName(name); if (mapping == null) { return null; } if (mapping.getFields().isEmpty()) { return null; } return mapping.getFields().get(0); } if (key.isDirectQueryKey()) { return ((DirectQueryKey)key).getField(); } return null; }
/** * Return the field used for the query key name. */ public DatabaseField getFieldForQueryKeyName(String name) { QueryKey key = this.descriptor.getQueryKeyNamed(name); if (key == null) { DatabaseMapping mapping = getMappingForAttributeName(name); if (mapping == null) { return null; } if (mapping.getFields().isEmpty()) { return null; } return mapping.getFields().get(0); } if (key.isDirectQueryKey()) { return ((DirectQueryKey)key).getField(); } return null; }
/** * INTERNAL: */ @Override public DatabaseField getField() { if (!isAttribute()) { return null; } QueryKey key = getQueryKeyOrNull(); if ((key != null) && key.isDirectQueryKey()) { return ((DirectQueryKey)key).getField(); } DatabaseMapping mapping = getMapping(); if ((mapping == null) || mapping.getFields().isEmpty()) { return null; } return mapping.getFields().get(0); }
/** * INTERNAL: */ @Override public DatabaseField getField() { if (!isAttribute()) { return null; } QueryKey key = getQueryKeyOrNull(); if ((key != null) && key.isDirectQueryKey()) { return ((DirectQueryKey)key).getField(); } DatabaseMapping mapping = getMapping(); if ((mapping == null) || mapping.getFields().isEmpty()) { return null; } return mapping.getFields().get(0); }
/** * INTERNAL: * Extract the fields for the Map key from the object to use in a query. */ @Override public Map extractIdentityFieldsForQuery(Object object, AbstractSession session){ Map keyFields = new HashMap(); ClassDescriptor descriptor =getReferenceDescriptor(); boolean usePrimaryKeyFields = (descriptor.getPrimaryKeyFields() != null && ! descriptor.getPrimaryKeyFields().isEmpty()) ? true : false; Iterator <DatabaseMapping> i = descriptor.getMappings().iterator(); while (i.hasNext()){ DatabaseMapping mapping = i.next(); if (!mapping.isReadOnly() && (!usePrimaryKeyFields || (usePrimaryKeyFields && mapping.isPrimaryKeyMapping()))){ Iterator<DatabaseField> fields = mapping.getFields().iterator(); while (fields.hasNext()){ DatabaseField field = fields.next(); if (field.isUpdatable()){ Object value = descriptor.getObjectBuilder().extractValueFromObjectForField(object, field, session); keyFields.put(field, value); } } } } return keyFields; }
/** * INTERNAL: * Extract the fields for the Map key from the object to use in a query. */ @Override public Map extractIdentityFieldsForQuery(Object object, AbstractSession session){ Map keyFields = new HashMap(); ClassDescriptor descriptor =getReferenceDescriptor(); boolean usePrimaryKeyFields = (descriptor.getPrimaryKeyFields() != null && ! descriptor.getPrimaryKeyFields().isEmpty()) ? true : false; Iterator <DatabaseMapping> i = descriptor.getMappings().iterator(); while (i.hasNext()){ DatabaseMapping mapping = i.next(); if (!mapping.isReadOnly() && (!usePrimaryKeyFields || (usePrimaryKeyFields && mapping.isPrimaryKeyMapping()))){ Iterator<DatabaseField> fields = mapping.getFields().iterator(); while (fields.hasNext()){ DatabaseField field = fields.next(); if (field.isUpdatable()){ Object value = descriptor.getObjectBuilder().extractValueFromObjectForField(object, field, session); keyFields.put(field, value); } } } } return keyFields; }
private void processXMLDescriptor(List<Descriptor> processed, Descriptor desc, org.eclipse.persistence.internal.oxm.NamespaceResolver nr) { if (desc == null || processed.contains(desc)) { return; } processed.add(desc); Vector mappings = desc.getMappings(); for (Object mapping : mappings) { DatabaseMapping nextMapping = (DatabaseMapping) mapping; Vector fields = nextMapping.getFields(); updateResolverForFields(fields, nr); Descriptor refDesc = (Descriptor) nextMapping.getReferenceDescriptor(); if (refDesc != null && !processed.contains(refDesc)) { processXMLDescriptor(processed, refDesc, nr); } if (nextMapping instanceof ChoiceObjectMapping) { Set refClasses = ((ChoiceObjectMapping) nextMapping).getClassToFieldMappings().keySet(); processRefClasses(processed, refClasses, nr); } else if (nextMapping instanceof ChoiceCollectionMapping) { Set refClasses = ((ChoiceCollectionMapping) nextMapping).getClassToFieldMappings().keySet(); processRefClasses(processed, refClasses, nr); } } }
private void processXMLDescriptor(List<Descriptor> processed, Descriptor desc, org.eclipse.persistence.internal.oxm.NamespaceResolver nr) { if (desc == null || processed.contains(desc)) { return; } processed.add(desc); Vector mappings = desc.getMappings(); for (Object mapping : mappings) { DatabaseMapping nextMapping = (DatabaseMapping) mapping; Vector fields = nextMapping.getFields(); updateResolverForFields(fields, nr); Descriptor refDesc = (Descriptor) nextMapping.getReferenceDescriptor(); if (refDesc != null && !processed.contains(refDesc)) { processXMLDescriptor(processed, refDesc, nr); } if (nextMapping instanceof ChoiceObjectMapping) { Set refClasses = ((ChoiceObjectMapping) nextMapping).getClassToFieldMappings().keySet(); processRefClasses(processed, refClasses, nr); } else if (nextMapping instanceof ChoiceCollectionMapping) { Set refClasses = ((ChoiceCollectionMapping) nextMapping).getClassToFieldMappings().keySet(); processRefClasses(processed, refClasses, nr); } } }
/** * INTERNAL: * This method is for processing a single FieldResult, returning the DatabaseField it refers to. */ public DatabaseField processValueFromRecordForMapping(ClassDescriptor descriptor, String[] attributeNames, int currentLoc){ DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForAttributeName(attributeNames[currentLoc]); if (mapping==null){throw QueryException.mappingForFieldResultNotFound(attributeNames,currentLoc);} currentLoc++; if (attributeNames.length!=currentLoc){ ClassDescriptor currentDescriptor = mapping.getReferenceDescriptor(); DatabaseField df= processValueFromRecordForMapping(currentDescriptor, attributeNames, currentLoc); if (mapping.isOneToOneMapping()){ return (((OneToOneMapping)mapping).getTargetToSourceKeyFields().get(df)); } return df; }else{ //this is it.. return this mapping's field return mapping.getFields().firstElement(); } }
/** * INTERNAL: * Return all the fields in the key. MapContainerPolicy gets it fields from the reference descriptor * of the provided mappings. It uses its keyName to lookup the appropriate mapping and returns the fields from * that mapping * @return */ public List<DatabaseField> getAllFieldsForMapKey(CollectionMapping baseMapping){ if (baseMapping == null){ return null; } ClassDescriptor descriptor = baseMapping.getReferenceDescriptor(); if (keyName != null){ DatabaseMapping mapping = descriptor.getMappingForAttributeName(Helper.getAttributeNameFromMethodName(keyName)); return mapping.getFields(); } else { return descriptor.getPrimaryKeyFields(); } }
/** * INTERNAL: * This method is for processing a single FieldResult, returning the DatabaseField it refers to. */ public DatabaseField processValueFromRecordForMapping(ClassDescriptor descriptor, String[] attributeNames, int currentLoc){ DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForAttributeName(attributeNames[currentLoc]); if (mapping==null){throw QueryException.mappingForFieldResultNotFound(attributeNames,currentLoc);} currentLoc++; if (attributeNames.length!=currentLoc){ ClassDescriptor currentDescriptor = mapping.getReferenceDescriptor(); DatabaseField df= processValueFromRecordForMapping(currentDescriptor, attributeNames, currentLoc); if (mapping.isOneToOneMapping()){ return (((OneToOneMapping)mapping).getTargetToSourceKeyFields().get(df)); } return df; }else{ //this is it.. return this mapping's field return mapping.getFields().firstElement(); } }
/** * INTERNAL: * This method is for processing a single FieldResult, returning the DatabaseField it refers to. */ public DatabaseField processValueFromRecordForMapping(ClassDescriptor descriptor, String[] attributeNames, int currentLoc){ DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForAttributeName(attributeNames[currentLoc]); if (mapping==null){throw QueryException.mappingForFieldResultNotFound(attributeNames,currentLoc);} currentLoc++; if (attributeNames.length!=currentLoc){ ClassDescriptor currentDescriptor = mapping.getReferenceDescriptor(); DatabaseField df= processValueFromRecordForMapping(currentDescriptor, attributeNames, currentLoc); if (mapping.isOneToOneMapping()){ return (((OneToOneMapping)mapping).getTargetToSourceKeyFields().get(df)); } return df; }else{ //this is it.. return this mapping's field return mapping.getFields().firstElement(); } }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map * Called when the insert query is being initialized to ensure the fields for the map key are in the insert query */ @Override public void addFieldsForMapKey(AbstractRecord joinRow){ for (DatabaseMapping mapping : getReferenceDescriptor().getMappings()) { if (!mapping.isReadOnly()) { for (DatabaseField field : mapping.getFields()) { if (field.isUpdatable()){ joinRow.put(field, null); } } } } }
/** * INTERNAL: * Used when initializing queries for mappings that use a Map * Called when the insert query is being initialized to ensure the fields for the map key are in the insert query */ @Override public void addFieldsForMapKey(AbstractRecord joinRow){ for (DatabaseMapping mapping : getReferenceDescriptor().getMappings()) { if (!mapping.isReadOnly()) { for (DatabaseField field : mapping.getFields()) { if (field.isUpdatable()){ joinRow.put(field, null); } } } } }
/** * Calculate the source table for based on the various QueryKeyExpression * usages (join query keys, custom defined query keys, or query keys for * mappings). * * Called from {@link SQLSelectStatement#appendFromClauseForOuterJoin}. * * @return DatabaseTable */ public DatabaseTable getSourceTable() { if(getMapping() != null) { // Grab the source table from the mapping not just the first table // from the descriptor. In an joined inheritance hierarchy, the // fk used in the outer join may be from a subclasses's table. if (getMapping().isObjectReferenceMapping() && ((ObjectReferenceMapping) getMapping()).isForeignKeyRelationship()) { return getMapping().getFields().firstElement().getTable(); } else { return ((ObjectExpression)getBaseExpression()).getDescriptor().getTables().firstElement(); } } else { return ((ForeignReferenceQueryKey)getQueryKeyOrNull()).getSourceTable(); } }
/** * calculate indexes for an item, given the current Offset */ protected int computeAndSetItemOffset(ReportItem item, int itemOffset){ item.setResultIndex(itemOffset); if (item.getAttributeExpression() != null) { if (item.hasJoining()){ itemOffset = item.getJoinedAttributeManager().computeJoiningMappingIndexes(true, getSession(), itemOffset); } else { if (item.getDescriptor() != null) { itemOffset += item.getDescriptor().getAllSelectionFields((ReportQuery)getQuery()).size(); } else { if (item.getMapping() != null && item.getMapping().isAggregateObjectMapping()) { itemOffset += item.getMapping().getFields().size(); // Aggregate object may consist out of 1..n fields } else { ++itemOffset; //only a single attribute can be selected } } } } return itemOffset; }