Skip to content

Commit

Permalink
Merge branch 'feature/Relation_fix' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuflatland-lf committed Dec 7, 2019
2 parents cc66fe0 + 055dda1 commit 2198872
Show file tree
Hide file tree
Showing 28 changed files with 585 additions and 108 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Build Status](https://travis-ci.org/yasuflatland-lf/damascus.svg?branch=master)](https://travis-ci.org/yasuflatland-lf/damascus)
[![Coverage Status](https://coveralls.io/repos/github/yasuflatland-lf/damascus/badge.svg?branch=master)](https://coveralls.io/github/yasuflatland-lf/damascus?branch=master)
[![Build status](https://ci.appveyor.com/api/projects/status/qqpdw6drt8w07ljp?svg=true)](https://ci.appveyor.com/project/yasuflatland-lf/damascus)
[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/liferay-damascus/community)

Damascus is a Liferay Blade tool extension for generating scaffoldings of Service builder portlet with CRUD functionality based on a configuration json file, base.json. For more detailed usage, please see [this official document](https://yasuflatland-lf.github.io/damascus-doc/)

Expand All @@ -14,9 +15,9 @@ The list of what Damascus automatically generate is as follows
* Workflow
* Trashbox
* Search (Including Advanced search for individual fields)
* Comments
* Comments (Deprecated in 7.2 templates)
* Related assets
* Ratings
* Ratings (Deprecated in 7.2 templates)
* Activities (The activities on the portlet will be recorded and visible on an activity portlet)
* Multiple service builder portlets at once
* Exporting entities by xls file format
Expand Down Expand Up @@ -65,7 +66,7 @@ Please see more detailed settings [here](https://github.com/yasuflatland-lf/dama

### IDE settings
Damascus is including lombok library, so annotation library for lombok needs to be properly installed on IDEs. Here are how to apply lombok to Eclipse / IntelliJ
##### Eclipse
##### Eclipse (Not Liferay Developer Studio)
1. Download lombok https://projectlombok.org/download
2. double click ```lombok.jar``` and select the directory where ```eclipse.exe``` exist
3. Run ```gradle eclipse``` at the project directory and restart IDE, and right click on the project and display context name, and choose ```gradle > Refresh gradle project```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jar {
manifest {
attributes(
"Bundle-SymbolicName": "com.liferay.damascus.cli",
"Bundle-Version": "1.1.1",
"Bundle-Version": "1.1.2",
"Bundle-Description": "Liferay extension tool for scaffolding service builder portlet",
"Main-Class": "com.liferay.damascus.cli.Damascus",
"JPM-Command": "damascus"
Expand Down
Binary file modified latest/damascus.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/java/com/liferay/damascus/cli/Damascus.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@Slf4j
public class Damascus {

public final static String VERSION = "1.1.1";// + "_" + LocalDateTime.now().toString();
public final static String VERSION = "1.1.2";// + "_" + LocalDateTime.now().toString();

/**
* Main
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/templates/7.1/service.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<?xml version="1.0"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_1_0.dtd">
<!-- <dmsc:root templateName="service.xml" pickup="true" /> -->
Expand Down Expand Up @@ -174,4 +173,4 @@
</exceptions>

</service-builder>
<!-- </dmsc:sync> -->
<!-- </dmsc:sync> -->
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import ${packageName}.web.upload.${capFirstModel}ItemSelectorHelper;
<#assign capFirstValidationModel = "${field.validation.className?cap_first}">
import ${packageName}.service.${capFirstValidationModel}LocalService;
import ${packageName}.web.constants.${capFirstValidationModel}WebKeys;
import ${packageName}.web.util.${capFirstValidationModel}ViewHelper;
</#if>
</#list>
// </dmsc:sync> //
Expand Down Expand Up @@ -115,9 +116,11 @@ public class ${capFirstModel}AdminCrudMVCRenderCommand implements MVCRenderComma
// <dmsc:sync id="render-attributes" > //
<#list application.fields as field >
<#if field.validation?? && field.validation.className??>
<#assign capFirstValidationModel = "${field.validation.className?cap_first}">
<#assign uncapFirstValidationModel = "${field.validation.className?uncap_first}">
<#assign uppercaseValidationModel = "${field.validation.className?upper_case}">

request.setAttribute(${capFirstValidationModel}WebKeys.${uppercaseValidationModel}_VIEW_HELPER, _${uncapFirstValidationModel}ViewHelper);
request.setAttribute(${capFirstModel}WebKeys.${uppercaseValidationModel}_LOCAL_SERVICE, _${uncapFirstValidationModel}LocalService);
</#if>
</#list>
Expand Down Expand Up @@ -229,6 +232,9 @@ public class ${capFirstModel}AdminCrudMVCRenderCommand implements MVCRenderComma
<#assign capFirstValidationModel = "${field.validation.className?cap_first}">
<#assign uncapFirstValidationModel = "${field.validation.className?uncap_first}">

@Reference
private ${capFirstValidationModel}ViewHelper _${uncapFirstValidationModel}ViewHelper;

@Reference
private ${capFirstValidationModel}LocalService _${uncapFirstValidationModel}LocalService;
</#if>
Expand All @@ -238,4 +244,4 @@ public class ${capFirstModel}AdminCrudMVCRenderCommand implements MVCRenderComma
@Reference
private ${capFirstModel}ItemSelectorHelper _${uncapFirstModel}ItemSelectorHelper;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import ${packageName}.web.upload.${capFirstModel}ItemSelectorHelper;
<#assign capFirstValidationModel = "${field.validation.className?cap_first}">
import ${packageName}.service.${capFirstValidationModel}LocalService;
import ${packageName}.web.constants.${capFirstValidationModel}WebKeys;
import ${packageName}.web.util.${capFirstValidationModel}ViewHelper;
</#if>
</#list>
// </dmsc:sync> //
Expand Down Expand Up @@ -114,9 +115,11 @@ public class ${capFirstModel}CrudMVCRenderCommand implements MVCRenderCommand {
// <dmsc:sync id="render-attributes" > //
<#list application.fields as field >
<#if field.validation?? && field.validation.className??>
<#assign capFirstValidationModel = "${field.validation.className?cap_first}">
<#assign uncapFirstValidationModel = "${field.validation.className?uncap_first}">
<#assign uppercaseValidationModel = "${field.validation.className?upper_case}">

request.setAttribute(${capFirstValidationModel}WebKeys.${uppercaseValidationModel}_VIEW_HELPER, _${uncapFirstValidationModel}ViewHelper);
request.setAttribute(${capFirstModel}WebKeys.${uppercaseValidationModel}_LOCAL_SERVICE, _${uncapFirstValidationModel}LocalService);
</#if>
</#list>
Expand Down Expand Up @@ -230,7 +233,10 @@ public class ${capFirstModel}CrudMVCRenderCommand implements MVCRenderCommand {
<#assign capFirstValidationModel = "${field.validation.className?cap_first}">
<#assign uncapFirstValidationModel = "${field.validation.className?uncap_first}">

@Reference
@Reference
private ${capFirstValidationModel}ViewHelper _${uncapFirstValidationModel}ViewHelper;

@Reference
private ${capFirstValidationModel}LocalService _${uncapFirstValidationModel}LocalService;
</#if>
</#list>
Expand All @@ -239,4 +245,4 @@ public class ${capFirstModel}CrudMVCRenderCommand implements MVCRenderCommand {
@Reference
private ${capFirstModel}ItemSelectorHelper _${uncapFirstModel}ItemSelectorHelper;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,45 @@ String redirect = ParamUtil.getString(request, "redirect");
field.type?string == "com.liferay.damascus.cli.json.fields.Integer" ||
field.type?string == "com.liferay.damascus.cli.json.fields.Text"
>
<#if field.validation?? && field.validation.className??>
<#assign capFirstValidationModel = "${field.validation.className?cap_first}">
<#assign uncapFirstValidationModel = "${field.validation.className?uncap_first}">
<#assign uppercaseValidationModel = "${field.validation.className?upper_case}">

<#assign fieldName = "PrimaryKey">
<#if field.validation.fieldName??>
<#assign fieldName = "${field.validation.fieldName?cap_first}">
</#if>

<#assign orderByField = "PrimaryKey">
<#if field.validation.orderByField??>
<#assign orderByField = "${field.validation.orderByField?uncap_first}">
</#if>
<%
${capFirstValidationModel}ViewHelper ${uncapFirstValidationModel}ViewHelper = (${capFirstValidationModel}ViewHelper) request
.getAttribute(${capFirstValidationModel}WebKeys.${uppercaseValidationModel}_VIEW_HELPER);

SearchContainerResults<${capFirstValidationModel}> ${uncapFirstValidationModel}Results = ${uncapFirstValidationModel}ViewHelper.getListFromDB(
renderRequest, -1, -1, "${orderByField?uncap_first}", "asc", new int[] {WorkflowConstants.STATUS_APPROVED});
%>
<liferay-ui:error key="${lowercaseModel}-${field.name?lower_case}-not-found"
message="${lowercaseModel}-${field.name?lower_case}-not-found" />

<aui:select name="${field.name}"
label='<%=LanguageUtil.get(request, "${lowercaseModel}-${field.name?lower_case}")
+ requiredLabel%>'>
<aui:option value=""><%=LanguageUtil.get(request, "please-select") %></aui:option>
<% for(${capFirstValidationModel} ${uncapFirstValidationModel} : ${uncapFirstValidationModel}Results.getResults()) { %>
<aui:option value="<%= ${uncapFirstValidationModel}.get${fieldName}() %>"><%=${uncapFirstValidationModel}.get${orderByField?cap_first}() %></aui:option>
<% } %>
</aui:select>

<#else>
<aui:input name="${field.name}" disabled="false"
label='<%=LanguageUtil.get(request, "${lowercaseModel}-${field.name?lower_case}")
+ requiredLabel%>'
/>
</#if>
</#if>
<#-- ---------------- -->
<#-- Document Library -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ page import="com.liferay.trash.util.TrashWebKeys" %>
<#if field.validation?? && field.validation.className??>
<%@page import="${packageName}.model.${field.validation.className}"%>
<%@page import="${packageName}.web.constants.${field.validation.className}WebKeys"%>
<%@page import="${packageName}.web.util.${field.validation.className}ViewHelper"%>
<%@page import="${packageName}.service.${field.validation.className}LocalService"%>
</#if>
</#list>

<%-- </dmsc:sync> --%>

<liferay-frontend:defineObjects />
Expand Down Expand Up @@ -87,4 +87,4 @@ datetimeFormatVal = HtmlUtil.escape(portletPreferences.getValue("datetimeFormat"

datePickerFormatVal = HtmlUtil.escape(portletPreferences.getValue("datePickerFormat", ${uncapFirstModel}Configuration.datePickerFormat()));
}
%>
%>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ String iconUnchecked = "unchecked";
SimpleDateFormat dateFormat = new SimpleDateFormat(dateFormatVal);
SimpleDateFormat dateTimeFormat = new SimpleDateFormat(datetimeFormatVal);

<#list application.fields as field >
<#if field.validation?? && field.validation.className??>
<#assign capFirstValidationModel = "${field.validation.className?cap_first}">
<#assign uncapFirstValidationModel = "${field.validation.className?uncap_first}">
<#assign uppercaseValidationModel = "${field.validation.className?upper_case}">
${capFirstValidationModel}LocalService ${uncapFirstValidationModel}LocalService = (${capFirstValidationModel}LocalService) request
.getAttribute(${capFirstModel}WebKeys.${uppercaseValidationModel}_LOCAL_SERVICE);
</#if>
</#list>

${capFirstModel}DisplayContext ${uncapFirstModel}DisplayContext = (${capFirstModel}DisplayContext)request.getAttribute(${capFirstModel}WebKeys.${uppercaseModel}_DISPLAY_CONTEXT);

String displayStyle = ${uncapFirstModel}DisplayContext.getDisplayStyle();
Expand Down Expand Up @@ -104,14 +114,38 @@ ${capFirstModel}ManagementToolbarDisplayContext ${uncapFirstModel}ManagementTool
field.type?string == "com.liferay.damascus.cli.json.fields.DocumentLibrary" ||
field.type?string == "com.liferay.damascus.cli.json.fields.Integer"
>

<#if field.validation?? && field.validation.className??>
<#assign capFirstValidationModel = "${field.validation.className?cap_first}">
<#assign uncapFirstValidationModel = "${field.validation.className?uncap_first}">

<#assign fieldName = "PrimaryKey">
<#if field.validation.fieldName??>
<#assign fieldName = "${field.validation.fieldName?cap_first}">
</#if>

<#assign orderByField = "PrimaryKey">
<#if field.validation.orderByField??>
<#assign orderByField = "${field.validation.orderByField?cap_first}">
</#if>
<%
String ${field.name}Text = "";
try {
${capFirstValidationModel} ${uncapFirstValidationModel} = ${uncapFirstValidationModel}LocalService.get${capFirstValidationModel}(GetterUtil.getLong(${uncapFirstModel}.get${field.name?cap_first}()));
${field.name}Text = ${uncapFirstValidationModel}.get${orderByField}();
} catch(Exception e) {}
%>
<liferay-ui:search-container-column-text name="${field.name?cap_first}"
align="center" value="<%= ${field.name}Text %>" />
<#else>
<liferay-ui:search-container-column-text
align="left"
name="${field.name?cap_first}"
orderable="true"
orderableProperty="${field.name}"
property="${field.name}"
/>

</#if>
</#if>
<#-- ---------------- -->
<#-- Date -->
Expand Down Expand Up @@ -179,4 +213,4 @@ ${capFirstModel}ManagementToolbarDisplayContext ${uncapFirstModel}ManagementTool
submitForm(form, '<portlet:actionURL name="/${lowercaseModel}/crud" />');
}
}
</aui:script>
</aui:script>
35 changes: 35 additions & 0 deletions src/main/resources/templates/7.2/Portlet_XXXXWEB_edit.jsp.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,45 @@
field.type?string == "com.liferay.damascus.cli.json.fields.Integer" ||
field.type?string == "com.liferay.damascus.cli.json.fields.Text"
>
<#if field.validation?? && field.validation.className??>
<#assign capFirstValidationModel = "${field.validation.className?cap_first}">
<#assign uncapFirstValidationModel = "${field.validation.className?uncap_first}">
<#assign uppercaseValidationModel = "${field.validation.className?upper_case}">

<#assign fieldName = "PrimaryKey">
<#if field.validation.fieldName??>
<#assign fieldName = "${field.validation.fieldName?cap_first}">
</#if>

<#assign orderByField = "PrimaryKey">
<#if field.validation.orderByField??>
<#assign orderByField = "${field.validation.orderByField?uncap_first}">
</#if>
<%
${capFirstValidationModel}ViewHelper ${uncapFirstValidationModel}ViewHelper = (${capFirstValidationModel}ViewHelper) request
.getAttribute(${capFirstValidationModel}WebKeys.${uppercaseValidationModel}_VIEW_HELPER);

SearchContainerResults<${capFirstValidationModel}> ${uncapFirstValidationModel}Results = ${uncapFirstValidationModel}ViewHelper.getListFromDB(
renderRequest, -1, -1, "${orderByField?uncap_first}", "asc", new int[] {WorkflowConstants.STATUS_APPROVED});
%>
<liferay-ui:error key="${lowercaseModel}-${field.name?lower_case}-not-found"
message="${lowercaseModel}-${field.name?lower_case}-not-found" />

<aui:select name="${field.name}"
label='<%=LanguageUtil.get(request, "${lowercaseModel}-${field.name?lower_case}")
+ requiredLabel%>'>
<aui:option value=""><%=LanguageUtil.get(request, "please-select") %></aui:option>
<% for(${capFirstValidationModel} ${uncapFirstValidationModel} : ${uncapFirstValidationModel}Results.getResults()) { %>
<aui:option value="<%= ${uncapFirstValidationModel}.get${fieldName}() %>"><%=${uncapFirstValidationModel}.get${orderByField?cap_first}() %></aui:option>
<% } %>
</aui:select>

<#else>
<aui:input name="${field.name}" disabled="false"
label='<%=LanguageUtil.get(request, "${lowercaseModel}-${field.name?lower_case}")
+ requiredLabel%>'
/>
</#if>
</#if>
<#-- ---------------- -->
<#-- Document Library -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ page import="com.liferay.trash.util.TrashWebKeys" %>
<#if field.validation?? && field.validation.className??>
<%@page import="${packageName}.model.${field.validation.className}"%>
<%@page import="${packageName}.web.constants.${field.validation.className}WebKeys"%>
<%@page import="${packageName}.web.util.${field.validation.className}ViewHelper"%>
<%@page import="${packageName}.service.${field.validation.className}LocalService"%>
</#if>
</#list>
Expand Down Expand Up @@ -85,4 +86,4 @@ datetimeFormatVal = HtmlUtil.escape(portletPreferences.getValue("datetimeFormat"

datePickerFormatVal = HtmlUtil.escape(portletPreferences.getValue("datePickerFormat", ${uncapFirstModel}Configuration.datePickerFormat()));
}
%>
%>
37 changes: 35 additions & 2 deletions src/main/resources/templates/7.2/Portlet_XXXXWEB_view.jsp.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ String iconUnchecked = "unchecked";
SimpleDateFormat dateFormat = new SimpleDateFormat(dateFormatVal);
SimpleDateFormat dateTimeFormat = new SimpleDateFormat(datetimeFormatVal);

<#list application.fields as field >
<#if field.validation?? && field.validation.className??>
<#assign capFirstValidationModel = "${field.validation.className?cap_first}">
<#assign uncapFirstValidationModel = "${field.validation.className?uncap_first}">
<#assign uppercaseValidationModel = "${field.validation.className?upper_case}">
${capFirstValidationModel}LocalService ${uncapFirstValidationModel}LocalService = (${capFirstValidationModel}LocalService) request
.getAttribute(${capFirstModel}WebKeys.${uppercaseValidationModel}_LOCAL_SERVICE);
</#if>
</#list>

${capFirstModel}DisplayContext ${uncapFirstModel}DisplayContext = (${capFirstModel}DisplayContext)request.getAttribute(${capFirstModel}WebKeys.${uppercaseModel}_DISPLAY_CONTEXT);

String displayStyle = ${uncapFirstModel}DisplayContext.getDisplayStyle();
Expand Down Expand Up @@ -86,14 +96,37 @@ ${capFirstModel}ManagementToolbarDisplayContext ${uncapFirstModel}ManagementTool
field.type?string == "com.liferay.damascus.cli.json.fields.DocumentLibrary" ||
field.type?string == "com.liferay.damascus.cli.json.fields.Integer"
>
<#if field.validation?? && field.validation.className??>
<#assign capFirstValidationModel = "${field.validation.className?cap_first}">
<#assign uncapFirstValidationModel = "${field.validation.className?uncap_first}">

<#assign fieldName = "PrimaryKey">
<#if field.validation.fieldName??>
<#assign fieldName = "${field.validation.fieldName?cap_first}">
</#if>

<#assign orderByField = "PrimaryKey">
<#if field.validation.orderByField??>
<#assign orderByField = "${field.validation.orderByField?cap_first}">
</#if>
<%
String ${field.name}Text = "";
try {
${capFirstValidationModel} ${uncapFirstValidationModel} = ${uncapFirstValidationModel}LocalService.get${capFirstValidationModel}(GetterUtil.getLong(${uncapFirstModel}.get${field.name?cap_first}()));
${field.name}Text = ${uncapFirstValidationModel}.get${orderByField}();
} catch(Exception e) {}
%>
<liferay-ui:search-container-column-text name="${field.name?cap_first}"
align="center" value="<%= ${field.name}Text %>" />
<#else>
<liferay-ui:search-container-column-text
align="left"
name="${field.name?cap_first}"
orderable="true"
orderableProperty="${field.name}"
property="${field.name}"
/>

</#if>
</#if>
<#-- ---------------- -->
<#-- Date -->
Expand Down Expand Up @@ -160,4 +193,4 @@ ${capFirstModel}ManagementToolbarDisplayContext ${uncapFirstModel}ManagementTool
submitForm(form, '<portlet:actionURL name="/${lowercaseModel}/crud" />');
}
}
</aui:script>
</aui:script>
Loading

0 comments on commit 2198872

Please sign in to comment.