This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
COMMERCE-943 item-selector modules: copy user-segment-item-selector
cp -r commerce-user-segment-item-selector-api commerce-account-item-selector-api && \ cp -r commerce-user-segment-item-selector-web commerce-account-item-selector-web && \ rm commerce-account-item-selector-web/src/main/resources/content/Language_*.properties
- Loading branch information
Showing
17 changed files
with
775 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Bundle-Name: Liferay Commerce User Segment Item Selector API | ||
Bundle-SymbolicName: com.liferay.commerce.user.segment.item.selector.api | ||
Bundle-Version: 1.0.4 | ||
Export-Package: com.liferay.commerce.user.segment.item.selector.criterion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dependencies { | ||
compileOnly group: "com.liferay", name: "com.liferay.item.selector.api", version: "3.0.0" | ||
} |
24 changes: 24 additions & 0 deletions
24
...e/user/segment/item/selector/criterion/CommerceUserSegmentEntryItemSelectorCriterion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
*/ | ||
|
||
package com.liferay.commerce.user.segment.item.selector.criterion; | ||
|
||
import com.liferay.item.selector.BaseItemSelectorCriterion; | ||
|
||
/** | ||
* @author Alessio Antonio Rendina | ||
*/ | ||
public class CommerceUserSegmentEntryItemSelectorCriterion | ||
extends BaseItemSelectorCriterion { | ||
} |
1 change: 1 addition & 0 deletions
1
.../src/main/resources/com/liferay/commerce/user/segment/item/selector/criterion/packageinfo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version 1.0.0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Bundle-Name: Liferay Commerce User Segment Item Selector Web | ||
Bundle-SymbolicName: com.liferay.commerce.user.segment.item.selector.web | ||
Bundle-Version: 1.0.7 | ||
Web-ContextPath: /commerce-user-segment-item-selector-web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apply plugin: "com.liferay.lang.merger" | ||
|
||
dependencies { | ||
compileOnly group: "com.liferay", name: "com.liferay.frontend.taglib", version: "3.0.0" | ||
compileOnly group: "com.liferay", name: "com.liferay.item.selector.api", version: "3.0.0" | ||
compileOnly group: "com.liferay", name: "com.liferay.item.selector.criteria.api", version: "3.0.0" | ||
compileOnly group: "com.liferay", name: "com.liferay.osgi.service.tracker.collections", version: "3.0.0" | ||
compileOnly group: "com.liferay", name: "com.liferay.petra.lang", version: "2.0.0" | ||
compileOnly group: "com.liferay.commerce", name: "com.liferay.commerce.user.segment.api", version: "1.0.0" | ||
compileOnly group: "com.liferay.commerce", name: "com.liferay.commerce.user.segment.item.selector.api", version: "1.0.0" | ||
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "3.5.0" | ||
compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "3.0.0" | ||
compileOnly group: "javax.portlet", name: "portlet-api", version: "3.0.0" | ||
compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1" | ||
compileOnly group: "org.osgi", name: "org.osgi.core", version: "5.0.0" | ||
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0" | ||
} |
134 changes: 134 additions & 0 deletions
134
...rce/user/segment/item/selector/web/internal/CommerceUserSegmentEntryItemSelectorView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/** | ||
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
*/ | ||
|
||
package com.liferay.commerce.user.segment.item.selector.web.internal; | ||
|
||
import com.liferay.commerce.user.segment.item.selector.criterion.CommerceUserSegmentEntryItemSelectorCriterion; | ||
import com.liferay.commerce.user.segment.item.selector.web.internal.display.context.CommerceUserSegmentEntryItemSelectorViewDisplayContext; | ||
import com.liferay.commerce.user.segment.service.CommerceUserSegmentEntryService; | ||
import com.liferay.item.selector.ItemSelectorReturnType; | ||
import com.liferay.item.selector.ItemSelectorView; | ||
import com.liferay.item.selector.criteria.UUIDItemSelectorReturnType; | ||
import com.liferay.portal.kernel.language.LanguageUtil; | ||
import com.liferay.portal.kernel.theme.ThemeDisplay; | ||
import com.liferay.portal.kernel.util.ListUtil; | ||
import com.liferay.portal.kernel.util.ResourceBundleUtil; | ||
import com.liferay.portal.kernel.util.WebKeys; | ||
|
||
import java.io.IOException; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.ResourceBundle; | ||
|
||
import javax.portlet.PortletURL; | ||
|
||
import javax.servlet.RequestDispatcher; | ||
import javax.servlet.ServletContext; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.ServletRequest; | ||
import javax.servlet.ServletResponse; | ||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.osgi.service.component.annotations.Component; | ||
import org.osgi.service.component.annotations.Reference; | ||
|
||
/** | ||
* @author Alessio Antonio Rendina | ||
*/ | ||
@Component(immediate = true, service = ItemSelectorView.class) | ||
public class CommerceUserSegmentEntryItemSelectorView | ||
implements ItemSelectorView<CommerceUserSegmentEntryItemSelectorCriterion> { | ||
|
||
@Override | ||
public Class<CommerceUserSegmentEntryItemSelectorCriterion> | ||
getItemSelectorCriterionClass() { | ||
|
||
return CommerceUserSegmentEntryItemSelectorCriterion.class; | ||
} | ||
|
||
public ServletContext getServletContext() { | ||
return _servletContext; | ||
} | ||
|
||
@Override | ||
public List<ItemSelectorReturnType> getSupportedItemSelectorReturnTypes() { | ||
return _supportedItemSelectorReturnTypes; | ||
} | ||
|
||
@Override | ||
public String getTitle(Locale locale) { | ||
ResourceBundle resourceBundle = ResourceBundleUtil.getBundle( | ||
"content.Language", locale, getClass()); | ||
|
||
return LanguageUtil.get(resourceBundle, "user-segment-entries"); | ||
} | ||
|
||
@Override | ||
public boolean isShowSearch() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isVisible(ThemeDisplay themeDisplay) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void renderHTML( | ||
ServletRequest servletRequest, ServletResponse servletResponse, | ||
CommerceUserSegmentEntryItemSelectorCriterion | ||
commerceUserSegmentEntryItemSelectorCriterion, | ||
PortletURL portletURL, String itemSelectedEventName, boolean search) | ||
throws IOException, ServletException { | ||
|
||
HttpServletRequest httpServletRequest = | ||
(HttpServletRequest)servletRequest; | ||
|
||
CommerceUserSegmentEntryItemSelectorViewDisplayContext | ||
commerceUserSegmentEntryItemSelectorViewDisplayContext = | ||
new CommerceUserSegmentEntryItemSelectorViewDisplayContext( | ||
_commerceUserSegmentEntryService, httpServletRequest, | ||
portletURL, itemSelectedEventName); | ||
|
||
httpServletRequest.setAttribute( | ||
WebKeys.PORTLET_DISPLAY_CONTEXT, | ||
commerceUserSegmentEntryItemSelectorViewDisplayContext); | ||
|
||
ServletContext servletContext = getServletContext(); | ||
|
||
RequestDispatcher requestDispatcher = | ||
servletContext.getRequestDispatcher( | ||
"/user_segment_entry_item_selector.jsp"); | ||
|
||
requestDispatcher.include(servletRequest, servletResponse); | ||
} | ||
|
||
private static final List<ItemSelectorReturnType> | ||
_supportedItemSelectorReturnTypes = Collections.unmodifiableList( | ||
ListUtil.fromArray( | ||
new ItemSelectorReturnType[] { | ||
new UUIDItemSelectorReturnType() | ||
})); | ||
|
||
@Reference | ||
private CommerceUserSegmentEntryService _commerceUserSegmentEntryService; | ||
|
||
@Reference( | ||
target = "(osgi.web.symbolicname=com.liferay.commerce.user.segment.item.selector.web)" | ||
) | ||
private ServletContext _servletContext; | ||
|
||
} |
180 changes: 180 additions & 0 deletions
180
.../web/internal/display/context/CommerceUserSegmentEntryItemSelectorViewDisplayContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
/** | ||
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
*/ | ||
|
||
package com.liferay.commerce.user.segment.item.selector.web.internal.display.context; | ||
|
||
import com.liferay.commerce.user.segment.item.selector.web.internal.display.context.util.CommerceUserSegmentItemSelectorRequestHelper; | ||
import com.liferay.commerce.user.segment.item.selector.web.internal.search.CommerceUserSegmentEntryItemSelectorChecker; | ||
import com.liferay.commerce.user.segment.item.selector.web.internal.util.CommerceUserSegmentItemSelectorViewUtil; | ||
import com.liferay.commerce.user.segment.model.CommerceUserSegmentEntry; | ||
import com.liferay.commerce.user.segment.service.CommerceUserSegmentEntryService; | ||
import com.liferay.portal.kernel.dao.search.RowChecker; | ||
import com.liferay.portal.kernel.dao.search.SearchContainer; | ||
import com.liferay.portal.kernel.exception.PortalException; | ||
import com.liferay.portal.kernel.search.BaseModelSearchResult; | ||
import com.liferay.portal.kernel.search.Sort; | ||
import com.liferay.portal.kernel.util.OrderByComparator; | ||
import com.liferay.portal.kernel.util.ParamUtil; | ||
import com.liferay.portal.kernel.util.Validator; | ||
|
||
import java.util.List; | ||
|
||
import javax.portlet.PortletURL; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
/** | ||
* @author Alessio Antonio Rendina | ||
*/ | ||
public class CommerceUserSegmentEntryItemSelectorViewDisplayContext { | ||
|
||
public CommerceUserSegmentEntryItemSelectorViewDisplayContext( | ||
CommerceUserSegmentEntryService commerceUserSegmentEntryService, | ||
HttpServletRequest httpServletRequest, PortletURL portletURL, | ||
String itemSelectedEventName) { | ||
|
||
_commerceUserSegmentEntryService = commerceUserSegmentEntryService; | ||
_portletURL = portletURL; | ||
_itemSelectedEventName = itemSelectedEventName; | ||
|
||
_commerceUserSegmentItemSelectorRequestHelper = | ||
new CommerceUserSegmentItemSelectorRequestHelper( | ||
httpServletRequest); | ||
} | ||
|
||
public String getItemSelectedEventName() { | ||
return _itemSelectedEventName; | ||
} | ||
|
||
public String getOrderByCol() { | ||
return ParamUtil.getString( | ||
_commerceUserSegmentItemSelectorRequestHelper.getRenderRequest(), | ||
SearchContainer.DEFAULT_ORDER_BY_COL_PARAM, "priority"); | ||
} | ||
|
||
public String getOrderByType() { | ||
return ParamUtil.getString( | ||
_commerceUserSegmentItemSelectorRequestHelper.getRenderRequest(), | ||
SearchContainer.DEFAULT_ORDER_BY_TYPE_PARAM, "asc"); | ||
} | ||
|
||
public PortletURL getPortletURL() { | ||
return _portletURL; | ||
} | ||
|
||
public SearchContainer<CommerceUserSegmentEntry> getSearchContainer() | ||
throws PortalException { | ||
|
||
if (_searchContainer != null) { | ||
return _searchContainer; | ||
} | ||
|
||
_searchContainer = new SearchContainer<>( | ||
_commerceUserSegmentItemSelectorRequestHelper. | ||
getLiferayPortletRequest(), | ||
getPortletURL(), null, null); | ||
|
||
_searchContainer.setEmptyResultsMessage("there-are-no-entries"); | ||
|
||
OrderByComparator<CommerceUserSegmentEntry> orderByComparator = | ||
CommerceUserSegmentItemSelectorViewUtil. | ||
getCommerceUserSegmentEntryOrderByComparator( | ||
getOrderByCol(), getOrderByType()); | ||
|
||
RowChecker rowChecker = new CommerceUserSegmentEntryItemSelectorChecker( | ||
_commerceUserSegmentItemSelectorRequestHelper.getRenderResponse(), | ||
getCheckedCommerceUserSegmentEntryIds()); | ||
|
||
_searchContainer.setOrderByCol(getOrderByCol()); | ||
_searchContainer.setOrderByComparator(orderByComparator); | ||
_searchContainer.setOrderByType(getOrderByType()); | ||
_searchContainer.setRowChecker(rowChecker); | ||
|
||
if (isSearch()) { | ||
Sort sort = | ||
CommerceUserSegmentItemSelectorViewUtil. | ||
getCommerceUserSegmentEntrySort( | ||
getOrderByCol(), getOrderByType()); | ||
|
||
BaseModelSearchResult<CommerceUserSegmentEntry> results = | ||
_commerceUserSegmentEntryService. | ||
searchCommerceUserSegmentEntries( | ||
_commerceUserSegmentItemSelectorRequestHelper. | ||
getCompanyId(), | ||
_commerceUserSegmentItemSelectorRequestHelper. | ||
getScopeGroupId(), | ||
getKeywords(), _searchContainer.getStart(), | ||
_searchContainer.getEnd(), sort); | ||
|
||
_searchContainer.setTotal(results.getLength()); | ||
_searchContainer.setResults(results.getBaseModels()); | ||
} | ||
else { | ||
int total = | ||
_commerceUserSegmentEntryService. | ||
getCommerceUserSegmentEntriesCount( | ||
_commerceUserSegmentItemSelectorRequestHelper. | ||
getScopeGroupId()); | ||
|
||
_searchContainer.setTotal(total); | ||
|
||
List<CommerceUserSegmentEntry> results = | ||
_commerceUserSegmentEntryService.getCommerceUserSegmentEntries( | ||
_commerceUserSegmentItemSelectorRequestHelper. | ||
getScopeGroupId(), | ||
_searchContainer.getStart(), _searchContainer.getEnd(), | ||
orderByComparator); | ||
|
||
_searchContainer.setResults(results); | ||
} | ||
|
||
return _searchContainer; | ||
} | ||
|
||
protected long[] getCheckedCommerceUserSegmentEntryIds() { | ||
return ParamUtil.getLongValues( | ||
_commerceUserSegmentItemSelectorRequestHelper.getRenderRequest(), | ||
"checkedCommerceUserSegmentEntryIds"); | ||
} | ||
|
||
protected String getKeywords() { | ||
if (_keywords != null) { | ||
return _keywords; | ||
} | ||
|
||
_keywords = ParamUtil.getString( | ||
_commerceUserSegmentItemSelectorRequestHelper.getRenderRequest(), | ||
"keywords"); | ||
|
||
return _keywords; | ||
} | ||
|
||
protected boolean isSearch() { | ||
if (Validator.isNotNull(getKeywords())) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
private final CommerceUserSegmentEntryService | ||
_commerceUserSegmentEntryService; | ||
private final CommerceUserSegmentItemSelectorRequestHelper | ||
_commerceUserSegmentItemSelectorRequestHelper; | ||
private final String _itemSelectedEventName; | ||
private String _keywords; | ||
private final PortletURL _portletURL; | ||
private SearchContainer<CommerceUserSegmentEntry> _searchContainer; | ||
|
||
} |
Oops, something went wrong.