Commit 2789bde6 authored by Elias Englmeier's avatar Elias Englmeier
Browse files

added a few functions to accomodate tagging

parent 1eb38d30
......@@ -119,6 +119,10 @@ public interface TagDataLocalService extends BaseLocalService,
@Indexable(type = IndexableType.REINDEX)
public TagData updateTagData(TagData tagData);
/**
* Can be used to check for duplicate strings in the Tag table
* returns true if new tag is already present
*/
public boolean findTagData(java.lang.String tag);
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
......@@ -209,6 +213,10 @@ public interface TagDataLocalService extends BaseLocalService,
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public List<TagData> getTagDatas(int start, int end);
/**
* adds Tag String to the Tag table
* auto increments the Tag ID - PK
*/
public long addNewTag(java.lang.String tag);
/**
......@@ -228,4 +236,7 @@ public interface TagDataLocalService extends BaseLocalService,
*/
public long dynamicQueryCount(DynamicQuery dynamicQuery,
Projection projection);
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public long getTagIdByTagName(java.lang.String name);
}
\ No newline at end of file
......@@ -113,6 +113,10 @@ public class TagDataLocalServiceUtil {
return getService().updateTagData(tagData);
}
/**
* Can be used to check for duplicate strings in the Tag table
* returns true if new tag is already present
*/
public static boolean findTagData(java.lang.String tag) {
return getService().findTagData(tag);
}
......@@ -228,6 +232,10 @@ public class TagDataLocalServiceUtil {
return getService().getTagDatas(start, end);
}
/**
* adds Tag String to the Tag table
* auto increments the Tag ID - PK
*/
public static long addNewTag(java.lang.String tag) {
return getService().addNewTag(tag);
}
......@@ -256,6 +264,10 @@ public class TagDataLocalServiceUtil {
return getService().dynamicQueryCount(dynamicQuery, projection);
}
public static long getTagIdByTagName(java.lang.String name) {
return getService().getTagIdByTagName(name);
}
public static TagDataLocalService getService() {
return _serviceTracker.getService();
}
......
......@@ -110,6 +110,10 @@ public class TagDataLocalServiceWrapper implements TagDataLocalService,
return _tagDataLocalService.updateTagData(tagData);
}
/**
* Can be used to check for duplicate strings in the Tag table
* returns true if new tag is already present
*/
@Override
public boolean findTagData(java.lang.String tag) {
return _tagDataLocalService.findTagData(tag);
......@@ -237,6 +241,10 @@ public class TagDataLocalServiceWrapper implements TagDataLocalService,
return _tagDataLocalService.getTagDatas(start, end);
}
/**
* adds Tag String to the Tag table
* auto increments the Tag ID - PK
*/
@Override
public long addNewTag(java.lang.String tag) {
return _tagDataLocalService.addNewTag(tag);
......@@ -268,6 +276,11 @@ public class TagDataLocalServiceWrapper implements TagDataLocalService,
return _tagDataLocalService.dynamicQueryCount(dynamicQuery, projection);
}
@Override
public long getTagIdByTagName(java.lang.String name) {
return _tagDataLocalService.getTagIdByTagName(name);
}
@Override
public TagDataLocalService getWrappedService() {
return _tagDataLocalService;
......
......@@ -14,6 +14,8 @@
package analysisService.service.impl;
import java.util.List;
import analysisService.exception.NoSuchTagDataException;
import analysisService.model.TagData;
import analysisService.model.impl.TagDataImpl;
......@@ -48,11 +50,11 @@ public class TagDataLocalServiceImpl extends TagDataLocalServiceBaseImpl {
public long addNewTag(String tag){
TagData newTagData = new TagDataImpl();
newTagData.setTag(tag);
TagDataLocalServiceUtil.addTagData(newTagData);
return newTagData.getPrimaryKey();
}
/**
* Can be used to check for duplicate strings in the Tag table
* returns true if new tag is already present
......@@ -65,4 +67,14 @@ public class TagDataLocalServiceImpl extends TagDataLocalServiceBaseImpl {
}
return true;
}
public long getTagIdByTagName (String name){
List<TagData> allTags = TagDataUtil.findAll();
for(TagData d : allTags){
if(d.getTag().equals(name)){
return d.getPrimaryKey();
}
}
return -1;
}
}
\ No newline at end of file
......@@ -13,6 +13,6 @@
##
build.namespace=ANALYSIS
build.number=72
build.date=1515488544544
build.number=76
build.date=1515677473549
build.auto.upgrade=true
\ No newline at end of file
......@@ -13,6 +13,6 @@
##
build.namespace=GB
build.number=93
build.date=1515488548834
build.number=97
build.date=1515677478102
build.auto.upgrade=true
\ No newline at end of file
......@@ -347,6 +347,9 @@ public interface IdeasLocalService extends BaseLocalService,
long companyId, int start, int end,
OrderByComparator<Ideas> orderByComparator);
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public List<java.lang.String> getTagsForIdea(long ideasId);
public List<java.lang.String> ratingStringToList(java.lang.String s);
/**
......
......@@ -403,6 +403,10 @@ public class IdeasLocalServiceUtil {
orderByComparator);
}
public static java.util.List<java.lang.String> getTagsForIdea(long ideasId) {
return getService().getTagsForIdea(ideasId);
}
public static java.util.List<java.lang.String> ratingStringToList(
java.lang.String s) {
return getService().ratingStringToList(s);
......
......@@ -424,6 +424,11 @@ public class IdeasLocalServiceWrapper implements IdeasLocalService,
start, end, orderByComparator);
}
@Override
public java.util.List<java.lang.String> getTagsForIdea(long ideasId) {
return _ideasLocalService.getTagsForIdea(ideasId);
}
@Override
public java.util.List<java.lang.String> ratingStringToList(
java.lang.String s) {
......
......@@ -4,6 +4,7 @@ dependencies {
compileOnly group: "com.liferay", name: "com.liferay.portal.spring.extender", version: "2.0.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.6.0"
compileOnly project(":modules:ideaService:ideaService-api")
compileOnly project(":modules:analysisService:analysisService-api")
compileOnly group: "com.liferay.portal", name:"com.liferay.portal.kernel", version:"2.0.0"
compileOnly group: "com.liferay", name:"com.liferay.contacts.api", version:"2.0.0"
compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
......
......@@ -48,6 +48,7 @@ import ideaService.service.IdeasLocalServiceUtil;
import ideaService.service.base.IdeasLocalServiceBaseImpl;
import ideaService.service.persistence.IdeasUtil;
import ideasService.service.enums.ReviewStatus;
import analysisService.service.TagDataLocalServiceUtil;
/**
* The implementation of the ideas local service.
......@@ -93,6 +94,25 @@ public class IdeasLocalServiceImpl extends IdeasLocalServiceBaseImpl {
return result;
}
public List<String> getTagsForIdea(long ideasId){
ArrayList<String> result = new ArrayList<String> ();
try {
Ideas idea = IdeasUtil.findByPrimaryKey(ideasId);
String [] tagPrimaryKeys = idea.getTags().split(",");
for(int i=0; i<tagPrimaryKeys.length; i++){
long tagKey = Long.parseLong(tagPrimaryKeys[i].replaceAll("\\s+",""));
result.add(TagDataLocalServiceUtil.getTagData(tagKey).getTag());
}
} catch (NumberFormatException | PortalException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
public void setIdeaReviewStatus(long ideasId, ReviewStatus status){
try {
Ideas i = IdeasUtil.findByPrimaryKey(ideasId);
......
......@@ -13,6 +13,6 @@
##
build.namespace=IDEA
build.number=226
build.date=1515488553545
build.number=230
build.date=1515677482780
build.auto.upgrade=true
\ No newline at end of file
......@@ -13,6 +13,6 @@
##
build.namespace=PROJECT
build.number=138
build.date=1515488556284
build.number=142
build.date=1515677485456
build.auto.upgrade=true
\ No newline at end of file
......@@ -13,6 +13,6 @@
##
build.namespace=SURVEY
build.number=237
build.date=1515488561189
build.number=241
build.date=1515677490480
build.auto.upgrade=true
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment