I want to compile my applications with the following tree in yocto project:
myapps/
├── Papps1
│ ├── module-apps1
│ │ └── app1
│ │ ├── include
│ │ │ ├── include files
│ │ ├── configure.ac
│ │ ├── Makefile
│ │ └── other source files
│ └── Papps2
│ └── app2
│ ├── include
│ ├── include files
│ ├── CMakeLists.txt
│ └── other source files
└── recipies_apps
├── recipies_app1.bb
└── recipies_app2.bb
is there any solution to compile this architecture tree in yocto ?
I'm trying to convert an old Ant project to Maven. The project has a massive code base which is packed in different wars using Ant targets. It has multiple source folders, and each war is generated using different classes of these source folder. The code base should be separated in different sub-project but at the moment this is not an option so the goal is to have multiple wars for one project.
I've tried to use maven modules, creating a parent pom and a subfolder maven-modules in which I have one pom for each war that I need to generate, here's an example:
OldMassiveProject
│ ├── src
│ │ └── bunch.of.packages
│ ├── other_src
│ │ └── bunch.of.packages
│ ├── various_resources_folder
...
│ ├── maven_modules
│ │ ├── module_1
│ │ │ └── pom.xml
│ │ ├── module_2
│ │ │ └── pom.xml
...
│ │ ├── module_n
│ │ │ └── pom.xml
│ ├── deploy_configuration
│ │ ├── module_1
│ │ │ ├── spring_files
│ │ │ └── web.xml
│ │ ├── module_2
│ │ │ ├── spring_files
│ │ │ └── web.xml
...
│ │ ├── module_n
│ │ │ ├── spring_files
│ │ │ └── web.xml
│ └── pom.xml (parent pom)
I've managed to create the wars but my IDE (Eclipse) cannot resolve imports of the dependencies used in the modules'pom. That's because the parent pom doesn't specify those dependencies so they are not added to the project's classpath. My question is: Is there a way to import modules' pom dependencies in the projectclass path?
I have prebuilt binaries of opencv as static libraries built using the android NDK r16 for arm64-v8a & armeabi-v7a.
I'm trying to use these binaries as is in an AOSP build for the same above two architectures.
The output of the opencv prebuild seems to have separated the opencv specific .a files from the 3rdparty .a files. I gather this means to link successfully I will have to include both the opencv library (eg libopencv_core.a) as well as the third-party dependency (libtbb.a). I'm not sure how to specify the 3rdparty dependency in the static prebuild module description.
This is folder structure of the opencv output
sdk
└── native
├── 3rdparty
│ └── libs
│ ├── arm64-v8a
│ │ ├── libcpufeatures.a
│ │ └── libtbb.a
│ ├── armeabi-v7a
│ │ ├── libcpufeatures.a
│ │ └── libtbb.a
│ ├── x86
│ │ ├── libcpufeatures.a
│ │ ├── libittnotify.a
│ │ └── libtbb.a
│ └── x86_64
│ ├── libcpufeatures.a
│ ├── libittnotify.a
│ └── libtbb.a
├── jni
│ ├── android.toolchain.cmake
│ ├── include
│ │ ├── opencv
│ │ │ ├── cvaux.h
| | | ...
│ │ └── opencv2
│ │ ├── core
└── libs
├── arm64-v8a
│ ├── libopencv_core.a
│ ├── libopencv_features2d.a
│ ├── libopencv_imgproc.a
│ └── libopencv_video.a
├── armeabi-v7a
│ ├── libopencv_core.a
│ ├── libopencv_features2d.a
│ ├── libopencv_imgproc.a
│ └── libopencv_video.a
├── x86
│ ├── libopencv_core.a
│ ├── libopencv_features2d.a
│ ├── libopencv_imgproc.a
│ └── libopencv_video.a
└── x86_64
├── libopencv_core.a
├── libopencv_features2d.a
├── libopencv_imgproc.a
└── libopencv_video.a
The dependencies are in the 3rdparty folder.
I created an Android.mk file that makes PREBUILDs out of all the opencv libraries, but I'm not sure how to add the dependencies to the prebuilt module. This is my current Android.mk file
ROOT_DIR := $(call my-dir)
LOCAL_PATH := $(ROOT_DIR)/core-libs/opencv/Android/sdk/native/libs
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_core_prebuilt
LOCAL_MULTILIB := both
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES_64 := arm64-v8a/libopencv_core.a
LOCAL_SRC_FILES_32 := armeabi-v7a/libopencv_core.a
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../jni/include
LOCAL_EXPORT_CFLAGS_64 := -L$(LOCAL_PATH)/../3rdparty/libs/arm64-v8a -llibtbb.a -llibcpufeatures.a
LOCAL_EXPORT_CFLAGS_32 := -L$(LOCAL_PATH)/../3rdparty/libs/armeabi-v7a -llibtbb.a -llibcpufeatures.a
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_features2d_prebuilt
LOCAL_MULTILIB := both
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES_64 := arm64-v8a/libopencv_features2d.a
LOCAL_SRC_FILES_32 := armeabi-v7a/libopencv_features2d.a
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../jni/include
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_imgproc_prebuilt
LOCAL_MULTILIB := both
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES_64 := arm64-v8a/libopencv_imgproc.a
LOCAL_SRC_FILES_32 := armeabi-v7a/libopencv_imgproc.a
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../jni/include
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_video_prebuilt
LOCAL_MULTILIB := both
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES_64 := arm64-v8a/libopencv_video.a
LOCAL_SRC_FILES_32 := armeabi-v7a/libopencv_video.a
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../jni/include
include $(BUILD_PREBUILT)
When I try to link to the opencv prebuilds sure enough I get undefined references for calls into libtbb.
How do I specify the libtbb dependency and how to do I make sure the corresponding 3rdparty .a file is linked together.
Can I add it to the LOCAL_SRC_FILES variable ?
I need to make custom queries to the liferay database including JOIN, etc.
My research took me to use the Service Builder strategy.
But when I read about the service builder, you need to define entities in the service.xml file. I do not need an entity, I am willing to use existing entities, for example JournalArcticle, etc.
I would appreciate if someone could direct me to the correct way to go.
The Query I need to use:
SELECT ja.*
FROM liferay.journalarticle ja
INNER JOIN liferay.assetentry ae
ON ja.resourcePrimKey = ae.classPK
INNER JOIN liferay.assetentries_assettags ae_at
ON ae.entryId = ae_at.entryId
INNER JOIN liferay.assettag tags
ON ae_at.tagId = tags.tagId
where tags.name = "actualités de recherche"
;
JournalArticle, assetentries_assettags, AssetTag, AssetEntry are all legacy liferay entities.
I am using liferay 6.1.1-GA2
I read that:
http://www.liferay.com/fr/documentation/liferay-portal/6.1/development/-/ai/define-object-relational-maps-liferay-portal-6-1-dev-guide-en
and that:
http://www.liferay.com/fr/web/sten.martinez/blog/-/blogs/using-a-legacy-db-with-service-builder
Basicaly, I follow the service builder rule and adapt it to maven environment.
Colored version of the post: http://blog.melard.fr/post/123556374437/liferay-implementing-your-custom-service-using
Environnement
------------------------------------
liferay: liferay-portal-6.1.1-ce-ga2
------------------------------------
PAY ATTENTION
If you define a variable hot.deploy.listeners in your portal-ext.properties file, be sur to add the com.liferay.portal.deploy.hot.SpringHotDeployListener class or you might get a BeanLocator is not set error.
I’ve been studying the way to implement a custom service using custom sql based on existing entities.
Case study
I need to retrieve the last version of JournalArticles using pagination adn tag name.
References
blog
Get last version of last journal articles
The answer from that blog entry is to retrieve all the articles and then for each article check if it is the last version of the article using that method:
if(JournalArticleLocalServiceUtil.isLatestVersion(groupId,journalobj.getArticleId(),journalobj.getVersion())){
// here logic will come or you can create another list to add those articles with latest version
}
Determine latest version of Web Content in Liferay
This is another solution, worse than the one mentionned before as it retrieve all the articles and then for each article, check if the articleId has been already loaded.
List articles = JournalArticleLocalServiceUtil.getStructureArticles(GROUPID, STRUCTUREID);
ListIterator it = articles.listIterator();
List checkedArticleIds = new ArrayList();
while (it.hasNext()) {
JournalArticle article = it.next();
if (checkedArticleIds.contains(article.getArticleId())) {
continue; // previous article version already checked
}
JournalArticle articleLastVersion = JournalArticleLocalServiceUtil.getLatestArticle(GROUPID, article.getArticleId());
checkedArticleIds.add(article.getArticleId());
System.out.println("Added articleId " + article.getArticleId() + " with version " + article.getVersion());
}
Find Liferay Latest Journal Atticles By Tag Name
public List getArticlesByTags(long groupId, String tagName)
throws PortalException, SystemException {
AssetEntryQuery assetEntryQuery = new AssetEntryQuery();
long[] anyTagIds = AssetTagLocalServiceUtil.getTagIds(groupId, new String[]{"alllocation", tagName});
assetEntryQuery.setAnyTagIds(anyTagIds);
List assetEntryList = AssetEntryLocalServiceUtil.getEntries(assetEntryQuery);
List journalArticleList = new ArrayList();
for (AssetEntry ae : assetEntryList) {
JournalArticleResource journalArticleResourceObj = JournalArticleResourceLocalServiceUtil
.getJournalArticleResource(ae.getClassPK());
JournalArticle journalArticleObj = JournalArticleLocalServiceUtil.getArticle(groupId,
journalArticleResourceObj.getArticleId());
journalArticleList.add(journalArticleObj);
}
return journalArticleList;
}
The first article entries are not possible because they retrieve all the articles in the database and then process them in order to get the latest versions of each article. It is possible for small entry sets. But when you get to thousands of articles, it will get very slow.
I like better the third article because you only get a limited amount or articles
Implement a custom service using Service Builder
I wanted to use a single method to get last article version by tag name using an SQL Query and let the database handle the joins
SELECT ja.*
FROM JournalArticle as ja
JOIN (
SELECT SUBSTRING_INDEX(GROUP_CONCAT(uuid_ ORDER BY version DESC),',',1) AS uuid_LastVersion
FROM JournalArticle ja
INNER JOIN assetentry ae
ON ja.resourcePrimKey = ae.classPK
INNER JOIN AssetEntries_AssetTags ae_at
ON ae.entryId = ae_at.entryId
INNER JOIN AssetTag tags
ON ae_at.tagId = tags.tagId
where tags.name = ?
GROUP BY articleId
ORDER BY articleId DESC
) as uuids
ON ja.uuid_ = uuids.uuid_LastVersion
After doing a lot of research, I found out that Service Builder was the way to go. I read the manual.
Why all that fuss around ORM, I did not want to create a new table, what I need is to access existing entities, remember? And I am not using Ant, who is using Ant nowadays? I am using Maven. So I had to understand how to create the sevice using maven and then where do I needed to put my classes in order to get my service up and running.
Build a service
In order to build a service, you can use a maven archetype.
mvn archetype:generate
then choose the option: com.liferay.maven.archetypes:liferay-servicebuilder-archetype (Provides an archetype to create Liferay Service Builder portlets.)
The Lifferay version: 2: 6.1.1
Define value for property 'groupId': : com.my.cms
Define value for property 'artifactId': : service
Define value for property 'version': 1.0-SNAPSHOT: :
Define value for property 'package': com.my.cms: :
The archetype then generate some code and modify the pom.xml of the current directory if any
directory:
pom.xml
service
├── pom.xml
├── service-portlet
│ ├── pom.xml
│ └── src
│ └── main
│ ├── resources
│ │ └── portlet.properties
│ └── webapp
│ ├── css
│ │ └── main.css
│ ├── icon.png
│ ├── js
│ │ └── main.js
│ ├── view.jsp
│ └── WEB-INF
│ ├── liferay-display.xml
│ ├── liferay-plugin-package.properties
│ ├── liferay-portlet.xml
│ ├── portlet.xml
│ ├── service.xml
│ └── web.xml
└── service-portlet-service
└── pom.xml The pom.xml on the parent directory is modified to add the “service” module. Be carreful to modify it if you already have a “modules” tag in order to add the “service” module in that tag.
<modules>
<module>service
</modules> As you can see, the Service Builder generated two portlets:
service-portlet
service-portlet-service
The service-portlet is a WAR containing the service to be deployed on you application server.
The service-portlet-service is a JAR containing the classes to be deployed in your portlet on the application server.
Implementation
service.xml
The first thing is to modify the service.xml file in order to have Service Builder to create all the stubs you need to register your service in liferay.
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_1_0.dtd">
<!-- service/service-portlet/src/main/webapp/WEB-INF/service.xml -->
<service-builder package-path="com.my.cms">
<namespace>service
<entity name="MyService" local-service="true" remote-service="true">
</entity>
</service-builder>
As you can see, I removed all the content of the entity tag, changed the name attribute to “MyService” instead of “Foo” and removed the uuid attribute.
Now, run service builder
cd service
mvn liferay:build-service
[INFO] Reactor Summary:
[INFO]
[INFO] service ........................................... SUCCESS [0.538s]
[INFO] service Portlet Service ........................... SUCCESS [0.299s]
[INFO] service Portlet ................................... SUCCESS [0.322s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
you can see the directory structure as some new files:
├── pom.xml
├── service-portlet
│ ├── pom.xml
│ └── src
│ └── main
│ ├── java
│ │ └── com
│ │ └── my
│ │ └── cms
│ │ └── service
│ │ ├── base
│ │ │ ├── MyServiceLocalServiceBaseImpl.java
│ │ │ ├── MyServiceLocalServiceClpInvoker.java
│ │ │ ├── MyServiceServiceBaseImpl.java
│ │ │ └── MyServiceServiceClpInvoker.java
│ │ ├── http
│ │ │ └── MyServiceServiceSoap.java
│ │ └── impl
│ │ ├── MyServiceLocalServiceImpl.java
│ │ └── MyServiceServiceImpl.java
│ ├── resources
│ │ ├── META-INF
│ │ │ ├── base-spring.xml
│ │ │ ├── cluster-spring.xml
│ │ │ ├── dynamic-data-source-spring.xml
│ │ │ ├── hibernate-spring.xml
│ │ │ ├── infrastructure-spring.xml
│ │ │ ├── portlet-hbm.xml
│ │ │ ├── portlet-model-hints.xml
│ │ │ ├── portlet-orm.xml
│ │ │ ├── portlet-spring.xml
│ │ │ └── shard-data-source-spring.xml
│ │ ├── portlet.properties
│ │ └── service.properties
│ └── webapp
│ ├── css
│ │ └── main.css
│ ├── icon.png
│ ├── js
│ │ ├── main.js
│ │ └── service.js
│ ├── view.jsp
│ └── WEB-INF
│ ├── liferay-display.xml
│ ├── liferay-plugin-package.properties
│ ├── liferay-portlet.xml
│ ├── portlet.xml
│ ├── service.xml
│ ├── service.xml~
│ ├── sql
│ │ ├── indexes.properties
│ │ ├── indexes.sql
│ │ ├── sequences.sql
│ │ └── tables.sql
│ └── web.xml
└── service-portlet-service
├── pom.xml
└── src
└── main
└── java
└── com
└── my
└── cms
└── service
├── ClpSerializer.java
├── messaging
│ └── ClpMessageListener.java
├── MyServiceLocalService.java
├── MyServiceLocalServiceClp.java
├── MyServiceLocalServiceUtil.java
├── MyServiceLocalServiceWrapper.java
├── MyServiceService.java
├── MyServiceServiceClp.java
├── MyServiceServiceUtil.java
└── MyServiceServiceWrapper.java
27 directories, 48 files
Now, everything is in place to add our custom sql. you can read about custom-sql in the manual
Custom-SQL
In order to use custom SQL you need to add a file containing your SQL queries, then to add a persistence class that will call execute that query. And call the method in a sevice util class.
SQL File
The file must be called custom-sql/default.xml and contain the SQL in a CDATA section:
<custom-sql>
<sql id="fr.meteo.cms.service.persistence.MeteoJournalArticleFinder.findLatestArticleByTagName">
<![CDATA[
SELECT ja.*
FROM mf3_liferay.journalarticle AS ja
JOIN (
SELECT SUBSTRING_INDEX(GROUP_CONCAT(uuid_ ORDER BY version DESC),',',1) AS uuid_LastVersion
FROM mf3_liferay.journalarticle ja
INNER JOIN mf3_liferay.assetentry ae
ON ja.resourcePrimKey = ae.classPK
INNER JOIN mf3_liferay.assetentries_assettags ae_at
ON ae.entryId = ae_at.entryId
INNER JOIN mf3_liferay.assettag tags
ON ae_at.tagId = tags.tagId
WHERE tags.name = ?
GROUP BY articleId
ORDER BY articleId DESC
) AS uuids
ON ja.uuid_ = uuids.uuid_LastVersion
]]>
</sql>
</custom-sql> Two points of attention here :
The file needs to be put in the portlet resource dir: service/service-portlet/src/main/resources/custom-sql/default.xml
The id attribute must contain the correct package name fr.meteo.cms.service.persistence.MeteoJournalArticleFinder + a unique name for the query: findLatestArticleByTagName
Persistence class
You need to add an implementation of the persistence class, the class that will implement the execution of the SQL query. The class need to be in that package: com.my.cms.service.persistence and in that path: service\service-portlet\src\main\java\com\my\cms\service\persistence\MyServiceFinderImpl.java
package com.my.cms.service.persistence;
import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portlet.journal.model.JournalArticle;
public class MyServiceFinderImpl extends BasePersistenceImpl {
}
You need to pay attention to the name of the class, it must be MyServiceFinderImpl or liferay will not recognize it! and it must be in the right package.
When you have put the file in the persistence forlder in the portlet package, you need to run Service Builder again to get the stubs file generated.
mvn liferay:build-service
service
├── pom.xml
├── service.iml
├── service-portlet
│ ├── pom.xml
│ ├── service-portlet.iml
│ └── src
│ └── main
│ ├── java
│ │ └── com
│ │ └── my
│ │ └── cms
│ │ └── service
│ │ ├── base
│ │ │ ├── MyServiceLocalServiceBaseImpl.java
│ │ │ ├── MyServiceLocalServiceClpInvoker.java
│ │ │ ├── MyServiceServiceBaseImpl.java
│ │ │ └── MyServiceServiceClpInvoker.java
│ │ ├── http
│ │ │ └── MyServiceServiceSoap.java
│ │ ├── impl
│ │ │ ├── MyServiceLocalServiceImpl.java
│ │ │ └── MyServiceServiceImpl.java
│ │ └── persistence
│ │ └── MyServiceFinderImpl.java
│ ├── resources
│ │ ├── custom-sql
│ │ │ └── default.xml
│ │ ├── META-INF
│ │ │ ├── base-spring.xml
│ │ │ ├── cluster-spring.xml
│ │ │ ├── dynamic-data-source-spring.xml
│ │ │ ├── hibernate-spring.xml
│ │ │ ├── infrastructure-spring.xml
│ │ │ ├── portlet-hbm.xml
│ │ │ ├── portlet-model-hints.xml
│ │ │ ├── portlet-orm.xml
│ │ │ ├── portlet-spring.xml
│ │ │ └── shard-data-source-spring.xml
│ │ ├── portlet.properties
│ │ └── service.properties
│ └── webapp
│ ├── css
│ │ └── main.css
│ ├── icon.png
│ ├── js
│ │ ├── main.js
│ │ └── service.js
│ ├── view.jsp
│ └── WEB-INF
│ ├── liferay-display.xml
│ ├── liferay-plugin-package.properties
│ ├── liferay-portlet.xml
│ ├── portlet.xml
│ ├── service.xml
│ ├── service.xml~
│ ├── sql
│ │ ├── indexes.properties
│ │ ├── indexes.sql
│ │ ├── sequences.sql
│ │ └── tables.sql
│ └── web.xml
└── service-portlet-service
├── pom.xml
├── service-portlet-service.iml
└── src
└── main
└── java
└── com
└── my
└── cms
└── service
├── ClpSerializer.java
├── messaging
│ └── ClpMessageListener.java
├── MyServiceLocalService.java
├── MyServiceLocalServiceClp.java
├── MyServiceLocalServiceUtil.java
├── MyServiceLocalServiceWrapper.java
├── MyServiceService.java
├── MyServiceServiceClp.java
├── MyServiceServiceUtil.java
├── MyServiceServiceWrapper.java
└── persistence
├── MyServiceFinder.java
└── MyServiceFinderUtil.java
30 directories, 55 files liferay added or modified those files:
service/service-portlet/src/main/webapp/WEB-INF/sql/tables.sql
service/service-portlet/src/main/resources/service.properties
service/service-portlet/src/main/java/com/my/cms/service/base/MyServiceLocalServiceClpInvoker.java
service/service-portlet/src/main/java/com/my/cms/service/base/MyServiceServiceBaseImpl.java
service/service-portlet/src/main/java/com/my/cms/service/base/MyServiceServiceClpInvoker.java
service/service-portlet/src/main/resources/META-INF/portlet-spring.xml
service/service-portlet/src/main/java/com/my/cms/service/base/MyServiceLocalServiceBaseImpl.java
service/service-portlet-service/src/main/java/com/my/cms/service/persistence/MyServiceFinder.java
service/service-portlet-service/src/main/java/com/my/cms/service/persistence/MyServiceFinderUtil.java
You can now implements the method findLatestArticleByTagName in the MyServiceFinderImpl file
package com.my.cms.service.persistence;
import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
import com.liferay.portal.kernel.dao.orm.*;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portlet.journal.model.JournalArticle;
import com.liferay.util.dao.orm.CustomSQLUtil;
import java.util.List;
public class MyServiceFinderImpl extends BasePersistenceImpl implements MyServiceFinder {
public List findLatestArticleByTagName(
String tagName,
int begin, int end) {
Session session = null;
try {
SessionFactory sessionFactory = (SessionFactory) PortalBeanLocatorUtil.locate("liferaySessionFactory");
session = sessionFactory.openSession();
String sql = CustomSQLUtil.get(
FIND_BY_LATEST_ARTICLES_BY_TAGNAME);
SQLQuery q = session.createSQLQuery(sql);
q.setCacheable(false);
q.addEntity("JournalArticle_JournalArticle", PortalClassLoaderUtil.getClassLoader().loadClass("com.liferay.portlet.journal.model.impl.JournalArticleImpl"));
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(tagName);
return (List) QueryUtil.list(q, getDialect(), begin, end);
} catch (Exception e) {
try {
throw new SystemException(e);
} catch (SystemException se) {
se.printStackTrace();
}
} finally {
closeSession(session);
}
return null;
}
public static final String FIND_BY_LATEST_ARTICLES_BY_TAGNAME =
MyServiceFinder.class.getName() +
".findLatestArticleByTagName";
}
I you want to use an existing session and connect your service to it, you can use that line of code:
SessionFactory sessionFactory = (SessionFactory) PortalBeanLocatorUtil.locate("liferaySessionFactory"); You can find the entity you are looking for by using the class loader:
PortalClassLoaderUtil.getClassLoader().loadClass("com.liferay.portlet.journal.model.impl.JournalArticleImpl") Then launch again the Service Builder in order to propagate the findLatestArticleByTagName method
mvn liferay:build-service You need now to add the method in the com.my.cms.service.impl.MyServiceLocalServiceImpl class in order to use it.
public List findLatestArticleByTagName(
String tagName,
int begin, int end) {
return MyServiceFinderUtil.findLatestArticleByTagName(tagName, begin, end);
}
Then launch again the Service Builder in order to propagate the findLatestArticleByTagName method in different classes.
mvn liferay:build-service
Use the service in a portlet
In order to use the service in the portlet, you need to do some configuration first.
Add the dependency to the Service’s portlet in liferay(service/service-portlet/src/main/webapp/WEB-INF/liferay-plugin-package.properties), this will ensure that the portlet using the service will not be deployed before the service:
required-deployment-contexts=service-portlet
Add the dependency to the Service’s portlet in maven in order to get the JAR file:
<dependency>
<groupId>com.my.cms</groupId>
<artifactId>service-portlet-service</artifactId>
<version>${pom.version}</version>
</dependency> Rebuild and redeploy the service in liferay application server.
You can test your service in your portlet using the Util class:
List journalArticles = MyServiceLocalServiceUtil.findLatestArticleByTagName("actualités de recherche", currentPage, currentPage + 8);
I have a problem with folder structure of MVC2
How can I use that way:
Folder:
├── Controllers
│ └── Portal
│ ├── Accounting
│ │ ├── CashController.cs
│ │ └── BankController.cs
│ └── HR
│ └── EmployeesController.cs Models
└── Views
└── Portal
└── Accounting
├── Cash
│ ├── Index.aspx
│ └── List.aspx
├── Bank
│ └── Index.aspx
└── HR
├── Index.aspx
└── Employee.aspx
How can I use folder structure like that and how can I route the URL with the right form.
Many Thanks
You might want to consider using Areas and dropping the Portal folder since it's just a wrapper.
So you will end up with something like this :
Areas
├── Accounting
│ ├── Controllers
│ │ ├── CashController.cs
│ │ └── BankController.cs
│ └── Views
│ ├── Cash
│ │ ├── Index.aspx
│ │ └── List.aspx
│ └── Bank
│ └── Index.aspx
└── HR
├── Controllers
│ └── EmployeesController.cs
└── Views
└── Employees
├── Index.aspx
└── Employee.aspx
More on Areas here
Or just use any structure you want and change the namesspaces to match the default (not recommended).