// public abstract List<IGroupTag> getGroupTags(); /// <summary> /// Clears existing counts and searches the complete collection to get current counts /// </summary> /// <param name="groups">The groups.</param> /// <param name="dbCollection">The database collection.</param> public void setGroupCounts(IGroupTagCollection tags = null) { clearCounts(); countHasGroup = 0; countNoGroup = 0; setGroupBorders(); string name = ""; // List<IGroupTag> items = dbCollection.selectItemsAll(); if (tags == null) { aceLog.log("Failed to recount the sample data set because no group tags were specified"); } else { foreach (IGroupTag item in tags) { if (collectionExtensions.isNullOrEmpty(name)) { name = item.GetType().Name; } // String groupTags = //item.imbGetPropertySafe(db_groupTagFieldName, "").toStringSafe(); countTags(item.groupTags); } } countedCollectionName = name; }
//public IRelationEnabledCollection getCollectionGroup(IRelationEnabledCollection collection, sampleGroupItem groupItem) //{ // IRelationEnabledCollection relationEnabled = collection.selectItems<> //} /// <summary> /// Sets the groups to collection according to policy and defined groups in this set. It will call <see cref="setGroupCounts(IRelationEnabledCollection)"/> if <see cref="isCountCalledYet"/> is <c>false</c> /// </summary> /// <param name="collection">The collection.</param> /// <param name="policy">The policy.</param> public void setGroupsToCollection(IGroupTagCollection collection, sampleGroupAssignPolicy policy) { if (!isCountCalledYet) { setGroupCounts(collection); } List <IGroupTag> items = new List <IGroupTag>(); sampleGroupItem group = pickRandomGroup(); switch (policy) { case sampleGroupAssignPolicy.unassignAll: items.AddRange(collection.Where <IGroupTag>(x => !x.groupTags.isNullOrEmpty())); // .selectItems(db_groupTagFieldName + " != '' AND " + db_groupTagFieldName + " IS NOT NULL", -1, selectItemsMode.sqlWhere, selectItemsResultType.managed); break; case sampleGroupAssignPolicy.onlyNonAssigned: items.AddRange(collection.Where <IGroupTag>(x => x.groupTags.isNullOrEmpty())); // = collection.selectItems(db_groupTagFieldName + " = '' OR " + db_groupTagFieldName + " IS NULL", -1, selectItemsMode.sqlWhere, selectItemsResultType.managed); break; case sampleGroupAssignPolicy.overAssignAll: case sampleGroupAssignPolicy.reAssignAll: items.AddRange((IEnumerable <IGroupTag>)collection); break; default: return; break; } string tagline = ""; foreach (IGroupTag item in items) { switch (policy) { case sampleGroupAssignPolicy.overAssignAll: group = pickRandomGroup(); tagline = item.imbGetPropertySafe(db_groupTagFieldName).toStringSafe(); if (!item.groupTags.Contains(group.groupTag)) { item.groupTags = item.groupTags.add(group.groupTag, ","); } //if (!tagline.Contains(group.groupTag)) tagline = tagline.add(group.groupTag, ","); break; case sampleGroupAssignPolicy.onlyNonAssigned: group = pickRandomGroup(); item.groupTags = item.groupTags.add(group.groupTag, ","); group.count++; break; case sampleGroupAssignPolicy.reAssignAll: group = pickRandomGroup(); item.groupTags = group.groupTag; //.groupTag, ","); //tagline = item.imbGetPropertySafe(db_groupTagFieldName).toStringSafe(); // countTags(tagline, true); //item.imbSetPropertySafe(db_groupTagFieldName, group.groupTag); group.count++; break; case sampleGroupAssignPolicy.unassignAll: item.groupTags = ""; break; } // item.updateRowAll(true); //item.setModified(); //item.saveItem(true); } // collection.saveItems(true, true); }