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 created a vendored framework that I am shipping through cocoapods. Now I would like to ship the dsym file with the framework also, so that my crashes could be shown in console and included with the archived ipa's dsyms.
I tried to copy the dsym in framework but it was throwing "bit_strip error" while archiving the build.
Thanks in advance
Cocoapods introduced in 1.3.0 the possibility of automatically copy the dSYMs for vendored dynamic frameworks as explained here:
CocoaPods will automatically detect and copy the .dSYM files of vendored dynamic frameworks. Place the .dSYM next to your .framework for CocoaPods to detect it and copy it to the onto the folder specified by ${DWARF_DSYM_FOLDER_PATH}.
So how this works exactly? Well, Cocoapods clone your repository locally and then clean it based on the patterns specified in the Podspec for the library. If you put your *.framework and the *.framework.dSYM in the same level of the path Cocoapods will automatically detect it and handles the copy of the dSYM to the ${DWARF_DSYM_FOLDER_PATH} folder during the archive process.
├── Stencil.framework
│ ├── Headers -> Versions/Current/Headers
│ ├── Modules -> Versions/Current/Modules
│ ├── Resources -> Versions/Current/Resources
│ ├── Stencil -> Versions/Current/Stencil
│ └── Versions
│ ├── A
│ │ ├── Headers
│ │ │ ├── Stencil-Swift.h
│ │ │ └── Stencil.h
│ │ ├── Modules
│ │ │ ├── Stencil.swiftmodule
│ │ │ │ ├── x86_64.swiftdoc
│ │ │ │ └── x86_64.swiftmodule
│ │ │ └── module.modulemap
│ │ ├── Resources
│ │ │ └── Info.plist
│ │ └── Stencil
│ └── Current -> A
└── Stencil.framework.dSYM
└── Contents
├── Info.plist
└── Resources
└── DWARF
└── Stencil
A good way to check also if your *.dSYM is being detected and handled it correctly is once you added it to a project take a look in the Pods-{ProjectName}-frameworks.sh and you should find a new line similar to the following one:
install_dsym "${PODS_ROOT}/Stencil.framework.dSYM"
With that line above Cocoapods will copy the dSYM to the ${DWARF_DSYM_FOLDER_PATH} folder and it will be added correctly to the *.xcarchive during the archive process.
An important point here is if your vendored dynamic framework has Bitcode enabled then the dSYM will not be enough as in this case another file called *.bcsymbolmap will be generated and it's necessary too to correctly to symbolicate your crashes. A good explanation of this can be found here by Apple.
So again how we can include the generated *.bcsymbolmap with the generated framework ?? Well, you can add to your Podspec a preserve_path to keep the reference to the *.bcsymbolmap generated, and again Cocoapods will take care of it and copy the symbols for you.
m.preserve_path = '**/*.bcsymbolmap'
A good example of it is the Mapbox-iOS-SDK-nightly-dynamic.podspec. It's very important to mention that the *.bcsymbol needs to be at the same level path as the *.framework as the *dSYM to be handled correctly.
Again to check if your *.bcsymbolmapis being detected and handled it correctly Go to the Pods-{ProjectName}-frameworks.sh and you should find a new line similar to the following one:
install_bcsymbolmap "${PODS_ROOT}/AA73DD4B-8AC5-30D1-9831-3D09CC9906D9.bcsymbolmap"
Bear with me on this one. I will try to explain in the simplest way possible. I have built a chatbot using API.AI. The tree below is a simple and rough representation of how the flow goes. First 2 levels are straightforward, it just asks simple questions then it branches out to different paths. As you can see also, that the endpoint is all the same.
The question here is that with a common endpoint and having multiple yes/no fallback intents, is there a way to link the fallback intents to one common intent?
Get name
└── Get email address
├── [johndoe#email.com]
└── Does not give email address
├── Know more about person
│ ├── About short description
│ │ └── Dont want to know more
│ │ ├── Read more
│ │ └── Want to connect with person?
│ │ ├── Show email address
│ │ └── Goodbye
│ ├── Coding short description
│ │ └── Dont want to know more
│ │ ├── Read more
│ │ └── Want to connect with person?
│ │ ├── Show email address
│ │ └── Goodbye
│ ├── Achievements short description
│ │ └── Dont want to know more
│ │ ├── Read more
│ │ └── Want to connect with person?
│ │ ├── Show email address
│ │ └── Goodbye
│ └── Skills short description
│ │ └── Dont want to know more
│ │ ├── Read more
│ │ └── Want to connect with person?
│ │ ├── Show email address
│ │ └── Goodbye
└── Want to connect with person?
├── Show email address
└── Goodbye
I assume by the structure you've given that you're using FollowUpIntents, one way to group multiple intents to one fallback intent is using a contextOut that's the same for all the endpoints you'd like to match the fallback to.
FollowUp intents actually construct their flow with contexts in the same way, however, you can do this yourself too ofcourse.
so in the following intents:
│ ├── Coding short description
│ ├── Achievements short description
│ └── Skills short description
You simply set the contextout of these intents to something like "contextFallback".
In:
Dont want to know more
You simply set the contextIn as "contextFallback". This way, every time you trigger one of the contexts that set the context out, you can trigger and branch to the "Dont want to know more" intent. Resulting in one intent (instead of the 4 intents that do the same as per your example)
I hope I understood your question properly, otherwise I'll edit my answer.
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);