Commit b01d610a authored by Elias Englmeier's avatar Elias Englmeier
Browse files

Combined local and remote ideaservice methods

parent 0b433868
......@@ -96,7 +96,7 @@ public interface IdeasLocalService extends BaseLocalService,
* created- and modified date are set automatically.
*/
public Ideas creadeIdeasWithAutomatedDbId(java.lang.String title,
long userId, long companyId, java.lang.String type,
long userId, long groupId, java.lang.String type,
java.lang.String icon, java.lang.String shortDescription,
java.lang.String description, double latitude, double longitude,
boolean published, boolean showOnMap);
......@@ -242,7 +242,7 @@ public interface IdeasLocalService extends BaseLocalService,
public long dynamicQueryCount(DynamicQuery dynamicQuery,
Projection projection);
public void deleteIdea(int id) throws NoSuchIdeasException;
public void deleteIdea(long id) throws NoSuchIdeasException;
/**
* persists the new Idea and performs some checks e.g. if the entry is a duplicate it won't be inserted.
......
......@@ -84,13 +84,13 @@ public class IdeasLocalServiceUtil {
* created- and modified date are set automatically.
*/
public static ideaService.model.Ideas creadeIdeasWithAutomatedDbId(
java.lang.String title, long userId, long companyId,
java.lang.String title, long userId, long groupId,
java.lang.String type, java.lang.String icon,
java.lang.String shortDescription, java.lang.String description,
double latitude, double longitude, boolean published, boolean showOnMap) {
return getService()
.creadeIdeasWithAutomatedDbId(title, userId, companyId,
type, icon, shortDescription, description, latitude, longitude,
.creadeIdeasWithAutomatedDbId(title, userId, groupId, type,
icon, shortDescription, description, latitude, longitude,
published, showOnMap);
}
......@@ -269,7 +269,7 @@ public class IdeasLocalServiceUtil {
return getService().dynamicQueryCount(dynamicQuery, projection);
}
public static void deleteIdea(int id)
public static void deleteIdea(long id)
throws ideaService.exception.NoSuchIdeasException {
getService().deleteIdea(id);
}
......
......@@ -81,12 +81,12 @@ public class IdeasLocalServiceWrapper implements IdeasLocalService,
*/
@Override
public ideaService.model.Ideas creadeIdeasWithAutomatedDbId(
java.lang.String title, long userId, long companyId,
java.lang.String title, long userId, long groupId,
java.lang.String type, java.lang.String icon,
java.lang.String shortDescription, java.lang.String description,
double latitude, double longitude, boolean published, boolean showOnMap) {
return _ideasLocalService.creadeIdeasWithAutomatedDbId(title, userId,
companyId, type, icon, shortDescription, description, latitude,
groupId, type, icon, shortDescription, description, latitude,
longitude, published, showOnMap);
}
......@@ -278,7 +278,7 @@ public class IdeasLocalServiceWrapper implements IdeasLocalService,
}
@Override
public void deleteIdea(int id)
public void deleteIdea(long id)
throws ideaService.exception.NoSuchIdeasException {
_ideasLocalService.deleteIdea(id);
}
......
......@@ -50,6 +50,9 @@ public interface IdeasService extends BaseService {
*
* Never modify or reference this interface directly. Always use {@link IdeasServiceUtil} to access the ideas remote service. Add custom service methods to {@link ideaService.service.impl.IdeasServiceImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface.
*/
@JSONWebService(method = "DELETE")
public java.lang.String deleteIdea(java.lang.String Id);
@JSONWebService(method = "GET")
@AccessControlled(guestAccessEnabled = true)
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
......@@ -66,5 +69,6 @@ public interface IdeasService extends BaseService {
public java.lang.String insertNewIdea(java.lang.String title,
java.lang.String type, long userId, java.lang.String icon,
java.lang.String shortDescription, java.lang.String description,
double latitude, double longitude, boolean published, boolean showOnMap);
double latitude, double longitude, boolean published,
boolean showOnMap, long groupId);
}
\ No newline at end of file
......@@ -41,6 +41,10 @@ public class IdeasServiceUtil {
*
* Never modify this class directly. Add custom service methods to {@link ideaService.service.impl.IdeasServiceImpl} and rerun ServiceBuilder to regenerate this class.
*/
public static java.lang.String deleteIdea(java.lang.String Id) {
return getService().deleteIdea(Id);
}
public static java.lang.String getAllIdeas() {
return getService().getAllIdeas();
}
......@@ -57,10 +61,11 @@ public class IdeasServiceUtil {
public static java.lang.String insertNewIdea(java.lang.String title,
java.lang.String type, long userId, java.lang.String icon,
java.lang.String shortDescription, java.lang.String description,
double latitude, double longitude, boolean published, boolean showOnMap) {
double latitude, double longitude, boolean published,
boolean showOnMap, long groupId) {
return getService()
.insertNewIdea(title, type, userId, icon, shortDescription,
description, latitude, longitude, published, showOnMap);
description, latitude, longitude, published, showOnMap, groupId);
}
public static IdeasService getService() {
......
......@@ -32,6 +32,11 @@ public class IdeasServiceWrapper implements IdeasService,
_ideasService = ideasService;
}
@Override
public java.lang.String deleteIdea(java.lang.String Id) {
return _ideasService.deleteIdea(Id);
}
@Override
public java.lang.String getAllIdeas() {
return _ideasService.getAllIdeas();
......@@ -51,10 +56,11 @@ public class IdeasServiceWrapper implements IdeasService,
public java.lang.String insertNewIdea(java.lang.String title,
java.lang.String type, long userId, java.lang.String icon,
java.lang.String shortDescription, java.lang.String description,
double latitude, double longitude, boolean published, boolean showOnMap) {
double latitude, double longitude, boolean published,
boolean showOnMap, long groupId) {
return _ideasService.insertNewIdea(title, type, userId, icon,
shortDescription, description, latitude, longitude, published,
showOnMap);
showOnMap, groupId);
}
@Override
......
......@@ -13,6 +13,6 @@
##
build.namespace=IDEA
build.number=70
build.date=1504686900923
build.number=72
build.date=1505116506024
build.auto.upgrade=true
\ No newline at end of file
......@@ -84,14 +84,40 @@ public class IdeasServiceHttp {
java.lang.String title, java.lang.String type, long userId,
java.lang.String icon, java.lang.String shortDescription,
java.lang.String description, double latitude, double longitude,
boolean published, boolean showOnMap) {
boolean published, boolean showOnMap, long groupId) {
try {
MethodKey methodKey = new MethodKey(IdeasServiceUtil.class,
"insertNewIdea", _insertNewIdeaParameterTypes1);
MethodHandler methodHandler = new MethodHandler(methodKey, title,
type, userId, icon, shortDescription, description,
latitude, longitude, published, showOnMap);
latitude, longitude, published, showOnMap, groupId);
Object returnObj = null;
try {
returnObj = TunnelUtil.invoke(httpPrincipal, methodHandler);
}
catch (Exception e) {
throw new com.liferay.portal.kernel.exception.SystemException(e);
}
return (java.lang.String)returnObj;
}
catch (com.liferay.portal.kernel.exception.SystemException se) {
_log.error(se, se);
throw se;
}
}
public static java.lang.String deleteIdea(HttpPrincipal httpPrincipal,
java.lang.String Id) {
try {
MethodKey methodKey = new MethodKey(IdeasServiceUtil.class,
"deleteIdea", _deleteIdeaParameterTypes2);
MethodHandler methodHandler = new MethodHandler(methodKey, Id);
Object returnObj = null;
......@@ -117,6 +143,9 @@ public class IdeasServiceHttp {
java.lang.String.class, java.lang.String.class, long.class,
java.lang.String.class, java.lang.String.class,
java.lang.String.class, double.class, double.class, boolean.class,
boolean.class
boolean.class, long.class
};
private static final Class<?>[] _deleteIdeaParameterTypes2 = new Class[] {
java.lang.String.class
};
}
\ No newline at end of file
......@@ -81,12 +81,26 @@ public class IdeasServiceSoap {
public static java.lang.String insertNewIdea(java.lang.String title,
java.lang.String type, long userId, java.lang.String icon,
java.lang.String shortDescription, java.lang.String description,
double latitude, double longitude, boolean published, boolean showOnMap)
throws RemoteException {
double latitude, double longitude, boolean published,
boolean showOnMap, long groupId) throws RemoteException {
try {
java.lang.String returnValue = IdeasServiceUtil.insertNewIdea(title,
type, userId, icon, shortDescription, description,
latitude, longitude, published, showOnMap);
latitude, longitude, published, showOnMap, groupId);
return returnValue;
}
catch (Exception e) {
_log.error(e, e);
throw new RemoteException(e.getMessage());
}
}
public static java.lang.String deleteIdea(java.lang.String Id)
throws RemoteException {
try {
java.lang.String returnValue = IdeasServiceUtil.deleteIdea(Id);
return returnValue;
}
......
......@@ -14,6 +14,7 @@
package ideaService.service.impl;
import java.util.Date;
import java.util.List;
import com.liferay.asset.kernel.model.AssetEntry;
......@@ -21,13 +22,25 @@ import com.liferay.counter.kernel.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.json.JSONFactoryUtil;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.model.ClassedModel;
import com.liferay.portal.kernel.search.Document;
import com.liferay.portal.kernel.search.Field;
import com.liferay.portal.kernel.search.Hits;
import com.liferay.portal.kernel.search.Indexer;
import com.liferay.portal.kernel.search.IndexerRegistryUtil;
import com.liferay.portal.kernel.search.SearchContext;
import com.liferay.portal.kernel.search.SearchContextFactory;
import com.liferay.portal.kernel.search.SearchEngineHelperUtil;
import com.liferay.portal.kernel.search.SearchException;
import com.liferay.portal.kernel.search.generic.BooleanQueryImpl;
import com.liferay.portal.kernel.social.SocialActivityManagerUtil;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.PortalUtil;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.social.kernel.model.SocialActivityConstants;
import com.liferay.social.kernel.service.SocialActivityInterpreterLocalServiceUtil;
import com.liferay.social.kernel.service.SocialActivityLocalServiceUtil;
import aQute.bnd.annotation.ProviderType;
import ideaService.exception.NoSuchIdeasException;
......@@ -91,31 +104,53 @@ public class IdeasLocalServiceImpl extends IdeasLocalServiceBaseImpl {
*/
public void persistIdeasAndPerformTypeChecks(Ideas idea){
try {
assetEntryLocalService.updateEntry(idea.getUserId(), idea.getGroupId(), idea.getCreateDate(), idea.getModifiedDate(),
AssetEntry entry = assetEntryLocalService.updateEntry(idea.getUserId(), idea.getGroupId(), idea.getCreateDate(), idea.getModifiedDate(),
Ideas.class.getName(), idea.getPrimaryKey(),PortalUUIDUtil.generate(),0L,null, null, true, true,
null, null, idea.getCreateDate(), null,ContentTypes.TEXT_HTML, idea.getTitle(), idea.getDescription(), null, null,null, 0, 0, null);
null, null, new Date(), null,ContentTypes.TEXT_HTML, idea.getTitle(), idea.getDescription(), null, null,null, 0,0, null);
Indexer<Ideas> indexer = IndexerRegistryUtil.nullSafeGetIndexer(Ideas.class);
// JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
// extraDataJSONObject.put("title", idea.getTitle());
// SocialActivityManagerUtil.addActivity(entry.getUserId(), entry, SocialActivityConstants.TYPE_ADD_COMMENT, extraDataJSONObject.toString(), entry.getUserId());
JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
extraDataJSONObject.put("title", idea.getTitle());
SocialActivityManagerUtil.addActivity(entry.getUserId(), entry, SocialActivityConstants.TYPE_ADD_COMMENT, extraDataJSONObject.toString(), entry.getUserId());
indexer.reindex(idea);
} catch (PortalException e) {
e.printStackTrace();
}
idea.persist();
//Search example
// SearchContext s = new SearchContext();
// s.setCompanyId(PortalUtil.getDefaultCompanyId());
// long [] gid = new long[1];
// gid[0] = idea.getGroupId();
// s.setGroupIds(gid);
//
// BooleanQueryImpl booleanQueryImpl=new BooleanQueryImpl();
// booleanQueryImpl.addRequiredTerm(Field.ENTRY_CLASS_NAME, Ideas.class.getName());
// booleanQueryImpl.addRequiredTerm(Field.STATUS, WorkflowConstants.STATUS_APPROVED);
// booleanQueryImpl.addRequiredTerm(Field.DESCRIPTION,"A");
// try {
// Hits results = null;
// results=SearchEngineHelperUtil.getSearchEngine(SearchEngineHelperUtil.getDefaultSearchEngineId()).getIndexSearcher().search(s, booleanQueryImpl);
// Document[] docs = results.getDocs();
// for(int i=0; i<docs.length; i++){
// System.out.println(i + " : " + docs[i]);
// }
// } catch (SearchException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
public void deleteIdea(int id) throws NoSuchIdeasException{
public void deleteIdea(long id) throws NoSuchIdeasException{
try {
assetEntryLocalService.deleteEntry(new Long(id));
assetEntryLocalService.deleteEntry(id);
Indexer<Ideas> indexer = IndexerRegistryUtil.nullSafeGetIndexer(Ideas.class);
indexer.delete(IdeasLocalServiceUtil.getIdeas(id));
} catch (PortalException e) {
e.printStackTrace();
}
IdeasUtil.remove(id);
IdeasUtil.remove(id);
}
}
......
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