/** * validate embedded column . * * @param metadata * the metadata * @param embeddedColumns * the embedded columns * @return true, if successful */ private boolean validateEmbeddedColumns(EntityMetadata metadata, Collection<EmbeddableType> embeddedColumns) { boolean isValid = false; Iterator<EmbeddableType> iter = embeddedColumns.iterator(); while (iter.hasNext()) { isValid = validateColumns(metadata, iter.next().getAttributes()) ? true : false; } return isValid; }
/** * Gets the composite id embeddables. * * @param embeddable * the embeddable * @param compositeEmbeddables * the composite embeddables * @param metaModel * the meta model * @return the composite id embeddables */ private void getCompositeIdEmbeddables(EmbeddableType embeddable, List compositeEmbeddables, MetamodelImpl metaModel) { compositeEmbeddables.add(embeddable.getJavaType().getSimpleName()); for (Object column : embeddable.getAttributes()) { Attribute columnAttribute = (Attribute) column; Field f = (Field) columnAttribute.getJavaMember(); if (columnAttribute.getJavaType().isAnnotationPresent(Embeddable.class)) { getCompositeIdEmbeddables(metaModel.embeddable(columnAttribute.getJavaType()), compositeEmbeddables, metaModel); } } }
Field field) { if (!ReflectUtils.isTransientOrStatic(field)) { Attribute compositeColumn = compoundKey.getAttribute(field.getName()); if (compositeColumn.getJavaType().isAnnotationPresent(Embeddable.class)) { Set<Attribute> cols = partitionCol.getAttributes(); for (Attribute col : cols) { Field f = (Field) col.getJavaMember();
/** * Assert on embeddable type. * * @param <X> * the generic type * @param entityClazz * the entity clazz * @param attribute * the attribute * @param embeddableType * the embeddable type * @param attributeName * the attribute name * @param attributeClazz * the attribute clazz */ @SuppressWarnings({ "rawtypes", "unchecked" }) private <X> void assertOnEmbeddableType(Class entityClazz, Attribute<X, String> attribute, EmbeddableType<X> embeddableType, String attributeName, Class attributeClazz) { Assert.assertNotSame(entityClazz.getDeclaredFields().length, embeddableType.getAttributes().size()); Assert.assertEquals(1, embeddableType.getAttributes().size()); Assert.assertEquals(entityClazz, embeddableType.getJavaType()); Attribute attributeTwo = (Attribute) embeddableType.getAttribute(attributeName); Assert.assertNotNull(attribute); Assert.assertEquals(attributeClazz, attributeTwo.getJavaType()); Assert.assertEquals(attributeName, attributeTwo.getName()); }
/** * Gets the json object. * * @param declaredFields * the declared fields * @param embeddableType * the embeddable type * @param embeddedObject * the embedded object * @return the json object */ private static JsonElement getJsonObject(Field[] declaredFields, EmbeddableType embeddableType, Object embeddedObject) { JsonObject jsonObject = new JsonObject(); for (Field field : declaredFields) { if (!ReflectUtils.isTransientOrStatic(field) && !embeddableType.getAttribute(field.getName()).isAssociation()) { Object valueObject = PropertyAccessorHelper.getObject(embeddedObject, field); jsonObject.add(((AbstractAttribute) (embeddableType.getAttribute(field.getName()))).getJPAColumnName(), getJsonPrimitive(valueObject, embeddableType.getAttribute(field.getName()).getJavaType())); } } return jsonObject; }
/** * On embedded columns. * * @param translator * the translator * @param tableInfo * the table info * @param queryBuilder * the query builder * @param compositeEmbeddables * the composite embeddables */ private void onEmbeddedColumns(CQLTranslator translator, TableInfo tableInfo, StringBuilder queryBuilder, List compositeEmbeddables) { List<EmbeddedColumnInfo> embeddedColumns = tableInfo.getEmbeddedColumnMetadatas(); for (EmbeddedColumnInfo embColInfo : embeddedColumns) { if (!compositeEmbeddables.contains(embColInfo.getEmbeddable().getJavaType().getSimpleName())) { String cqlType = CQLTranslator.FROZEN + Constants.STR_LT + Constants.ESCAPE_QUOTE + embColInfo.getEmbeddable().getJavaType().getSimpleName() + Constants.ESCAPE_QUOTE + Constants.STR_GT + translator.COMMA_STR; translator.appendColumnName(queryBuilder, embColInfo.getEmbeddedColumnName(), cqlType); } } }
if (!embeddedColumn.getPersistenceType().equals(PersistenceType.EMBEDDABLE) || compositeEmbeddables.contains(embeddedColumn.getJavaType().getSimpleName())) translator.ensureCase(new StringBuilder(), embeddedColumn.getJavaType().getSimpleName(), false) .toString()); for (Object column : embeddedColumn.getAttributes()) embNametoUDTQuery.put(embeddedColumn.getJavaType().getSimpleName(), typeQueryBuilder.toString()); embNametoDependentList.put(embeddedColumn.getJavaType().getSimpleName(), childEmb);
&& PersistenceType.BASIC.equals(embeddedColumn.getPersistenceType())) .getPersistenceType())) if (PersistenceType.BASIC.equals(embeddedColumn.getPersistenceType()) || PersistenceType.EMBEDDABLE.equals(embeddedColumn .getPersistenceType())) Object targetEmbeddedObj = embeddedColumnClass.newInstance(); Set<Attribute> columns = embeddedColumn.getAttributes(); for (Attribute column : columns)
/** * Assert on embeddable type. * * @param <X> * the generic type * @param entityClazz * the entity clazz * @param attribute * the attribute * @param embeddableType * the embeddable type * @param attributeName * the attribute name * @param attributeClazz * the attribute clazz */ @SuppressWarnings({ "rawtypes", "unchecked" }) private <X> void assertOnEmbeddableType(Class entityClazz, Attribute<X, String> attribute, EmbeddableType<X> embeddableType, String attributeName, Class attributeClazz) { // Assert.assertEquals(entityClazz.getDeclaredFields().length, // embeddableType.getAttributes().size()); Assert.assertEquals(KunderaCoreUtils.countNonSyntheticFields(entityClazz), embeddableType.getAttributes() .size()); Assert.assertEquals(entityClazz, embeddableType.getJavaType()); Attribute attributeTwo = (Attribute) embeddableType.getAttribute(attributeName); Assert.assertNotNull(attribute); Assert.assertEquals(attributeClazz, attributeTwo.getJavaType()); Assert.assertEquals(attributeName, attributeTwo.getName()); }
private void addPrimaryKeyColumnsFromEmbeddable(List<ColumnSchema> columns, EmbeddableType embeddable, Field[] fields, MetamodelImpl metaModel) { for (Field f : fields) { if (!ReflectUtils.isTransientOrStatic(f)) { if (f.getType().isAnnotationPresent(Embeddable.class)) { // nested addPrimaryKeyColumnsFromEmbeddable(columns, (EmbeddableType) metaModel.embeddable(f.getType()), f .getType().getDeclaredFields(), metaModel); } else { Attribute attribute = embeddable.getAttribute(f.getName()); columns.add(new ColumnSchema.ColumnSchemaBuilder( ((AbstractAttribute) attribute).getJPAColumnName(), KuduDBValidationClassMapper .getValidTypeForClass(f.getType())).key(true).build()); } } } }
if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType())) { keyObj = metaModel.embeddable(entityMetadata.getIdAttribute().getBindableJavaType()); key = JAXBUtils.toObject(id, keyObj.getJavaType(), mediaType); } else { ObjectMapper mapper = new ObjectMapper();
/** * Populate partial row for embedded column. * * @param row * the row * @param embeddable * the embeddable * @param EmbEntity * the emb entity * @param metaModel * the meta model */ private void populatePartialRowForEmbeddedColumn(PartialRow row, EmbeddableType embeddable, Object EmbEntity, MetamodelImpl metaModel) { Set<Attribute> attributes = embeddable.getAttributes(); Iterator<Attribute> iterator = attributes.iterator(); iterateAndPopulateRow(row, EmbEntity, metaModel, iterator); }
columns = superColumn.getAttributes(); (BasicDBObject) dbObj, superColumn.getAttributes(), obj); Object fieldValue = PropertyAccessorHelper.getObject(embeddedObject, columnName); Object obj = superColumn.getJavaType().newInstance(); Object embeddedObject = DocumentObjectMapper.getObjectFromDocument(metaModel, (BasicDBObject) embeddedDocumentObject, superColumn.getAttributes(), obj); list.add(embeddedObject);
AbstractAttribute attribute = (AbstractAttribute) keyObj.getAttribute(compositePartitionkeyName); fieldName = fieldName.substring(fieldName.indexOf(".") + 1); attribute = (AbstractAttribute) compositePartitionkey.getAttribute(fieldName); else if (metamodel.isEmbeddable(((AbstractAttribute) keyObj.getAttribute(fieldName)).getBindableJavaType())) { AbstractAttribute attribute = (AbstractAttribute) keyObj.getAttribute(fieldName); Set<Attribute> attributes = metamodel.embeddable(attribute.getBindableJavaType()).getAttributes(); AbstractAttribute attribute = (AbstractAttribute) keyObj.getAttribute(fieldName); String columnName = attribute.getJPAColumnName(); isPresent = buildWhereClause(builder, isPresent, translator, condition, value, useInClause, attribute,
if (metaModel.isEmbeddable(((AbstractAttribute) embeddable.getAttribute(f.getName())) .getBindableJavaType())) prepareCompositeKey((SingularAttribute) embeddable.getAttribute(f.getName()), metaModel, f.get(compositeKey))).append(LUCENE_COMPOSITE_KEY_SEPERATOR);
if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType())) { keyObj = metaModel.embeddable(entityMetadata.getIdAttribute().getBindableJavaType()); key = JAXBUtils.toObject(id, keyObj.getJavaType(), mediaType); } else { ObjectMapper mapper = new ObjectMapper();
/** * Populate embedded column. * * @param entity * the entity * @param result * the result * @param embeddable * the embeddable * @param metaModel * the meta model */ private void populateEmbeddedColumn(Object entity, RowResult result, EmbeddableType embeddable, MetamodelImpl metaModel) { Set<Attribute> attributes = embeddable.getAttributes(); Iterator<Attribute> iterator = attributes.iterator(); iterateAndPopulateEntity(entity, result, metaModel, iterator); }
private GraphQLObjectType getEmbeddableType(EmbeddableType<?> embeddableType) { if (embeddableCache.containsKey(embeddableType)) return embeddableCache.get(embeddableType); String embeddableTypeName = namingStrategy.singularize(embeddableType.getJavaType().getSimpleName())+"EmbeddableType"; GraphQLObjectType objectType = GraphQLObjectType.newObject() .name(embeddableTypeName) .description(getSchemaDescription( embeddableType.getJavaType())) .fields(embeddableType.getAttributes().stream() .filter(this::isNotIgnored) .map(this::getObjectField) .collect(Collectors.toList()) ) .build(); embeddableCache.putIfAbsent(embeddableType, objectType); return objectType; }
CQLTranslator translator, List<Object> value, boolean useInClause, Map<Attribute, List<Object>> columnValues, Field field) { Attribute compositeColumn = keyObj.getAttribute(field.getName()); String jpaColumnName = ((AbstractAttribute) compositeColumn).getJPAColumnName(); .embeddable(((AbstractAttribute) compositeColumn).getBindableJavaType()).getAttributes(); metaModel.embeddable(((AbstractAttribute) compositeColumn).getBindableJavaType()).getAttributes();
/** * Gets the _ id. * * @param field * the field * @param embeddedObject * the embedded object * @param embeddableType * the embeddable type * @param _id * the _id * @return the _ id */ static String get_Id(Field field, Object embeddedObject, EmbeddableType embeddableType, String _id) { Field[] fields = field.getType().getDeclaredFields(); for (Field columnField : fields) { if (!ReflectUtils.isTransientOrStatic(columnField) && !embeddableType.getAttribute(columnField.getName()).isAssociation()) { Object valueObject = PropertyAccessorHelper.getObject(embeddedObject, columnField); _id = _id + PropertyAccessorHelper.getString(valueObject); } } return _id; } }