Code Monkey home page Code Monkey logo

damascus's Issues

getDateTimeFromRequest need to create a empty time instead of throwing Exception when no parameters found

In *LocalServiceImpl#getDateTimeFromRequest, this method should return alternative data instead of throwing an exception when no parameters for date found. Also in the exception, it needs to be printed on the console. The sample code is below.

    public Date getDateTimeFromRequest(PortletRequest request, String prefix) {
        int Year = ParamUtil.getInteger(request, prefix + "Year");
        int Month = ParamUtil.getInteger(request, prefix + "Month") + 1;
        int Day = ParamUtil.getInteger(request, prefix + "Day");
        int Hour = ParamUtil.getInteger(request, prefix + "Hour");
        int Minute = ParamUtil.getInteger(request, prefix + "Minute");
        int AmPm = ParamUtil.getInteger(request, prefix + "AmPm");

        if (AmPm == Calendar.PM) {
            Hour += 12;
        }

        LocalDateTime ldt;
		try {
			ldt = LocalDateTime.of(Year, Month, Day, Hour, Minute, 0);
		} catch (Throwable e) {
			e.printStackTrace();
			Date in = new Date();
			Instant instant = in.toInstant();
			return Date.from(instant);			
		}
		
        return Date.from(ldt.atZone(ZoneId.systemDefault()).toInstant());
    }

*-web switch

*-web switch would be preferable to be implemented when a user needs only services.

Generate code for multiple entities in the same modules.

For now, when we define several entities in our base.json file, we get 3 modules for each entity (*-api, *-service and *-web).

In my point of view, it would be more valuable to get 3 modules in total.

To be more concrete, consider the airline example project with entites Flight and Plane.
With the current version of Damascus, the directory layout looks like this (and there is only 1 entity in each service.xml file) :

airline
|
|----Flight-api
|
|----Flight-service
|    |
|    |--- service.xml 
|
|----Flight-web
|
|----Plane-api
|
|----Plane-service
|    |
|    |--- service.xml
|
|----Plane-web

With the proposed evolution, the directory layout would look like that (and all the entities would be in the only service.xml file) :

airline
|
|----airline-api
|
|----airline-service
|    |
|    |--- service.xml
|
|----airline-web

@yasuflatland-lf : What is your feeling about that? If you agree I can implement this evolution and submit you a pull request.

Preference values can't be referred in view.jsp

need to add something like as follows in *Portlet.java

	@Override
	protected void doDispatch(
			RenderRequest renderRequest, RenderResponse renderResponse)
		throws IOException, PortletException {

        renderRequest.setAttribute(DummyFactoryConfiguration.class.getName(), _dummyFactoryConfiguration);

		super.doDispatch(renderRequest, renderResponse);
	}

View Detail

Create "View Detail" Functionality.

We already created this for 7.0 version, we need to customise so it support 7.1 version. Our team will upgrade it to 7.1 version, then will ask for pull request.

Template generator from actual code

Motivation

At a project, there's a case where a user wants to use Damascus as a service generator of their custom templates. In that case, users repeat a cycle to generate codes and fix templates accordingly. A functionally to assist the cycle efficiency will be beneficial not only for users but also Damascus contributors as well.

The idea of implementation

Replacement patterns

The default replacement patterns between template value and Keywords (model names, package names and directory names) should be generated in base.json file as optional fields at damascus -init command called.

The fields should be customizable as users may want to add custom patterns as well.

Manage Relations between Entities

1st of all this is a great CRUD plugin for Liferay. Thanks for developing and contributing this.

This feature would be a great benefit : manage relations between entities.

Let us know how we could contribute for Damascus...

Advanced Search

Create "Advanced Search" Functionality.

We already created this for 7.0 version, we need to customise so it support 7.1 version.

Feature request: custom json objects in CustomValue or (better) customfield in fields definition

Hi,
great work here! I tried to customize templates to allow generation of an HTML Select input for one of my fields. Currently I added a bunch of fields in the customValue field of base.json. Currently they are:

"fieldXY": 3,
"fieldXYvalue1": "1",
"fieldXYlabel1" : "Option 1",
"fieldXYvalue2": "2",
"fieldXYlabel2" : "Option 2",
"fieldXYvalue3": "3",
"fieldXYlabel3" : "Option 3"

that I parse in the template as

<#if (field.type?string == "com.liferay.damascus.cli.json.fields.Integer" && application.customValue[field.name]?? ) >
  <aui:select name="${field.name}" disabled="false" label='<%=LanguageUtil.get(request, "${lowercaseModel}-${field.name?lower_case}") + requiredLabel%>'>
    <aui:option value="" label="Select a value"/>
    <#list 1..application.customValue[field.name]?number as optionIdx>
      <#assign optionvalue = application.customValue[field.name+"value"+optionIdx?string] />
      <#assign optionlabel = application.customValue[field.name+"label"+optionIdx?string] />
      <aui:option value="${optionvalue}" label="${optionlabel}"/>
    </#list>
  </aui:select>
</#if>

I saw that customValue is implemented as a Map<String, String> so it is a sort of key-value map. Maybe a Map<String, Object> could be better for having custom objects in base.json that can be used in templates.
So in base.json it could be:

