|
|
@ -173,11 +173,9 @@ public final class TagService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public QueryTemplate untaggedTemplate() {
|
|
|
|
public QueryTemplate untaggedTemplate() {
|
|
|
|
String[] emergentTags = getEmergentTagIds();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new QueryTemplate().where(Criterion.and(
|
|
|
|
return new QueryTemplate().where(Criterion.and(
|
|
|
|
Criterion.not(Task.UUID.in(Query.select(TaskToTagMetadata.TASK_UUID).from(Metadata.TABLE)
|
|
|
|
Criterion.not(Task.UUID.in(Query.select(TaskToTagMetadata.TASK_UUID).from(Metadata.TABLE)
|
|
|
|
.where(Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY), Metadata.DELETION_DATE.eq(0), Criterion.not(TaskToTagMetadata.TAG_UUID.in(emergentTags)))))),
|
|
|
|
.where(Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY), Metadata.DELETION_DATE.eq(0))))),
|
|
|
|
TaskCriteria.isActive(),
|
|
|
|
TaskCriteria.isActive(),
|
|
|
|
TaskApiDao.TaskCriteria.ownedByMe(),
|
|
|
|
TaskApiDao.TaskCriteria.ownedByMe(),
|
|
|
|
TaskCriteria.isVisible()));
|
|
|
|
TaskCriteria.isVisible()));
|
|
|
@ -191,12 +189,8 @@ public final class TagService {
|
|
|
|
* @return empty array if no tags, otherwise array
|
|
|
|
* @return empty array if no tags, otherwise array
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
@Deprecated
|
|
|
|
public Tag[] getGroupedTags(Order order, Criterion activeStatus, boolean includeEmergent) {
|
|
|
|
public Tag[] getGroupedTags(Order order, Criterion activeStatus) {
|
|
|
|
Criterion criterion;
|
|
|
|
Criterion criterion = Criterion.and(activeStatus, MetadataCriteria.withKey(TaskToTagMetadata.KEY));
|
|
|
|
if (includeEmergent)
|
|
|
|
|
|
|
|
criterion = Criterion.and(activeStatus, MetadataCriteria.withKey(TaskToTagMetadata.KEY));
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
criterion = Criterion.and(activeStatus, MetadataCriteria.withKey(TaskToTagMetadata.KEY), Criterion.not(TaskToTagMetadata.TAG_UUID.in(getEmergentTagIds())));
|
|
|
|
|
|
|
|
Query query = Query.select(TaskToTagMetadata.TAG_NAME, TaskToTagMetadata.TAG_UUID, COUNT).
|
|
|
|
Query query = Query.select(TaskToTagMetadata.TAG_NAME, TaskToTagMetadata.TAG_UUID, COUNT).
|
|
|
|
join(Join.inner(Task.TABLE, Metadata.TASK.eq(Task.ID))).
|
|
|
|
join(Join.inner(Task.TABLE, Metadata.TASK.eq(Task.ID))).
|
|
|
|
where(criterion).
|
|
|
|
where(criterion).
|
|
|
@ -216,25 +210,6 @@ public final class TagService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String[] getEmergentTagIds() {
|
|
|
|
|
|
|
|
TodorooCursor<TagData> emergent = tagDataService.query(Query.select(TagData.UUID)
|
|
|
|
|
|
|
|
.where(Functions.bitwiseAnd(TagData.FLAGS, TagData.FLAG_EMERGENT).gt(0)));
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
ArrayList<String> tags = new ArrayList<String>();
|
|
|
|
|
|
|
|
TagData data = new TagData();
|
|
|
|
|
|
|
|
for (int i = 0; i < emergent.getCount(); i++) {
|
|
|
|
|
|
|
|
emergent.moveToPosition(i);
|
|
|
|
|
|
|
|
data.readFromCursor(emergent);
|
|
|
|
|
|
|
|
String uuid = data.getValue(TagData.UUID);
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(uuid) && !"0".equals(uuid))
|
|
|
|
|
|
|
|
tags.add(uuid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return tags.toArray(new String[tags.size()]);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
emergent.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void createLink(Task task, String tagName) {
|
|
|
|
public void createLink(Task task, String tagName) {
|
|
|
|
TodorooCursor<TagData> existingTag = tagDataService.query(Query.select(TagData.NAME, TagData.UUID)
|
|
|
|
TodorooCursor<TagData> existingTag = tagDataService.query(Query.select(TagData.NAME, TagData.UUID)
|
|
|
|
.where(TagData.NAME.eqCaseInsensitive(tagName)));
|
|
|
|
.where(TagData.NAME.eqCaseInsensitive(tagName)));
|
|
|
@ -338,28 +313,20 @@ public final class TagService {
|
|
|
|
* @param taskId
|
|
|
|
* @param taskId
|
|
|
|
* @return cursor. PLEASE CLOSE THE CURSOR!
|
|
|
|
* @return cursor. PLEASE CLOSE THE CURSOR!
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public TodorooCursor<Metadata> getTags(long taskId, boolean includeEmergent) {
|
|
|
|
public TodorooCursor<Metadata> getTags(long taskId) {
|
|
|
|
Criterion criterion;
|
|
|
|
Criterion criterion = Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY),
|
|
|
|
if (includeEmergent)
|
|
|
|
|
|
|
|
criterion = Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY),
|
|
|
|
|
|
|
|
Metadata.DELETION_DATE.eq(0),
|
|
|
|
Metadata.DELETION_DATE.eq(0),
|
|
|
|
MetadataCriteria.byTask(taskId));
|
|
|
|
MetadataCriteria.byTask(taskId));
|
|
|
|
else
|
|
|
|
|
|
|
|
criterion = Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY),
|
|
|
|
|
|
|
|
Metadata.DELETION_DATE.eq(0),
|
|
|
|
|
|
|
|
MetadataCriteria.byTask(taskId), Criterion.not(TaskToTagMetadata.TAG_UUID.in(getEmergentTagIds())));
|
|
|
|
|
|
|
|
Query query = Query.select(TaskToTagMetadata.TAG_NAME, TaskToTagMetadata.TAG_UUID).where(criterion).orderBy(Order.asc(Functions.upper(TaskToTagMetadata.TAG_NAME)));
|
|
|
|
Query query = Query.select(TaskToTagMetadata.TAG_NAME, TaskToTagMetadata.TAG_UUID).where(criterion).orderBy(Order.asc(Functions.upper(TaskToTagMetadata.TAG_NAME)));
|
|
|
|
return metadataDao.query(query);
|
|
|
|
return metadataDao.query(query);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public TodorooCursor<TagData> getTagDataForTask(long taskId, boolean includeEmergent, Property<?>... properties) {
|
|
|
|
public TodorooCursor<TagData> getTagDataForTask(long taskId, Property<?>... properties) {
|
|
|
|
Criterion criterion = TagData.UUID.in(Query.select(TaskToTagMetadata.TAG_UUID)
|
|
|
|
Criterion criterion = TagData.UUID.in(Query.select(TaskToTagMetadata.TAG_UUID)
|
|
|
|
.from(Metadata.TABLE)
|
|
|
|
.from(Metadata.TABLE)
|
|
|
|
.where(Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY),
|
|
|
|
.where(Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY),
|
|
|
|
Metadata.DELETION_DATE.eq(0),
|
|
|
|
Metadata.DELETION_DATE.eq(0),
|
|
|
|
Metadata.TASK.eq(taskId))));
|
|
|
|
Metadata.TASK.eq(taskId))));
|
|
|
|
if (!includeEmergent)
|
|
|
|
|
|
|
|
criterion = Criterion.and(Criterion.not(TagData.UUID.in(getEmergentTagIds())), criterion);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return tagDataService.query(Query.select(properties).where(criterion));
|
|
|
|
return tagDataService.query(Query.select(properties).where(criterion));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -377,8 +344,8 @@ public final class TagService {
|
|
|
|
* @param taskId
|
|
|
|
* @param taskId
|
|
|
|
* @return empty string if no tags, otherwise string
|
|
|
|
* @return empty string if no tags, otherwise string
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public String getTagsAsString(long taskId, boolean includeEmergent) {
|
|
|
|
public String getTagsAsString(long taskId) {
|
|
|
|
return getTagsAsString(taskId, ", ", includeEmergent);
|
|
|
|
return getTagsAsString(taskId, ", ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -387,9 +354,9 @@ public final class TagService {
|
|
|
|
* @param taskId
|
|
|
|
* @param taskId
|
|
|
|
* @return empty string if no tags, otherwise string
|
|
|
|
* @return empty string if no tags, otherwise string
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public String getTagsAsString(long taskId, String separator, boolean includeEmergent) {
|
|
|
|
public String getTagsAsString(long taskId, String separator) {
|
|
|
|
StringBuilder tagBuilder = new StringBuilder();
|
|
|
|
StringBuilder tagBuilder = new StringBuilder();
|
|
|
|
TodorooCursor<Metadata> tags = getTags(taskId, includeEmergent);
|
|
|
|
TodorooCursor<Metadata> tags = getTags(taskId);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
int length = tags.getCount();
|
|
|
|
int length = tags.getCount();
|
|
|
|
Metadata metadata = new Metadata();
|
|
|
|
Metadata metadata = new Metadata();
|
|
|
@ -437,7 +404,7 @@ public final class TagService {
|
|
|
|
for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
|
|
|
|
for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
|
|
|
|
tagData.readFromCursor(cursor);
|
|
|
|
tagData.readFromCursor(cursor);
|
|
|
|
Tag tag = new Tag(tagData);
|
|
|
|
Tag tag = new Tag(tagData);
|
|
|
|
if(tagData.getValue(TagData.DELETION_DATE) > 0 || tagData.getFlag(TagData.FLAGS, TagData.FLAG_EMERGENT) || tagData.getFlag(TagData.FLAGS, TagData.FLAG_FEATURED)) {
|
|
|
|
if(tagData.getValue(TagData.DELETION_DATE) > 0 || tagData.getFlag(TagData.FLAGS, TagData.FLAG_FEATURED)) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(TextUtils.isEmpty(tag.tag))
|
|
|
|
if(TextUtils.isEmpty(tag.tag))
|
|
|
|