/** * @param mergeWithAnnotations Whether to use Java annotations for this * element, if present and not disabled by the XMLContext defaults. * In some contexts (such as an element-collection mapping) merging * with annotations is never allowed. */ private AssociationOverrides getAssociationOverrides(Element tree, XMLContext.Default defaults, boolean mergeWithAnnotations) { List<AssociationOverride> attributes = buildAssociationOverrides( tree, defaults ); if ( mergeWithAnnotations && defaults.canUseJavaAnnotations() ) { AssociationOverride annotation = getPhysicalAnnotation( AssociationOverride.class ); addAssociationOverrideIfNeeded( annotation, attributes ); AssociationOverrides annotations = getPhysicalAnnotation( AssociationOverrides.class ); if ( annotations != null ) { for ( AssociationOverride current : annotations.value() ) { addAssociationOverrideIfNeeded( current, attributes ); } } } if ( attributes.size() > 0 ) { AnnotationDescriptor ad = new AnnotationDescriptor( AssociationOverrides.class ); ad.setValue( "value", attributes.toArray( new AssociationOverride[attributes.size()] ) ); return AnnotationFactory.create( ad ); } else { return null; } }
private static Map<String, JoinColumn[]> buildJoinColumnOverride(XAnnotatedElement element, String path) { Map<String, JoinColumn[]> columnOverride = new HashMap<String, JoinColumn[]>(); if ( element == null ) return columnOverride; AssociationOverride singleOverride = element.getAnnotation( AssociationOverride.class ); AssociationOverrides multipleOverrides = element.getAnnotation( AssociationOverrides.class ); AssociationOverride[] overrides; if ( singleOverride != null ) { overrides = new AssociationOverride[] { singleOverride }; } else if ( multipleOverrides != null ) { overrides = multipleOverrides.value(); } else { overrides = null; } //fill overridden columns if ( overrides != null ) { for (AssociationOverride depAttr : overrides) { columnOverride.put( StringHelper.qualify( path, depAttr.name() ), depAttr.joinColumns() ); } } return columnOverride; }
private static Map<String, JoinTable> buildJoinTableOverride(XAnnotatedElement element, String path) { Map<String, JoinTable> tableOverride = new HashMap<String, JoinTable>(); if ( element == null ) return tableOverride; AssociationOverride singleOverride = element.getAnnotation( AssociationOverride.class ); AssociationOverrides multipleOverrides = element.getAnnotation( AssociationOverrides.class ); AssociationOverride[] overrides; if ( singleOverride != null ) { overrides = new AssociationOverride[] { singleOverride }; } else if ( multipleOverrides != null ) { overrides = multipleOverrides.value(); } else { overrides = null; } //fill overridden tables if ( overrides != null ) { for (AssociationOverride depAttr : overrides) { if ( depAttr.joinColumns().length == 0 ) { tableOverride.put( StringHelper.qualify( path, depAttr.name() ), depAttr.joinTable() ); } } } return tableOverride; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.getSudo", joinColumns = @JoinColumn(name = "GetSudo")), @AssociationOverride(name = "pk.bunruiKbn", joinColumns = @JoinColumn(name = "BunruiKbn")) }) public ClassificationCategoryIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.parent", joinColumns = @JoinColumn(name = "ProGNo")), @AssociationOverride(name = "pk.srProNo", joinColumns = @JoinColumn(name = "SrProNo")) }) public MenuIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.account", joinColumns = @JoinColumn(name = "KmkCode")) }) public BudgetPerformanceWorktableIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.getSudo", joinColumns = @JoinColumn(name = "GetSudo")) }) public ClassificationCategoryWithoutBunruiKbnIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.srDate", joinColumns = @JoinColumn(name = "SrDate")) }) public StampAndLaborCostIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.getSudo", joinColumns = @JoinColumn(name = "GetSudo")), @AssociationOverride(name = "pk.account", joinColumns = @JoinColumn(name = "KmkCode")) }) public FixedSystemCostWorktableIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.vendor", joinColumns = @JoinColumn(name = "SrsCode")), @AssociationOverride(name = "pk.category", joinColumns = @JoinColumn(name = "CtgCode")) }) public SectorVendorIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode", columnDefinition = "TINYINT")), @AssociationOverride(name = "pk.getSudo", joinColumns = @JoinColumn(name = "GetSudo", columnDefinition = "TINYINT")) }) public ClassificationCategoryWithoutBunruiKbnIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.jinjiKbn", joinColumns = @JoinColumn(name = "JinjiKbn")), @AssociationOverride(name = "pk.shoriDate", joinColumns = @JoinColumn(name = "ShoriDate")) }) public LaborCostWorktableIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.getSudo", joinColumns = @JoinColumn(name = "GetSudo")), @AssociationOverride(name = "pk.srDate", joinColumns = @JoinColumn(name = "SrDate")) }) public SalesChangeIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.getSudo", joinColumns = @JoinColumn(name = "GetSudo")) }) public SalesFixedIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.kojinCode", joinColumns = @JoinColumn(name = "KojinCode")), @AssociationOverride(name = "pk.shoriDate", joinColumns = @JoinColumn(name = "ShoriDate")) }) public StrokesLeakageTimeWorktableIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.getSudo", joinColumns = @JoinColumn(name = "GetSudo")), @AssociationOverride(name = "pk.kmkCodeJ", joinColumns = @JoinColumn(name = "KmkCodeJ")) }) public BudgetPerformanceIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.getSudo", joinColumns = @JoinColumn(name = "GetSudo")), @AssociationOverride(name = "pk.srDate", joinColumns = @JoinColumn(name = "SrDate")), @AssociationOverride(name = "pk.vendor", joinColumns = @JoinColumn(name = "SrsCode")), @AssociationOverride(name = "pk.category", joinColumns = @JoinColumn(name = "CtgCode")), @AssociationOverride(name = "pk.wakuNum", joinColumns = @JoinColumn(name = "WakuNum")) }) public PurchaseIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.getSudo", joinColumns = @JoinColumn(name = "GetSudo")), @AssociationOverride(name = "pk.category", joinColumns = @JoinColumn(name = "CtgCode")) }) public InventoryIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.getSudo", joinColumns = @JoinColumn(name = "GetSudo")), @AssociationOverride(name = "pk.vendor", joinColumns = @JoinColumn(name = "SrsCode")), @AssociationOverride(name = "pk.category", joinColumns = @JoinColumn(name = "CtgCode")) }) public MonthlyPurchaseIdentifier getPk() { return pk; }
@EmbeddedId @AssociationOverrides({ @AssociationOverride(name = "pk.organization", joinColumns = @JoinColumn(name = "StrCode")), @AssociationOverride(name = "pk.getSudo", joinColumns = @JoinColumn(name = "GetSudo")), @AssociationOverride(name = "pk.ugKbn", joinColumns = @JoinColumn(name = "UgKbn")), @AssociationOverride(name = "pk.category", joinColumns = @JoinColumn(name = "CtgCode")) }) public MonthlySalesIdentifier getPk() { return pk; }
/** * Funds all association overrides that are attached to the given field or class. * * @param fieldOrClass * the annotated element * @return a mapping from the name of the override to its definition, empty if neither {@link AssociationOverrides} * nor {@link AssociationOverride} are given */ static Map<String, AssociationOverride> getAccociationOverrides(final AnnotatedElement fieldOrClass) { final AssociationOverrides multiOverride = fieldOrClass.getAnnotation(AssociationOverrides.class); final AssociationOverride singleOverride = fieldOrClass.getAnnotation(AssociationOverride.class); if (multiOverride == null && singleOverride == null) { return Collections.emptyMap(); } final Collection<AssociationOverride> config = new ArrayList<>(); // Multi annotation if (multiOverride != null) { config.addAll(Arrays.asList(multiOverride.value())); } // Single annotion if (singleOverride != null) { config.add(singleOverride); } final Map<String, AssociationOverride> attributeOverrides = new HashMap<>(); for (final AssociationOverride override : config) { attributeOverrides.put(override.name(), override); } return attributeOverrides; }