Skip to content

Commit

Permalink
Merge branch 'release/1.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuflatland-lf committed Feb 15, 2021
2 parents 5a62859 + c58e905 commit eb17228
Show file tree
Hide file tree
Showing 9 changed files with 415 additions and 27 deletions.
Binary file modified latest/damascus.jar
Binary file not shown.
1 change: 0 additions & 1 deletion src/main/java/com/liferay/damascus/cli/CreateCommand.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.liferay.damascus.cli;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.liferay.damascus.cli.common.*;
import com.liferay.damascus.cli.exception.DamascusProcessException;
Expand Down
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 @@ -18,7 +18,7 @@
@Slf4j
public class Damascus {

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

/**
* Main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
*/
@Slf4j
public class TemplateGeneratorCommand extends BaseCommand<TemplateGeneratorArgs> {
public TemplateGeneratorCommand() {
}
public TemplateGeneratorCommand() {}

public TemplateGeneratorCommand(Damascus damascus) {
super(damascus, null);
Expand Down Expand Up @@ -95,11 +94,11 @@ public void execute() throws Exception {
.build()
.process();

System.out.println("Done.");

} catch (DamascusProcessException e) {
log.error(e.getMessage());
e.printStackTrace();
}

System.out.println("Done.");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
// <dmsc:root templateName="Portlet_XXXXWEB_AssetInfoDisplayContributor.java.ftl" />
// <dmsc:sync id="head-common" > //
<#include "./license.ftl">
<#include "./valuables.ftl">
<#assign createPath = "${webModulePath}/src/main/java/${packagePath}/web/info/display/contributor/${capFirstModel}AssetInfoDisplayContributor.java">
<#assign skipTemplate = !generateWeb>
// <#include "./valuables.ftl">
// <#assign createPath = "${webModulePath}/src/main/java/${packagePath}/web/info/display/contributor/${capFirstModel}AssetInfoDisplayContributor.java">
// </dmsc:sync> //
package ${packageName}.web.info.display.contributor;

import com.liferay.asset.info.display.contributor.BaseAssetInfoDisplayContributor;
import com.liferay.asset.info.display.field.AssetEntryInfoDisplayFieldProvider;
import com.liferay.asset.kernel.model.AssetEntry;
import com.liferay.info.display.contributor.InfoDisplayContributor;
import com.liferay.info.display.contributor.InfoDisplayField;
import com.liferay.info.display.contributor.InfoDisplayObjectProvider;
import com.liferay.info.display.field.ExpandoInfoDisplayFieldProvider;
import com.liferay.info.display.field.InfoDisplayFieldProvider;
import com.liferay.portal.kernel.exception.PortalException;
import ${packageName}.model.${capFirstModel};
import ${packageName}.service.${capFirstModel}LocalService;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* ${capFirstModel} Asset Info Display Contributor
Expand All @@ -24,21 +31,98 @@ import org.osgi.service.component.annotations.Component;
*
*/
@Component(immediate = true, service = InfoDisplayContributor.class)
public class ${capFirstModel}AssetInfoDisplayContributor extends BaseAssetInfoDisplayContributor<${capFirstModel}> {
public class ${capFirstModel}AssetInfoDisplayContributor implements InfoDisplayContributor<${capFirstModel}> {

@Override
public String getClassName() {
return ${capFirstModel}.class.getName();
}

@Override
public String getInfoURLSeparator() {
return "/${lowercaseModel}/";
public Set<InfoDisplayField> getInfoDisplayFields(
long classTypeId, Locale locale)
throws PortalException {

Set<InfoDisplayField> infoDisplayFields =
_infoDisplayFieldProvider.getContributorInfoDisplayFields(
locale, AssetEntry.class.getName(), ${capFirstModel}.class.getName());

infoDisplayFields.addAll(
_expandoInfoDisplayFieldProvider.
getContributorExpandoInfoDisplayFields(
${capFirstModel}.class.getName(), locale));

return infoDisplayFields;
}

@Override
public Map<String, Object> getInfoDisplayFieldsValues(
${capFirstModel} entry, Locale locale)
throws PortalException {

Map<String, Object> infoDisplayFieldValues = new HashMap<>();

infoDisplayFieldValues.putAll(
_assetEntryInfoDisplayFieldProvider.
getAssetEntryInfoDisplayFieldsValues(
${capFirstModel}.class.getName(), entry.getPrimaryKey(),
locale));
infoDisplayFieldValues.putAll(
_expandoInfoDisplayFieldProvider.
getContributorExpandoInfoDisplayFieldsValues(
${capFirstModel}.class.getName(), entry, locale));
infoDisplayFieldValues.putAll(
_infoDisplayFieldProvider.getContributorInfoDisplayFieldsValues(
${capFirstModel}.class.getName(), entry, locale));

return infoDisplayFieldValues;
}

@Override
public InfoDisplayObjectProvider<${capFirstModel}> getInfoDisplayObjectProvider(
long classPK)
throws PortalException {

${capFirstModel} entry = _${dashcaseProjectName}LocalService.get${capFirstModel}(classPK);

if (entry.isInTrash()) {
return null;
}

return new ${capFirstModel}InfoDisplayObjectProvider(entry);
}

@Override
public InfoDisplayObjectProvider<${capFirstModel}> getInfoDisplayObjectProvider(
long groupId, String urlTitle)
throws PortalException {

${capFirstModel} entry = _${dashcaseProjectName}LocalService.get${capFirstModel}(groupId, urlTitle);

if (entry.isInTrash()) {
return null;
}

return new ${capFirstModel}InfoDisplayObjectProvider(entry);
}

@Override
protected Map<String, Object> getClassTypeValues(${capFirstModel} assetEntryObject, Locale locale) {
return new HashMap<>();
public String getInfoURLSeparator() {
return "/${dashcaseProjectName}/";
}

@Reference
private AssetEntryInfoDisplayFieldProvider
_assetEntryInfoDisplayFieldProvider;

@Reference
private ${capFirstModel}LocalService _${dashcaseProjectName}LocalService;

@Reference
private ExpandoInfoDisplayFieldProvider _expandoInfoDisplayFieldProvider;

@Reference
private InfoDisplayFieldProvider _infoDisplayFieldProvider;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// <dmsc:root templateName="Portlet_XXXXWEB_InfoDisplayObjectProvider.java.ftl" />
// <dmsc:sync id="head-common" > //
// <#include "./valuables.ftl">
// <#assign createPath = "${webModulePath}/src/main/java/${packagePath}/web/info/display/contributor/${capFirstModel}InfoDisplayObjectProvider.java">
// </dmsc:sync> //
package ${packageName}.web.info.display.contributor;

import com.liferay.asset.kernel.AssetRendererFactoryRegistryUtil;
import com.liferay.asset.kernel.model.AssetEntry;
import com.liferay.asset.kernel.model.AssetRenderer;
import com.liferay.asset.kernel.model.AssetRendererFactory;
import com.liferay.asset.kernel.service.AssetCategoryLocalServiceUtil;
import com.liferay.asset.kernel.service.AssetTagLocalServiceUtil;
import com.liferay.info.display.contributor.InfoDisplayObjectProvider;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.PortalUtil;
import com.liferay.portal.kernel.util.StringUtil;
import ${packageName}.model.${capFirstModel};

import java.util.Locale;

/**
* @author ${damascus_author}
*/
public class ${capFirstModel}InfoDisplayObjectProvider implements InfoDisplayObjectProvider<${capFirstModel}> {


public ${capFirstModel}InfoDisplayObjectProvider(${capFirstModel} entry)
throws PortalException {

_assetEntry = _getAssetEntry(entry);
_entry = entry;
}


@Override
public long getClassNameId() {
return _assetEntry.getClassNameId();
}

@Override
public long getClassPK() {
return _entry.getPrimaryKey();
}

@Override
public long getClassTypeId() {
return _assetEntry.getClassTypeId();
}

@Override
public String getDescription(Locale locale) {
return _assetEntry.getDescription(locale);
}

@Override
public ${capFirstModel} getDisplayObject() {
return _entry;
}

@Override
public long getGroupId() {
return _entry.getGroupId();
}

@Override
public String getKeywords(Locale locale) {
String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(
_assetEntry.getClassName(), _assetEntry.getClassPK());
String[] assetCategoryNames =
AssetCategoryLocalServiceUtil.getCategoryNames(
_assetEntry.getClassName(), _assetEntry.getClassPK());

String[] keywords =
new String[assetTagNames.length + assetCategoryNames.length];

ArrayUtil.combine(assetTagNames, assetCategoryNames, keywords);

return StringUtil.merge(keywords);
}

@Override
public String getTitle(Locale locale) {
return _assetEntry.getTitle(locale);
}

@Override
public String getURLTitle(Locale locale) {
AssetRenderer assetRenderer = _assetEntry.getAssetRenderer();

return assetRenderer.getUrlTitle(locale);
}

private AssetEntry _getAssetEntry(${capFirstModel} entry)
throws PortalException {

long classNameId = PortalUtil.getClassNameId(${capFirstModel}.class);

AssetRendererFactory assetRendererFactory =
AssetRendererFactoryRegistryUtil.
getAssetRendererFactoryByClassNameId(classNameId);

return assetRendererFactory.getAssetEntry(
${capFirstModel}.class.getName(), entry.getPrimaryKey());
}
private final AssetEntry _assetEntry;
private final ${capFirstModel} _entry;

}
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ class CreateCommandTest extends Specification {
[path: pathMap["webPath"], target: ".*PortletLayoutFinder.java", amount: 1],
[path: pathMap["webPath"], target: ".*AdminPortlet.java", amount: 1],
[path: pathMap["webPath"], target: ".*PanelApp.java", amount: 1],
[path: pathMap["webPath"], target: ".*InfoDisplayObjectProvider.java", amount: 1],
[path: pathMap["webPath"], target: ".*AssetInfoDisplayContributor.java", amount: 1],
[path: pathMap["rootPath"], target: ".*build.gradle", amount: 3],
[path: pathMap["rootPath"], target: ".*settings.gradle", amount: 0]
];
Expand Down
Loading

0 comments on commit eb17228

Please sign in to comment.