Class AbstractAssociationGenerator
- java.lang.Object
-
- de.hybris.platform.odata2services.odata.schema.association.AbstractAssociationGenerator
-
- All Implemented Interfaces:
AssociationGenerator
,SchemaElementGenerator<org.apache.olingo.odata2.api.edm.provider.Association,IntegrationObjectItemAttributeModel>
- Direct Known Subclasses:
CollectionAssociationGenerator
,OneToOneAssociationGenerator
public abstract class AbstractAssociationGenerator extends java.lang.Object implements AssociationGenerator
-
-
Constructor Summary
Constructors Constructor Description AbstractAssociationGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TypeAttributeDescriptor
asDescriptor(IntegrationObjectItemAttributeModel attributeDefinitionModel)
Converts attribute model to an attribute descriptor.protected void
checkIsApplicablePrecondition(IntegrationObjectItemAttributeModel attributeDefinitionModel)
Runs safety checks on the specified attribute definition model, to make sure it can be analyzed by theAssociationGenerator.isApplicable(IntegrationObjectItemAttributeModel)
method.java.lang.String
getAssociationName(IntegrationObjectItemAttributeModel attributeDefinitionModel)
Derives the association name from the given attribute definition modelprotected java.lang.String
getAssociationName(TypeAttributeDescriptor descriptor)
Generates association name based on the the provided attribute descriptor.protected org.apache.olingo.odata2.api.edm.EdmMultiplicity
getSourceCardinality(TypeAttributeDescriptor descriptor)
Determines cardinality of the source type presented in the specified attribute descriptor.java.lang.String
getSourceRole(IntegrationObjectItemAttributeModel attributeDefinitionModel)
Derives the source role from the given attribute definition modelprotected java.lang.String
getSourceRole(TypeAttributeDescriptor descriptor)
Generates an association source role.protected org.apache.olingo.odata2.api.edm.EdmMultiplicity
getTargetCardinality(TypeAttributeDescriptor descriptor)
Determines cardinality of the target type presented in the specified attribute descriptor.java.lang.String
getTargetRole(IntegrationObjectItemAttributeModel attributeDefinitionModel)
Derives the target role from the given attribute definition modelprotected java.lang.String
getTargetRole(TypeAttributeDescriptor descriptor)
Generates an association target role.protected java.lang.String
getTargetType(IntegrationObjectItemAttributeModel attributeModel)
Generates an association target type.protected java.lang.String
getTargetType(TypeAttributeDescriptor descriptor)
Generates an association target type.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.odata2services.odata.schema.association.AssociationGenerator
isApplicable
-
Methods inherited from interface de.hybris.platform.odata2services.odata.schema.SchemaElementGenerator
generate
-
-
-
-
Method Detail
-
getSourceRole
public java.lang.String getSourceRole(IntegrationObjectItemAttributeModel attributeDefinitionModel)
Description copied from interface:AssociationGenerator
Derives the source role from the given attribute definition model- Specified by:
getSourceRole
in interfaceAssociationGenerator
- Parameters:
attributeDefinitionModel
- the integration object attribute definition model- Returns:
- the source role
-
getTargetRole
public java.lang.String getTargetRole(IntegrationObjectItemAttributeModel attributeDefinitionModel)
Description copied from interface:AssociationGenerator
Derives the target role from the given attribute definition model- Specified by:
getTargetRole
in interfaceAssociationGenerator
- Parameters:
attributeDefinitionModel
- the integration object attribute definition model- Returns:
- the target role
-
getAssociationName
public java.lang.String getAssociationName(IntegrationObjectItemAttributeModel attributeDefinitionModel)
Description copied from interface:AssociationGenerator
Derives the association name from the given attribute definition model- Specified by:
getAssociationName
in interfaceAssociationGenerator
- Parameters:
attributeDefinitionModel
- the integration object attribute definition model- Returns:
- the association name
-
checkIsApplicablePrecondition
protected void checkIsApplicablePrecondition(IntegrationObjectItemAttributeModel attributeDefinitionModel)
Runs safety checks on the specified attribute definition model, to make sure it can be analyzed by theAssociationGenerator.isApplicable(IntegrationObjectItemAttributeModel)
method. Specifically it checks the the model is notnull
and contains anAttributeDescriptorModel
.- Parameters:
attributeDefinitionModel
- a model to analyze
-
getAssociationName
protected java.lang.String getAssociationName(TypeAttributeDescriptor descriptor)
Generates association name based on the the provided attribute descriptor.- Parameters:
descriptor
- a descriptor to generate the association name for.- Returns:
- name of the descriptor in
"FK_<item_type>_<attribute_type>"
format, whereitem_type
is the type containing the attribute descriptor andattribute_type
is the type of the attribute values or, in other words, type referenced by the attribute.
-
asDescriptor
protected TypeAttributeDescriptor asDescriptor(IntegrationObjectItemAttributeModel attributeDefinitionModel)
Converts attribute model to an attribute descriptor.- Parameters:
attributeDefinitionModel
- a model to convert.- Returns:
- attribute descriptor for the specified attribute model.
-
getSourceRole
protected java.lang.String getSourceRole(TypeAttributeDescriptor descriptor)
Generates an association source role.- Parameters:
descriptor
- an attribute descriptor to generate the source role for.- Returns:
- type code of the
TypeDescriptor
containing the attribute descriptor. - See Also:
TypeAttributeDescriptor.getTypeDescriptor()
,TypeDescriptor.getItemCode()
-
getTargetRole
protected java.lang.String getTargetRole(TypeAttributeDescriptor descriptor)
Generates an association target role.- Parameters:
descriptor
- an attribute descriptor to generate the target role from.- Returns:
- type code of the
TypeDescriptor
referenced by the attribute descriptor (type of the attribute values) or the attribute name if the source type is the same as the target type in the association. - See Also:
TypeAttributeDescriptor.getAttributeType()
,TypeDescriptor.getItemCode()
,TypeAttributeDescriptor.getAttributeName()
-
getTargetType
protected java.lang.String getTargetType(TypeAttributeDescriptor descriptor)
Generates an association target type.- Parameters:
descriptor
- an attribute descriptor to generate the target type from.- Returns:
- type code of the
TypeDescriptor
referenced by the attribute descriptor (type of the attribute values). - See Also:
TypeAttributeDescriptor.getAttributeType()
,TypeDescriptor.getItemCode()
-
getTargetType
protected java.lang.String getTargetType(IntegrationObjectItemAttributeModel attributeModel)
Generates an association target type.- Parameters:
attributeModel
- an attribute descriptor to generate the target type from.- Returns:
- type code of the
TypeDescriptor
referenced by the attribute descriptor (type of the attribute values). - See Also:
TypeAttributeDescriptor.getAttributeType()
,TypeDescriptor.getItemCode()
-
getSourceCardinality
protected org.apache.olingo.odata2.api.edm.EdmMultiplicity getSourceCardinality(TypeAttributeDescriptor descriptor)
Determines cardinality of the source type presented in the specified attribute descriptor. Normally the source type is the item type containing the attribute.- Parameters:
descriptor
- descriptor to derive the cardinality from- Returns:
- multiplicity
-
getTargetCardinality
protected org.apache.olingo.odata2.api.edm.EdmMultiplicity getTargetCardinality(TypeAttributeDescriptor descriptor)
Determines cardinality of the target type presented in the specified attribute descriptor. Normally the target type is the item type returned by the attribute.- Parameters:
descriptor
- descriptor to derive the cardinality from- Returns:
- multiplicity
-
-