I have the following service.xml:
<!-- PK fields -->
<column name="id" type="long" primary="true"/>
<!-- Group instance -->
<!-- <column name="groupId" type="long" /> -->
<!-- Certificate fields -->
<column name="version" type="int" />
<column name="subject" type="String" />
<column name="serial" type="String" />
<column name="encoded" type="Blob" />
<column name="to_auth" type="boolean" />
<column name="to_sign" type="boolean" />
<column name="ins_date" type="Date" />
<column name="alt_date" type="Date" />
<column name="requests" type="Collection" entity="APPLET_REQUEST"/>
<column name="user_certifcates" type="Collection" entity="USER_CERTIFICATE"/>
<!-- Order -->
<order by="asc">
<order-column name="id" />
</order>
<!-- Finder methods: TODO: gets dos campos que pretendo -->
<finder name="id" return-type="Collection">
<finder-column name="id" />
</finder>
</entity>
<!-- PK fields -->
<column name="userid" type="long" primary="true"/>
<column name="companyid" type="long" primary="true"/>
<column name="certificateid" type="long" primary="true"/>
<!-- Group instance -->
<!-- <column name="groupId" type="long" /> -->
<!-- User_Certificate fields -->
<!-- Order -->
<order by="asc">
<order-column name="userid" />
</order>
<finder name="userid" return-type="Collection">
<finder-column name="userid" />
</finder>
</entity>
I deployed the service with the first entity and no problem appeared. When I insert the second entity and made deploy of the service, liferay showed the next error message:
Caused by: com.liferay.portal.kernel.upgrade.UpgradeException: Upgrade code using unsupported class type 2004
How can i solve this problem?
Admitted, Liferay's error message is - well - not terribly helpful. I've filed LPS-57190 to change this in future. The relevant code changes are already mentioned in the ticket. As of now, if you look at the code that I've touched for this issue, you'll see that the 2004 is the SQL-type of one of the columns that ServiceBuilder tries to update. This number is from java.sql.Types. Inspecting that class, it's BLOB - so it seems SB has some problems upgrading your BLOB column.
You can (and should) write your own upgrade code, to explicitly take care of what Liferay can't do itself. Liferay itself comes with quite a lot of UpgradeActions that will alter the database upon installing a new release. The standard operation of upgrading a table (e.g. described in this thread) is not always what you want.
Here's how to prevent Liferay from automatically upgrading your tables - look up UpgradeAction and let Liferay know that you upgraded to the new required table structure yourself.
Related
What's the best performance way of writing log files for Splunk forwarder (that monitors a folder and removes the files and puts them into Splunk)?
<target name="jsonfile" xsi:type="File" fileName="${gdc:logDirectory}/${gdc:environment}/${longdate}.json" >
<layout xsi:type="JsonLayout">
<attribute name="time" layout="${date:format=O}" />
<attribute name="message" layout="${message}" />
<attribute name="logger" layout="${logger}"/>
<attribute name="level" layout="${level}"/>
</layout>
</target>
Creates files like:
2021-08-25 18_37_45.9420.json
...
But that would mean a lot of files (every millisecond fraction). Plus if there are a lot of log activity, each log file could have more than one record (and possibly fight with the Forwarder for file locks).
I could even add a guid in the end of the file name so that I'm sure that only record logs per file, but again, that's a lot of files being created.
But if log fewer times (every second):
<target name="jsonfile" xsi:type="File"
fileName="${gdc:logDirectory}/${gdc:environment}/${date:format=yyyy-MM-dd_HH-mm-ss}.json"
<layout xsi:type="JsonLayout">
<attribute name="time" layout="${date:format=O}" />
<attribute name="message" layout="${message}" />
<attribute name="logger" layout="${logger}"/>
<attribute name="level" layout="${level}"/>
</layout>
</target>
Creates a file like:
2021-08-25_18-41-31.json
...would possibly mean that Splunk and NLog would possibly fight over file locks.
What's the optimal performance way of logging files for the Splunk Forwarder? :-)
Trying to create a FetchXML report for CRM 2016 using VS2012 following instructions here: Create a new report using SQL Server Data Tools. I want to simply find a count of cases created between two dates.
The instructions talk about copy/pasting downloaded FetchXML from the CRM Advanced find process.
FetchXML generated by the Advanced Find process to list all Cases (by ticketnumber):
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="incident">
<attribute name="incidentid" />
<attribute name="ticketnumber" />
<order attribute="ticketnumber" descending="false" />
<filter type="and">
<filter type="and">
<condition attribute="createdon" operator="on-or-after" value="2015-07-01" />
<condition attribute="createdon" operator="on-or-before" value="2016-06-30" />
</filter>
</filter>
</entity>
</fetch>
I can't find a way to aggregate with Advanced Find, but instructions here: Use FetchXML aggregation seem to indicate a couple of attribute changes to the XML is all that is necessary.
So, I changed my FetchXML in notepad++ to:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" aggregate="true" >
<entity name="incident">
<attribute name="incidentid" />
<attribute name="ticketnumber" aggregate="count" alias="casecount" />
<order attribute="ticketnumber" descending="false" />
<filter type="and">
<filter type="and">
<condition attribute="createdon" operator="on-or-after" value="2015-07-01" />
<condition attribute="createdon" operator="on-or-before" value="2016-06-30" />
</filter>
</filter>
</entity>
</fetch>
This results in an error:
Either I'm doing something wrong, or that FetchXML Aggregation page is incorrect.
Can someone show me how to create a fetchXML report that counts cases opened between two dates?
You cannot select an attribute (incidentid) while at the same time doing aggregation.
Additionally, applying ordering does not make sense when you are aggregating.
I have removed those two lines, after which the FetchXML is able to run:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" aggregate="true" >
<entity name="incident">
<attribute name="ticketnumber" aggregate="count" alias="casecount" />
<filter type="and">
<filter type="and">
<condition attribute="createdon" operator="on-or-after" value="2015-07-01" />
<condition attribute="createdon" operator="on-or-before" value="2016-06-30" />
</filter>
</filter>
</entity>
</fetch>
As a side-note, you might want to use the FetchXml Tester in XrmToolBox for quickly being able to edit and execute FetchXML.
Use this for order by clause
<order alias="casecount" descending="true" />
I know the question might be confusing,any ways I will explain it.
Basically I have two tables. Student and Course where studentid and courseid are their corresponding primary keys.
In the Student table I have two attributes courseid and courseidbackup both are key(FK) to the course table.
This is the service xml I am using, but it shows build unsuccessful.
What am I missing here? How to create service xml to achieve this ?
<service-builder package-path="com.students.db">
<author>bugs</author>
<namespace>students</namespace>
<entity name="Student" local-service="true" remote-service="true" cache-enabled="false">
<column name="studentId" type="long" primary="true" />
<column name="studentName" type="String" />
<column name="coursesid" type="Collection" entity="Course" mapping-table="Students_Courses"/>
<column name="coursesidbackup" type="Collection" entity="Course" mapping-table="Students_Courses"/>
</entity>
<entity name="Course" local-service="true" remote-service="true" cache-enabled="false">
<column name="courseId" type="long" primary="true" />
<column name="courseName" type="String" />
<column name="courseDetails" type="String" />
<column name="students" type="Collection" entity="Student" mapping-table="Students_Courses" />
</entity>
</service-builder>
You're giving the same mapping table - Students_Courses - in both cases. Try e.g. Students_Backupcourses as the second option. Otherwise I'd be puzzled how that mapping table should handle that relationship. As mentioned in the comments, typically Liferay doesn't enforce any foreign key relationship in the db model, but this would be as close as you get.
change your mapping-table="Students_Courses"
to this--> mapping-table="Students_Course"
I am developing a class where I wish to databind the attributes of a class to a dataset.
I have managed to get the following to work in the following simplified version of my class:
<class name="myclass">
<dataset name="attSettings"><settings>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</settings></dataset>
<attribute name="default_applyshadow" type="boolean" value="$once{(this.attSettings.getPointer()).xpathQuery('settings/property[#name="applyshadow"]/#defaultvalue')}" />
</class>
However, this syntax is very cumbersome and does not feel right so I am wondering if there is a better way to do this.
This doesn't answer your question but explains why you cannot use a local dataset in your situation. When you have a local dataset in a class, the dataset can only be addressed in children of the class, e.g.:
<canvas debug="true">
<class name="myclass">
<dataset name="myds">
<root>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</root>
</dataset>
<text datapath="local:classroot.myds:/root/property[#name='applyshadow']/#defaultvalue" />
</class>
<myclass />
</canvas>
The <text> element can access the dataset of the parent class by prepending local: to the datapath value. If you don't select a name for your dataset, OpenLaszlo will automatically use the name localdata for the dataset. Datasets using that name can be addressed by omitting the dataset name in the datapath/xpath value, e.g.
<class name="myclass">
<dataset>
<root>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</root>
</dataset>
<text datapath="local:classroot:/root/property[#name='applyshadow']/#defaultvalue" />
</class>
Note that the datapath does not have a name and that the datapath used for the <text> component is now local:classroot:/root/..., while local:classroot.localdata:/root/... would work as well.
I don't understand the design decision which makes it impossible to allow the use a local dataset in the datapath of a class containing that dataset, but maybe there were some technical reasons (initialization order, etc.) for it.
I figured out the proper syntax to do what I wanted:
<dataset name="myclass_settings">
<root>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</root>
</dataset>
<class name="myclass" datapath="myclass_settings:/root">
<attribute name="default_applyshadow" type="boolean" value=$path{'property[#name="applyshadow"]/#defaultvalue'}" />
</class>
The $path{} constraint is used on the class attribute to link the value to the dataset via a relative xpath query. I also had to move the dataset outside of the class to get it to work.
it is a big question since long time and now I am facing it....
I have to add list view web part through CAML to publish page.
I have used the code:
<View List="0GeneralInformationandReports" RowLimit="5" FreeForm="TRUE"
BaseViewID="0"
RecurrenceRowset="TRUE"
WebPartZoneID="bottomLeft_LeftZone"
WebPartOrder="1">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title">0 - General Information and Reports</property>
<property name="AllowConnect" type="bool">True</property>
<property name="AllowClose" type="bool">False</property>
<property name="Height" type="unit">215px</property>
</properties>
</data>
</webPart>
</webParts>
]]>
</View>
and it is rendering fine with the list view on the page. But i have to add more control to the web part like show only limited columns and top 5 modified by date ascending. This is not working using the tag as there are no other ways I can add sorting, view fields etc...
please help.
I have tried that and still it is not working. This is my list view in schema.xml.
<View DisplayName="" BaseViewID="0" Type="HTML" MobileView="TRUE" ImageUrl="/_layouts/images/dlicon.png" Hidden="TRUE" XslLink="main.xsl"
WebPartZoneID="bottomLeft_LeftZone" WebPartOrder="0">
<XslLink>main.xsl</XslLink>
<Query />
<ViewFields>
<FieldRef Name="DocIcon" />
<FieldRef Name="LinkFilenameNoMenu" />
</ViewFields>
<RowLimit>5</RowLimit>
<Aggregations Value="Off" />
</View>
</Views>
Still it is showing the same fields... No ideas how to get to it... I have referenced BaseView="0" in the of my elements.xml. Still no luck.
To do that, you'll probably have to define a new View in your List Definition, and then use BaseViewID to specify the new view by that ID.