public IReadOnlyList <AttributeHolder> Get([NotNull] EntityMetadata entityMetadata, long rowstamp, SearchRequestDto searchDto = null) { if (entityMetadata == null) { throw new ArgumentNullException("entityMetadata"); } if (searchDto == null) { searchDto = new SearchRequestDto(); } var query = new EntityQueryBuilder().AllRows(entityMetadata, searchDto); if (searchDto.QueryGeneratorService != null && entityMetadata is SlicedEntityMetadata) { var sliced = (SlicedEntityMetadata)entityMetadata; var customQuery = GenericSwMethodInvoker.Invoke <string>(sliced.AppSchema, searchDto.QueryGeneratorService, entityMetadata, searchDto); if (customQuery != null) { query.Sql = customQuery; } } var rows = Query(entityMetadata, query, rowstamp, searchDto); return(rows.Cast <IEnumerable <KeyValuePair <string, object> > >() .Select(r => BuildDataMap(entityMetadata, r)) .ToList()); }
public int Count([NotNull] EntityMetadata entityMetadata, [NotNull] SearchRequestDto searchDto) { if (entityMetadata == null) { throw new ArgumentNullException("entityMetadata"); } if (searchDto == null) { throw new ArgumentNullException("searchDto"); } var query = new EntityQueryBuilder().CountRows(entityMetadata, searchDto); if (searchDto.QueryGeneratorService != null && entityMetadata is SlicedEntityMetadata) { var sliced = (SlicedEntityMetadata)entityMetadata; var customQuery = GenericSwMethodInvoker.Invoke <string>(sliced.AppSchema, searchDto.QueryGeneratorService + "Count", entityMetadata, searchDto); if (customQuery != null) { query.Sql = customQuery; } } return(GetDao(entityMetadata).CountByNativeQuery(query.Sql, query.Parameters, searchDto.QueryAlias)); }
public IList <IEnumerable <KeyValuePair <string, object> > > GetSynchronizationData(SlicedEntityMetadata entityMetadata, Rowstamps rowstamps) { var query = new EntityQueryBuilder().AllRowsForSync(entityMetadata, rowstamps); //TODO: hack to avoid garbage data and limit size of list queries. var sql = query.Sql; var queryResult = GetDao(entityMetadata).FindByNativeQuery(sql, query.Parameters); var rows = queryResult.Cast <IEnumerable <KeyValuePair <string, object> > >(); return(rows as IList <IEnumerable <KeyValuePair <string, object> > > ?? rows.ToList()); }
public IEnumerable <dynamic> RawGet([NotNull] EntityMetadata entityMetadata, [NotNull] SearchRequestDto searchDto) { if (entityMetadata == null) { throw new ArgumentNullException("entityMetadata"); } if (searchDto == null) { throw new ArgumentNullException("searchDto"); } var query = new EntityQueryBuilder().AllRows(entityMetadata, searchDto); var rows = Query(entityMetadata, query, searchDto); return(rows); }
public AttributeHolder Get([NotNull] EntityMetadata entityMetadata, [NotNull] string id) { //TODO: we're always handling the entity ID as a string. //Maybe we should leverage the entity attribute type. if (entityMetadata == null) { throw new ArgumentNullException("entityMetadata"); } if (id == null) { throw new ArgumentNullException("id"); } var query = new EntityQueryBuilder().ById(entityMetadata, id); var rows = Query(entityMetadata, query, new SearchRequestDto()); return(rows.Cast <IEnumerable <KeyValuePair <string, object> > >() .Select(r => BuildDataMap(entityMetadata, r)) .ToList().FirstOrDefault()); }
//needed to avoid "Fields" nesting in collectionData public SearchEntityResult GetAsRawDictionary([NotNull] EntityMetadata entityMetadata, [NotNull] SearchRequestDto searchDto, Boolean fetchMaxRowstamp = false) { if (entityMetadata == null) { throw new ArgumentNullException("entityMetadata"); } if (searchDto == null) { throw new ArgumentNullException("searchDto"); } var query = new EntityQueryBuilder().AllRows(entityMetadata, searchDto); var rows = Query(entityMetadata, query, searchDto); var enumerable = rows as dynamic[] ?? rows.ToArray(); Log.DebugFormat("returning {0} rows", enumerable.Count()); long?maxRowstamp = 0; IList <Dictionary <string, object> > list = new List <Dictionary <string, object> >(); foreach (var row in enumerable) { var dict = (IDictionary <string, object>)row; var item = new Dictionary <string, object>(); if (fetchMaxRowstamp) { if (dict.ContainsKey(RowStampUtil.RowstampColumnName)) { var rowstamp = RowStampUtil.Convert(dict[RowStampUtil.RowstampColumnName]); if (rowstamp > maxRowstamp) { maxRowstamp = rowstamp; } } } foreach (var column in dict) { item[FixKey(column.Key, entityMetadata)] = column.Value; } if (entityMetadata.Name == "relatedrecord") { item["hmachash"] = AuthUtils.HmacShaEncode(item["relatedreckey"].ToString()); } else if (entityMetadata.Name == "ticket" || entityMetadata.Name == "imac") { item["hmachash"] = AuthUtils.HmacShaEncode(item["ticketid"].ToString()); } else if (entityMetadata.IdFieldName != null && item.ContainsKey(entityMetadata.IdFieldName)) { //for compositions in general item["hmachash"] = AuthUtils.HmacShaEncode(item[entityMetadata.IdFieldName].ToString()); } list.Add(item); } return(new SearchEntityResult { MaxRowstampReturned = maxRowstamp == 0 ? null : maxRowstamp, ResultList = list, IdFieldName = entityMetadata.IdFieldName }); }