final AtlasEntity.AtlasEntityWithExtInfo flowPathExt = atlasClient.searchEntityDef(new AtlasObjectId(TYPE_NIFI_FLOW_PATH, ATTR_QUALIFIED_NAME, flowPathQualifiedName)); final AtlasEntity flowPathEntity = flowPathExt.getEntity(); flowPathGuid = flowPathEntity.getGuid(); distinctInputs = toReferenceables(flowPathEntity.getAttribute(ATTR_INPUTS), metrics);
@Test(dependsOnMethods = "testCreate") public void testUpdateEntityWithMap() throws Exception { AtlasEntity tableEntity = new AtlasEntity(tblEntity.getEntity()); AtlasEntitiesWithExtInfo entitiesInfo = new AtlasEntitiesWithExtInfo(tableEntity); Map<String, AtlasStruct> partsMap = new HashMap<>(); col0.setAttribute("table", AtlasTypeUtil.getAtlasObjectId(tableEntity)); AtlasEntityWithExtInfo col0WithExtendedInfo = new AtlasEntityWithExtInfo(col0); col0WithExtendedInfo.addReferredEntity(tableEntity); col0WithExtendedInfo.addReferredEntity(dbEntity.getEntity()); col1.setAttribute("table", AtlasTypeUtil.getAtlasObjectId(tableEntity)); AtlasEntityWithExtInfo col1WithExtendedInfo = new AtlasEntityWithExtInfo(col1); col1WithExtendedInfo.addReferredEntity(tableEntity); col1WithExtendedInfo.addReferredEntity(dbEntity.getEntity()); validateEntity(entitiesInfo, getEntityFromStore(tableDefinition6)); Assert.assertEquals(entityStore.getById(col0.getGuid()).getEntity().getStatus(), AtlasEntity.Status.ACTIVE); Assert.assertEquals(entityStore.getById(col1.getGuid()).getEntity().getStatus(), AtlasEntity.Status.ACTIVE);
@Test(dependsOnMethods = "testCreate") public void testUpdateEntityWithMap() throws Exception { AtlasEntity tableEntity = new AtlasEntity(tblEntity.getEntity()); AtlasEntitiesWithExtInfo entitiesInfo = new AtlasEntitiesWithExtInfo(tableEntity); Map<String, AtlasStruct> partsMap = new HashMap<>(); col0.setAttribute("table", AtlasTypeUtil.getAtlasObjectId(tableEntity)); AtlasEntityWithExtInfo col0WithExtendedInfo = new AtlasEntityWithExtInfo(col0); col0WithExtendedInfo.addReferredEntity(tableEntity); col0WithExtendedInfo.addReferredEntity(dbEntity.getEntity()); col1.setAttribute("table", AtlasTypeUtil.getAtlasObjectId(tableEntity)); AtlasEntityWithExtInfo col1WithExtendedInfo = new AtlasEntityWithExtInfo(col1); col1WithExtendedInfo.addReferredEntity(tableEntity); col1WithExtendedInfo.addReferredEntity(dbEntity.getEntity()); validateEntity(entitiesInfo, getEntityFromStore(tableDefinition6)); Assert.assertEquals(entityStore.getById(col0.getGuid()).getEntity().getStatus(), AtlasEntity.Status.ACTIVE); Assert.assertEquals(entityStore.getById(col1.getGuid()).getEntity().getStatus(), AtlasEntity.Status.ACTIVE);
AtlasObjectId dbObjectId = (AtlasObjectId) tblEntity.getEntity().getAttribute("database"); dbObjectId.setGuid(db1.getGuid()); tblEntity.addReferredEntity(dbEntity.getEntity());
AtlasObjectId dbObjectId = (AtlasObjectId) tblEntity.getEntity().getAttribute("database"); dbObjectId.setGuid(db1.getGuid()); tblEntity.addReferredEntity(dbEntity.getEntity());
}}); AtlasEntityWithExtInfo entityWithExtInfo = new AtlasEntityWithExtInfo(entity);
public static AtlasEntityWithExtInfo createMapAttrEntity() { AtlasEntity entity = new AtlasEntity(ENTITY_TYPE_MAP); Map<String, String> map1 = new HashMap<>(); map1.put("map1Key1", "value1"); map1.put("map1Key2", "value2"); map1.put("map1Key3", "value3"); Map<String, Integer> map2 = new HashMap<>(); map2.put("map2Key1", 100); map2.put("map2Key2", 200); map2.put("map2Key3", 300); Map<String, Boolean> map3 = new HashMap<>(); map3.put("map3Key1", false); map3.put("map3Key2", true); map3.put("map3Key3", false); Map<String, Float> map4 = new HashMap<>(); map4.put("map4Key1", 1.0f); map4.put("map4Key2", 2.0f); map4.put("map4Key3", 3.0f); Map<String, Date> map5 = new HashMap<>(); map5.put("map5Key1", new Date()); map5.put("map5Key2", new Date()); map5.put("map5Key3", new Date()); entity.setAttribute("mapAttr1", map1); entity.setAttribute("mapAttr2", map2); entity.setAttribute("mapAttr3", map3); entity.setAttribute("mapAttr4", map4); entity.setAttribute("mapAttr5", map5); AtlasEntityWithExtInfo ret = new AtlasEntityWithExtInfo(entity); return ret; }
protected AtlasEntityWithExtInfo createOrUpdateTable(String nameSpace, String tableName, AtlasEntity nameSapceEntity, HTableDescriptor htd, HColumnDescriptor[] hcdts) throws Exception { String owner = htd.getOwnerString(); String tblQualifiedName = getTableQualifiedName(clusterName, nameSpace, tableName); AtlasEntityWithExtInfo ret = findTableEntityInAtlas(tblQualifiedName); if (ret == null) { LOG.info("Importing Table: " + tblQualifiedName); AtlasEntity entity = getTableEntity(nameSpace, tableName, owner, nameSapceEntity, htd, null); ret = createEntityInAtlas(new AtlasEntityWithExtInfo(entity)); } else { LOG.info("Table already present in Atlas. Updating it..: " + tblQualifiedName); AtlasEntity entity = getTableEntity(nameSpace, tableName, owner, nameSapceEntity, htd, ret.getEntity()); ret.setEntity(entity); ret = updateEntityInAtlas(ret); } AtlasEntity tableEntity = ret.getEntity(); if (tableEntity != null) { List<AtlasEntityWithExtInfo> cfEntities = createOrUpdateColumnFamilies(nameSpace, tableName, owner, hcdts, tableEntity); List<AtlasObjectId> cfIDs = new ArrayList<>(); if (CollectionUtils.isNotEmpty(cfEntities)) { for (AtlasEntityWithExtInfo cfEntity : cfEntities) { cfIDs.add(AtlasTypeUtil.getAtlasObjectId(cfEntity.getEntity())); } } tableEntity.setAttribute(COLUMN_FAMILIES, cfIDs); } return ret; }
public static AtlasEntityWithExtInfo createComplexCollectionAttrEntity() { AtlasEntity entity = new AtlasEntity(ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR); entity.setAttribute(NAME, ENTITY_TYPE_WITH_COMPLEX_COLLECTION_ATTR); entity.setAttribute("listOfStructs", Arrays.asList(new AtlasStruct("struct_type", "name", "structArray0"), new AtlasStruct("struct_type", "name", "structArray1"), new AtlasStruct("struct_type", "name", "structArray2"))); entity.setAttribute("mapOfStructs", new HashMap<String, AtlasStruct>() {{ put("key0", new AtlasStruct("struct_type", "name", "structMap0")); put("key1", new AtlasStruct("struct_type", "name", "structMap1")); put("key2", new AtlasStruct("struct_type", "name", "structMap2")); }}); AtlasEntity e1Array = new AtlasEntity(ENTITY_TYPE, new HashMap<String, Object>() {{ put(NAME, "entityArray0"); put("isReplicated", true); }}); AtlasEntity e2Array = new AtlasEntity(ENTITY_TYPE, new HashMap<String, Object>() {{ put(NAME, "entityArray1"); put("isReplicated", false); }}); AtlasEntity e3Array = new AtlasEntity(ENTITY_TYPE, new HashMap<String, Object>() {{ put(NAME, "entityArray2"); put("isReplicated", true); }}); entity.setAttribute("listOfEntities", Arrays.asList(getAtlasObjectId(e1Array), getAtlasObjectId(e2Array), getAtlasObjectId(e3Array))); AtlasEntity e1MapValue = new AtlasEntity(ENTITY_TYPE, new HashMap<String, Object>() {{ put(NAME, "entityMapValue0"); put("isReplicated", false); }}); AtlasEntity e2MapValue = new AtlasEntity(ENTITY_TYPE, new HashMap<String, Object>() {{ put(NAME, "entityMapValue1"); put("isReplicated", true); }}); AtlasEntity e3MapValue = new AtlasEntity(ENTITY_TYPE, new HashMap<String, Object>() {{ put(NAME, "entityMapValue2"); put("isReplicated", false); }}); entity.setAttribute("mapOfEntities", new HashMap<String, Object>() {{ put("key0", getAtlasObjectId(e1MapValue)); put("key1", getAtlasObjectId(e2MapValue)); put("key2", getAtlasObjectId(e3MapValue)); }}); AtlasEntityWithExtInfo ret = new AtlasEntityWithExtInfo(entity); ret.addReferredEntity(e1Array); ret.addReferredEntity(e2Array); ret.addReferredEntity(e3Array); ret.addReferredEntity(e1MapValue); ret.addReferredEntity(e2MapValue); ret.addReferredEntity(e3MapValue); return ret; }
protected AtlasEntityWithExtInfo createOrUpdateTable(String nameSpace, String tableName, AtlasEntity nameSapceEntity, HTableDescriptor htd, HColumnDescriptor[] hcdts) throws Exception { String owner = htd.getOwnerString(); String tblQualifiedName = getTableQualifiedName(clusterName, nameSpace, tableName); AtlasEntityWithExtInfo ret = findTableEntityInAtlas(tblQualifiedName); if (ret == null) { LOG.info("Importing Table: " + tblQualifiedName); AtlasEntity entity = getTableEntity(nameSpace, tableName, owner, nameSapceEntity, htd, null); ret = createEntityInAtlas(new AtlasEntityWithExtInfo(entity)); } else { LOG.info("Table already present in Atlas. Updating it..: " + tblQualifiedName); AtlasEntity entity = getTableEntity(nameSpace, tableName, owner, nameSapceEntity, htd, ret.getEntity()); ret.setEntity(entity); ret = updateEntityInAtlas(ret); } AtlasEntity tableEntity = ret.getEntity(); if (tableEntity != null) { List<AtlasEntityWithExtInfo> cfEntities = createOrUpdateColumnFamilies(nameSpace, tableName, owner, hcdts, tableEntity); List<AtlasObjectId> cfIDs = new ArrayList<>(); if (CollectionUtils.isNotEmpty(cfEntities)) { for (AtlasEntityWithExtInfo cfEntity : cfEntities) { cfIDs.add(AtlasTypeUtil.getAtlasObjectId(cfEntity.getEntity())); } } tableEntity.setAttribute(COLUMN_FAMILIES, cfIDs); } return ret; }
@Test public void testInverseReferenceAutoUpdate_NonComposite_OneToMany() throws Exception { AtlasObjectId juliusId = nameIdMap.get("Julius"); // Change Max's Employee.manager reference to Julius and apply the change as a partial update. // This should also update Julius to add Max to the inverse Manager.subordinates reference. AtlasEntity maxEntityForUpdate = new AtlasEntity(TestUtilsV2.EMPLOYEE_TYPE); maxEntityForUpdate.setAttribute("manager", juliusId); AtlasEntityType employeeType = typeRegistry.getEntityTypeByName(TestUtilsV2.EMPLOYEE_TYPE); Map<String, Object> uniqAttributes = Collections.<String, Object>singletonMap("name", "Max"); EntityMutationResponse updateResponse = entityStore.updateByUniqueAttributes(employeeType, uniqAttributes , new AtlasEntityWithExtInfo(maxEntityForUpdate)); List<AtlasEntityHeader> partialUpdatedEntities = updateResponse.getPartialUpdatedEntities(); // 3 entities should have been updated: // * Max to change the Employee.manager reference // * Julius to add Max to Manager.subordinates // * Jane to remove Max from Manager.subordinates assertEquals(partialUpdatedEntities.size(), 3); AtlasObjectId maxId = nameIdMap.get("Max"); String janeGuid = nameIdMap.get("Jane").getGuid(); AtlasEntitiesWithExtInfo storedEntities = entityStore.getByIds(ImmutableList.of(maxId.getGuid(), juliusId.getGuid(), janeGuid)); AtlasEntity storedEntity = storedEntities.getEntity(maxId.getGuid()); verifyReferenceValue(storedEntity, "manager", juliusId.getGuid()); storedEntity = storedEntities.getEntity(juliusId.getGuid()); verifyReferenceList(storedEntity, "subordinates", ImmutableList.of(maxId)); storedEntity = storedEntities.getEntity(janeGuid); verify_testInverseReferenceAutoUpdate_NonComposite_OneToMany(storedEntity); }
private void processEntity(String guid, ExportContext context) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> processEntity({})", guid); } if (!context.guidsProcessed.contains(guid)) { TraversalDirection direction = context.guidDirection.get(guid); AtlasEntityWithExtInfo entityWithExtInfo = entityGraphRetriever.toAtlasEntityWithExtInfo(guid); if(!context.lineageProcessed.contains(guid)) { context.result.getData().getEntityCreationOrder().add(entityWithExtInfo.getEntity().getGuid()); } addEntity(entityWithExtInfo, context); addTypes(entityWithExtInfo.getEntity(), context); context.guidsProcessed.add(entityWithExtInfo.getEntity().getGuid()); getConntedEntitiesBasedOnOption(entityWithExtInfo.getEntity(), context, direction); if(entityWithExtInfo.getReferredEntities() != null) { for (AtlasEntity e : entityWithExtInfo.getReferredEntities().values()) { addTypes(e, context); getConntedEntitiesBasedOnOption(e, context, direction); } context.guidsProcessed.addAll(entityWithExtInfo.getReferredEntities().keySet()); } } if (LOG.isDebugEnabled()) { LOG.debug("<== processEntity({})", guid); } }
@Test public void testInverseReferenceAutoUpdate_NonComposite_OneToMany() throws Exception { AtlasObjectId juliusId = nameIdMap.get("Julius"); // Change Max's Employee.manager reference to Julius and apply the change as a partial update. // This should also update Julius to add Max to the inverse Manager.subordinates reference. AtlasEntity maxEntityForUpdate = new AtlasEntity(TestUtilsV2.EMPLOYEE_TYPE); maxEntityForUpdate.setAttribute("manager", juliusId); AtlasEntityType employeeType = typeRegistry.getEntityTypeByName(TestUtilsV2.EMPLOYEE_TYPE); Map<String, Object> uniqAttributes = Collections.<String, Object>singletonMap("name", "Max"); EntityMutationResponse updateResponse = entityStore.updateByUniqueAttributes(employeeType, uniqAttributes , new AtlasEntityWithExtInfo(maxEntityForUpdate)); List<AtlasEntityHeader> partialUpdatedEntities = updateResponse.getPartialUpdatedEntities(); // 3 entities should have been updated: // * Max to change the Employee.manager reference // * Julius to add Max to Manager.subordinates // * Jane to remove Max from Manager.subordinates assertEquals(partialUpdatedEntities.size(), 3); AtlasObjectId maxId = nameIdMap.get("Max"); String janeGuid = nameIdMap.get("Jane").getGuid(); AtlasEntitiesWithExtInfo storedEntities = entityStore.getByIds(ImmutableList.of(maxId.getGuid(), juliusId.getGuid(), janeGuid)); AtlasEntity storedEntity = storedEntities.getEntity(maxId.getGuid()); verifyReferenceValue(storedEntity, "manager", juliusId.getGuid()); storedEntity = storedEntities.getEntity(juliusId.getGuid()); verifyReferenceList(storedEntity, "subordinates", ImmutableList.of(maxId)); storedEntity = storedEntities.getEntity(janeGuid); verify_testInverseReferenceAutoUpdate_NonComposite_OneToMany(storedEntity); }
@Override @GraphTransaction public SchemaDetails getSchemaForHiveTableByGuid(final String guid) throws AtlasBaseException { if (StringUtils.isEmpty(guid)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST); } SchemaDetails ret = new SchemaDetails(); AtlasEntityType hive_column = atlasTypeRegistry.getEntityTypeByName("hive_column"); ret.setDataType(AtlasTypeUtil.toClassTypeDefinition(hive_column)); AtlasEntityWithExtInfo entityWithExtInfo = entityRetriever.toAtlasEntityWithExtInfo(guid); AtlasEntity entity = entityWithExtInfo.getEntity(); AtlasAuthorizationUtils.verifyAccess(new AtlasEntityAccessRequest(atlasTypeRegistry, AtlasPrivilege.ENTITY_READ, new AtlasEntityHeader(entity)), "read entity schema: guid=", guid); Map<String, AtlasEntity> referredEntities = entityWithExtInfo.getReferredEntities(); List<String> columnIds = getColumnIds(entity); if (MapUtils.isNotEmpty(referredEntities)) { List<Map<String, Object>> rows = referredEntities.entrySet() .stream() .filter(e -> isColumn(columnIds, e)) .map(e -> AtlasTypeUtil.toMap(e.getValue())) .collect(Collectors.toList()); ret.setRows(rows); } return ret; }
protected List<AtlasEntityWithExtInfo> createOrUpdateColumnFamilies(String nameSpace, String tableName, String owner, HColumnDescriptor[] hcdts , AtlasEntity tableEntity) throws Exception { List<AtlasEntityWithExtInfo > ret = new ArrayList<>(); if (hcdts != null) { AtlasObjectId tableId = AtlasTypeUtil.getAtlasObjectId(tableEntity); for (HColumnDescriptor columnFamilyDescriptor : hcdts) { String cfName = columnFamilyDescriptor.getNameAsString(); String cfQualifiedName = getColumnFamilyQualifiedName(clusterName, nameSpace, tableName, cfName); AtlasEntityWithExtInfo cfEntity = findColumnFamiltyEntityInAtlas(cfQualifiedName); if (cfEntity == null) { LOG.info("Importing Column-family: " + cfQualifiedName); AtlasEntity entity = getColumnFamilyEntity(nameSpace, tableName, owner, columnFamilyDescriptor, tableId, null); cfEntity = createEntityInAtlas(new AtlasEntityWithExtInfo(entity)); } else { LOG.info("ColumnFamily already present in Atlas. Updating it..: " + cfQualifiedName); AtlasEntity entity = getColumnFamilyEntity(nameSpace, tableName, owner, columnFamilyDescriptor, tableId, cfEntity.getEntity()); cfEntity.setEntity(entity); cfEntity = updateEntityInAtlas(cfEntity); } ret.add(cfEntity); } } return ret; }
protected List<AtlasEntityWithExtInfo> createOrUpdateColumnFamilies(String nameSpace, String tableName, String owner, HColumnDescriptor[] hcdts , AtlasEntity tableEntity) throws Exception { List<AtlasEntityWithExtInfo > ret = new ArrayList<>(); if (hcdts != null) { AtlasObjectId tableId = AtlasTypeUtil.getAtlasObjectId(tableEntity); for (HColumnDescriptor columnFamilyDescriptor : hcdts) { String cfName = columnFamilyDescriptor.getNameAsString(); String cfQualifiedName = getColumnFamilyQualifiedName(clusterName, nameSpace, tableName, cfName); AtlasEntityWithExtInfo cfEntity = findColumnFamiltyEntityInAtlas(cfQualifiedName); if (cfEntity == null) { LOG.info("Importing Column-family: " + cfQualifiedName); AtlasEntity entity = getColumnFamilyEntity(nameSpace, tableName, owner, columnFamilyDescriptor, tableId, null); cfEntity = createEntityInAtlas(new AtlasEntityWithExtInfo(entity)); } else { LOG.info("ColumnFamily already present in Atlas. Updating it..: " + cfQualifiedName); AtlasEntity entity = getColumnFamilyEntity(nameSpace, tableName, owner, columnFamilyDescriptor, tableId, cfEntity.getEntity()); cfEntity.setEntity(entity); cfEntity = updateEntityInAtlas(cfEntity); } ret.add(cfEntity); } } return ret; }
public static AtlasEntityWithExtInfo createTableEntityV2(AtlasEntity dbEntity) { AtlasEntity tblEntity = new AtlasEntity(TABLE_TYPE); tblEntity.setAttribute(NAME, RandomStringUtils.randomAlphanumeric(10)); tblEntity.setAttribute("description", "random table"); tblEntity.setAttribute("type", "type"); tblEntity.setAttribute("tableType", "MANAGED"); tblEntity.setAttribute("database", getAtlasObjectId(dbEntity)); tblEntity.setAttribute("created", new Date()); final AtlasStruct partitionStruct = new AtlasStruct("partition_struct_type", "name", "part0"); tblEntity.setAttribute("partitions", new ArrayList<AtlasStruct>() {{ add(partitionStruct); }}); tblEntity.setAttribute("partitionsMap", new HashMap<String, AtlasStruct>() {{ put("part0", new AtlasStruct("partition_struct_type", "name", "part0")); put("part1", new AtlasStruct("partition_struct_type", "name", "part1")); put("part2", new AtlasStruct("partition_struct_type", "name", "part2")); }}); tblEntity.setAttribute("parametersMap", new java.util.HashMap<String, String>() {{ put("key1", "value1"); }}); AtlasEntityWithExtInfo ret = new AtlasEntityWithExtInfo(tblEntity); ret.addReferredEntity(dbEntity); return ret; }
@VisibleForTesting AtlasEntityWithExtInfo updateEntityInAtlas(AtlasEntityWithExtInfo entity) throws Exception { AtlasEntityWithExtInfo ret = null; EntityMutationResponse response = atlasClientV2.updateEntity(entity); if (response != null) { List<AtlasEntityHeader> entities = response.getUpdatedEntities(); if (CollectionUtils.isNotEmpty(entities)) { AtlasEntityWithExtInfo getByGuidResponse = atlasClientV2.getEntityByGuid(entities.get(0).getGuid()); ret = getByGuidResponse; LOG.info("Updated {} entity: name={}, guid={} ", ret.getEntity().getTypeName(), ret.getEntity().getAttribute(ATTRIBUTE_QUALIFIED_NAME), ret.getEntity().getGuid()); } else { LOG.info("Entity: name={} ", entity.toString() + " not updated as it is unchanged from what is in Atlas" ); ret = entity; } } else { LOG.info("Entity: name={} ", entity.toString() + " not updated as it is unchanged from what is in Atlas" ); ret = entity; } return ret; }
private AtlasEntityWithExtInfo updateEntityInAtlas(AtlasEntityWithExtInfo entity) throws Exception { AtlasEntityWithExtInfo ret = null; EntityMutationResponse response = atlasClientV2.updateEntity(entity); if (response != null) { List<AtlasEntityHeader> entities = response.getUpdatedEntities(); if (CollectionUtils.isNotEmpty(entities)) { AtlasEntityWithExtInfo getByGuidResponse = atlasClientV2.getEntityByGuid(entities.get(0).getGuid()); ret = getByGuidResponse; LOG.info("Updated {} entity: name={}, guid={} ", ret.getEntity().getTypeName(), ret.getEntity().getAttribute(ATTRIBUTE_QUALIFIED_NAME), ret.getEntity().getGuid()); } else { LOG.info("Entity: name={} ", entity.toString() + " not updated as it is unchanged from what is in Atlas" ); ret = entity; } } else { LOG.info("Entity: name={} ", entity.toString() + " not updated as it is unchanged from what is in Atlas" ); ret = entity; } return ret; }
private AtlasEntityWithExtInfo updateEntityInAtlas(AtlasEntityWithExtInfo entity) throws Exception { AtlasEntityWithExtInfo ret = null; EntityMutationResponse response = atlasClientV2.updateEntity(entity); if (response != null) { List<AtlasEntityHeader> entities = response.getUpdatedEntities(); if (CollectionUtils.isNotEmpty(entities)) { AtlasEntityWithExtInfo getByGuidResponse = atlasClientV2.getEntityByGuid(entities.get(0).getGuid()); ret = getByGuidResponse; LOG.info("Updated {} entity: name={}, guid={} ", ret.getEntity().getTypeName(), ret.getEntity().getAttribute(ATTRIBUTE_QUALIFIED_NAME), ret.getEntity().getGuid()); } else { LOG.info("Entity: name={} ", entity.toString() + " not updated as it is unchanged from what is in Atlas" ); ret = entity; } } else { LOG.info("Entity: name={} ", entity.toString() + " not updated as it is unchanged from what is in Atlas" ); ret = entity; } return ret; }