"customValue" : {
       "fieldXY": {
            "items": [
                {value:1, label: "Option 1"},
                {value:2, label: "Option 2"},
                {value:3, label: "Option 3"}
          ]
         }
      }

Even better could be having a custom object in the field definition so that one can specify custom code based on field data.
So for an integer field in base.json it could be:

{
  "type": "com.liferay.damascus.cli.json.fields.Integer",
  "name": "fieldXY",
  "title": "Field Title",
  "required": "true" {
  "items": [
     {value:1, label: "Option 1"},
     {value:2, label: "Option 2"},
     {value:3, label: "Option 3"}
    ]
}

README for *-service and *-web

Since many functionalities are pre implemented in the templates, README that described details in *-service and *-web will be helpful for users.

Add more flexibility to the project name

The project name has 2 restrictions as below now

  1. The project name must start from a capital alphabet letter
  2. Hyphens are not allowed.

1 should be straight forward to resolve, but in terms of 2, service builder doesn't allow hyphens for the model / field name. Damascus utilize project name (a parameter after -init) for model / primary key field name for now, so they may need to be converted into other way, say camel case for example when a user run damascus -init

edit.jsp's categories, assets and related assets markup need to be updated

The current code is as below

<aui:input name="categories" type="assetCategories" />
<aui:input name="tags" type="assetTags" />

<liferay-ui:panel defaultState="closed" extended="<%=false%>"
    id="todoEntryAssetLinksPanel" persistState="<%=true%>"
    title="related-assets">
    <aui:fieldset>
        <liferay-ui:input-asset-links
            className="<%=Todo.class.getName()%>"
            classPK="<%=todo.getPrimaryKey()%>" />
    </aui:fieldset>
</liferay-ui:panel>

These need to be as follows

<aui:fieldset collapsed="<%= true %>" collapsible="<%= true %>" label="categorization">
    <aui:input name="categories" type="assetCategories" />

    <aui:input name="tags" type="assetTags" />
</aui:fieldset>

<aui:fieldset collapsed="<%= true %>" collapsible="<%= true %>" label="related-assets">
    <liferay-ui:input-asset-links
        className="<%= BlogsEntry.class.getName() %>"
        classPK="<%= entryId %>"
    />
</aui:fieldset>

Ability to use user defined valuable in templates.

As a developer, custom variables in templates to manage conditions is helpful. The expected use case is as follows

  1. Define valuables in base.json (extend base.json structure)
  2. Create custom templates and use those conditional values with Freemarker. Maybe storing those data into an associative array.

Templates cache is never refreshed

Templates cache is never refreshed : if you build and install a new version of Damascus with modifications in template files, the template files stored in ${HOME}/.damascus/templates are never updated.

AnnotationTypeMismatchException from JCommander

Hi,

I installed damascus with jpm as indicated in the wiki, but when I run it I get an AnnotationTypeMismatchException error.

I tried to compile it myself, same result as you can see below.

C:\...\damascus\build\libs>java -jar damascus.jar -init Todo -p todo
java.lang.annotation.AnnotationTypeMismatchException: Incorrectly typed data found for annotation element public abstract java.lang.Class[] com.beust.jcommander.Parameter.validateWith() (Found data of type class java.lang.Class[class com.liferay.damascus.cli.validators.ProjectNameValidator])
        at sun.reflect.annotation.AnnotationTypeMismatchExceptionProxy.generateException(Unknown Source)
        at sun.reflect.annotation.AnnotationInvocationHandler.invoke(Unknown Source)
        at com.sun.proxy.$Proxy2.validateWith(Unknown Source)
        at com.beust.jcommander.WrappedParameter.validateWith(WrappedParameter.java:55)
        at com.beust.jcommander.ParameterDescription.validateParameter(ParameterDescription.java:330)
        at com.beust.jcommander.ParameterDescription.addValue(ParameterDescription.java:233)
        at com.beust.jcommander.JCommander.processFixedArity(JCommander.java:895)
        at com.beust.jcommander.JCommander.processFixedArity(JCommander.java:870)
        at com.beust.jcommander.JCommander.parseValues(JCommander.java:721)
        at com.beust.jcommander.JCommander.parse(JCommander.java:340)
        at com.beust.jcommander.JCommander.parse(JCommander.java:319)
        at com.beust.jcommander.JCommander.<init>(JCommander.java:253)
        at com.liferay.damascus.cli.Damascus.run(Damascus.java:57)
        at com.liferay.damascus.cli.Damascus.main(Damascus.java:46)

I fixed it by using JCommander 1.71 (https://github.com/cbeust/jcommander/releases/tag/1.71)

-compile 'com.beust:jcommander:1.64'
+compile 'com.beust:jcommander:1.71'

Is there a reason why you rolled back to version 1.64 in commit bc62708#diff-c197962302397baf3a4cc36463dce5ea?

Add Liferay minimal required versions to the readme file

Since the last release, it seems that the minimal required versions of Liferay for generated code was higher than previously (now it seems to be Liferay 7.0 CE GA4 and Liferay DXP SP3).

It will be very valuable to add the minimal required versions to the readme file.

Add exception message printing at each the catch syntax

At Exception in *ActionCommand.java and *ServiceLocalImpl.java, the root error cause must be displayed on console because it's hard to debug without it.

In case where throwing a custom exception, log.error may be appropriate.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.