Liferay Service Builder many to many relationship with custom column - liferay

I have a question relating to the Liferay Service Builder. I want to create a many-to-many relationship with custom colums in the created Join table.
This is my service.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.2.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_2_0.dtd">
<service-builder package-path="de.mycompany.mm.services">
<author>rawdog</author>
<namespace>mycompany</namespace>
<entity name="Registration" local-service="true" remote-service="false">
<column name="RegID" type="long" primary="true"></column>
<column name="Email" type="String"></column>
<column name="Hash" type="String"></column>
<column name="Validate" type="boolean"></column>
<column name="NewsletterID" type="Collection" entity="Newsletter" mapping-table="Registration_Newsletter"/>
<finder name="Hash" return-type="Registration">
<finder-column name="Hash"></finder-column>
</finder>
</entity>
<entity name="Newsletter" local-service="true" remote-service="false">
<column name="NewsletterID" type="long" primary="true"></column>
<column name="Name" type="String"></column>
<column name="Status" type="boolean"></column>
<column name="RegID" type="Collection" entity="Registration" mapping-table="Registration_Newsletter"/>
</entity>
</service-builder>
This automatically creates following SQL CREATE statement:
create table mycompany_Registration_Newsletter (
RegID LONG not null,
NewsletterID LONG not null,
primary key (ANID, MMID)
);
How could I also automatically create custom colums in the JOIN table like Status BOOLEAN. It should look like this in the end:
create table mycompany_Registration_Newsletter (
RegID LONG not null,
NewsletterID LONG not null,
Status BOOLEAN,
primary key (ANID, MMID)
);
Thanks for any help.

You have two ways to solve this problem :
You can manually modify your joined table by adding your boolean column (execute sql script on your database : ALTER TABLE yourJoinedTable ADD yourBooleanColumn BOOLEAN NOT NULL;) and then define CUSTOM SQL / NATIVE QUERY IN SERVICE BUILDER to use this joined table.
(If you want Service Builder to handle this joined table as others tables) to define it as an entity in your service.xml so that you'll be able to use it easily once you had defined 2 OneToMany relationship "right side" and "left side" of your joined table (assuming that a ManyToMany = is "equal" to = oneToMany left side && ManyToOne right side).

Related

How can I resize table column width while designing Maximo anywhere app

I have tried using usefieldsizegroup="false" and then setting width and size values , however the column width are not getting adjusted.
I think that flag tells maximo to not use the default field sizes based on field types (text box, table column, text editor, etc...). At least that's how I took their documentation:
http://www-01.ibm.com/support/docview.wss?uid=swg21388710
I was able to resize table column fields in Maximo (didn't try Anywhere-Maximo) by using a 'width' flag in the XML like so:
<tablecol dataattribute="CHANGEDATE" id="11111111111" label="Change Date" width="120"/>
You can edit the layout which is associated with the listItemTemplate element of your list. For example we want to change the width of the text field on position item3:
<listItemTemplate id="xxxxx" layout="WorkListItem">
<listtext layoutInsertAt="item3"
In this example You can find this layout template at /apps//artifact/layouts/templates/small/WorkListItem.xml
When you open this file you will see the definition of your list layout. Search the "item3" place in the layout. By editing the colspan attribute you can manipulate tablecol width:
<?xml version="1.0" encoding="UTF-8"?>
<layout id="WorkListItem" width="100">
<row id="row_0">
<column colspan="10" columnid="item3" id="item3_column"/>
<column colspan="2" columnid="button1" halign="right" id="button1_column" rowspan="3"/>
</row>
<row id="row_1">
<column colspan="8" columnid="item1" id="item1_column"/>
<column colspan="2" columnid="item2" id="item2_column"/>
</row>
<row id="row_2">
<column colspan="5" columnid="item4" id="item4_column"/>
<column colspan="5" columnid="item5" id="item5_column"/>
</row>
</layout>

CRM 2011 FetchXml to pull list accounts and display only most recent activity dates

I am trying to create a report in fetchxml on crm 2011 that displays a list of Account Names, and also in the same row displays the date of ONLY the most recent activity for that account.
So
Report should look like
Account1, Date of most recent activity for Account 1
Account2, Date of most recent activity for Account 2
Account3, Date of most recent activity for Account 3
I have a fetch query that pulls the correct data, but it pulls a row for each activity for the account instead of just for the newest activity.
so it looks like
Account1, Date of most recent activity for Account 1
Account1, Date of other activity for Account 1
Account2, Date of most recent activity for Account 2
Account2, Date of other activity for Account 2
Account3, Date of most recent activity for Account 3
Here is my fetch
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" aggregate="false">
<entity name="<accountentityname>"
<attribute name="<accountname>" />
<link-entity name="activity" from="<regardingaccoutnfield>" to="<account field>" visible="false" link-type="outer">
<attribute name="<date of activity>" />
</link-entity>
</entity>
</fetch>
Any suggestions?
Thanks.
Not sure if the maxaggregate attribute will work with datetimes, but if it does that might work
What you're wanting to do requires a subquery. This is something that CRM does not support.
If you're not using CRM Online, just perform a standard SSRS query using SQL rather then FetchXml.
If you're just trying to pull back data with the SDK, you could perform the subquery on the client side.
Why Max Aggregate Won't Work
If your column you were wanting to get the max value on was a number you could use an aggregate, but Aggregate functions AVG, MIN, MAX, or SUM can only be applied to attributes of type integer, float, money, bigint, or decimal.
That's the error if you attempt to run this query:
var xml = #"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true' aggregate='true'>
<entity name='contact'>
<attribute name='fullname' alias='name' groupby='true' />
<attribute name='contactid' alias='id' groupby='true' />
<link-entity name='activitypointer' from='regardingobjectid' to='contactid' alias='ad' link-type='outer'>
<attribute name='createdon' alias='createdon_max' aggregate='max' />
<filter type='and'>
<condition attribute='createdon' operator='not-null' />
</filter>
</link-entity>
</entity>
</fetch>";
EntityCollection fetchResult = service.RetrieveMultiple(new FetchExpression(xml);
You can do a sort on the date and return the first record only!
Do your query on accounts then return a for each & use something like:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="activitypointer">
<attribute name="scheduledstart" />
<order attribute="scheduledstart" descending="true" />
<filter type="and">
<condition attribute="scheduledstart" operator="not-null" />
</filter>
</entity>
</fetch>
OR similar Query Expression:
QueryExpression query = new QueryExpression("activitypointer");
query.ColumnSet.AddColumns("scheduledstart");
query.AddOrder("scheduledstart", OrderType.Descending);
EntityCollection results = service.RetrieveMultiple(query);
Then something like:
(DateTime)(((Entity)results.Entities.First()).Attributes["scheduledstart"]);
Add the condition that the regarding field is equal to the account.id that's in scope for the for each loop

How can i create a hierarchical dimension for dates in ActivePivot?

I'm a newbe in ActivePivot and i want to create a dimension with DimensionType = time, where the dates a shown in hierachical manner. E.g. for 30.01.2013 i need one level for the year -> 2013 (sort descending), one level for the month (also sort descending) -> 1 and one level for the days (also sort descending) -> 30, 29, 28, ...
Viewed via ActivePivotLive should look like:
- 2013
- 1
- 30
- 29
- 28
- ...
+ 2012
+ 2011
and so on.
I went through the ActivePivot sandbox project, but i didn't find anything that helps me. The TimeBucket dimension which i've found in the EquityDerivativesCube makes something similar but the buckets are created in a different manner.
How can i solve this problem?
Ok, i handle it out.
It is not necessary to make the round trip and to implement a dimension. It is easy done by levels and the a calculator.
Here the code from the EquityDerivativesCube.xml
<!-- Standard time buckets, bucketing performed at insertion -->
<dimension name="TimeBucket">
<properties>
<entry key="DimensionType" value="time" />
<entry key="IsAllMembersEnabled" value="true" />
</properties>
<level name="Year">
<properties>
<entry key="LevelType" value="TIME_YEARS" />
</properties>
<comparator pluginKey="ReverseOrder" />
</level>
<level name="Month">
<properties>
<entry key="LevelType" value="TIME_MONTHS" />
</properties>
<comparator pluginKey="Custom">
<order name="firstObjects">
<value>Jan</value>
<value>Feb</value>
<value>Mrz</value>
<value>Apr</value>
<value>Mai</value>
<value>Jun</value>
<value>Jul</value>
<value>Aug</value>
<value>Sep</value>
<value>Okt</value>
<value>Nov</value>
<value>Dez</value>
</order>
</comparator>
</level>
<!-- The Value Date level is the field Date -->
<level name="Value Date" property="Date">
<properties>
<entry key="LevelType" value="time" />
</properties>
<comparator pluginKey="ReverseOrder" />
</level>
</dimension>
I added the following snippet to PNLCalculator.enrichTrade:
...
pnl = pnlVega + pnlDelta;
// Year and month calculations BEGIN
final Calendar cal = CALENDAR.get();
cal.setTime(trade.getDate());
final int year = cal.get(Calendar.YEAR);
final String month = DateFormatSymbols.getInstance(GERMANY).getShortMonths()[cal.get(MONTH)];
// Year and month calculations END
// instantiate the result that will hold the enrichment data
final PNLCalculatorResult result = new PNLCalculatorResult();
...
// add them to the result
result.setYear(year);
result.setMonth(month);
...
I also extended the SanboxFields.xml with the two new fields:
...
<field name="Year" type="integer" />
<field name="Month" type="string" />
...
Cheers!
The TimeBucket dimension in the ActivePivot Sandbox application defines a custom bucketing based on financial time periods. Creating a standard year > month > day hierarchy is actually simpler and seamless in ActivePivot. In the description if the schema you need to declare three fields (one for year, one for month and one for the day).
<field name="Year" indexation="dictionary" />
<field name="Month" indexation="dictionary" />
<field name="Day" indexation="dictionary" />
And then you need to declare a dimension that references those fields.
<dimension name="Time">
<level name="Year" />
<level name="Month" />
<level name="Day" />
</dimension>
Then ActivePivot will build the time hierarchy incrementally, by introspecting the loaded records.
This will work automagically if the input records (objects) already contain a Year attribute, a Month attribute and a Day atribute (For instance if the input records are POJOs with getYear(), getMonth() and getDay() methods). If that is not the case and that for instance the input records only have a date attribute, you can either transform your records before puutting them into ActivePivot, or inject a calculator in ActivePivot (com.quartetfs.biz.pivot.classification.ICalculator) that will on the fly compute the three fields from the date. Look at the ActivePivot Sandbox application for an example of calculator.
Extracting those fields is usually done with standard Java code:
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
System.out.println("Date: " + date);
System.out.println("Year: " + calendar.get(Calendar.YEAR));
System.out.println("Month: " + calendar.get(Calendar.MONTH) + 1);
System.out.println("Day: " + calendar.get(Calendar.DAY_OF_MONTH));
About the ordering of members in the level of a dimension, ActivePivot per default uses the natural ordering of java objects (those that implement java.lang.Comparable interface) so dates and integers will be sorted from the lowest to the greatest. You can easily reverse that by declaring a "ReverseOrder" comparator on the target level(s).
<dimension name="Time">
<level name="Year">
<comparator pluginKey="ReverseOrder" />
</level>
<level name="Month">
<comparator pluginKey="ReverseOrder" />
</level>
<level name="Day">
<comparator pluginKey="ReverseOrder" />
</level>
</dimension>

Search Results XML Data returns first line of text as the result title instead of the title field for some .doc files

Excuse the very long title, I was just trying to be descriptive :)
I have a number of word documents stored in a document library in a document centre. For most of the documents when I search for a term, the content that's in the "Title" field is returned in the result's title node in the Search Result XML. However there are a number of documents that return the first line of text in the document's content as the title. This is very peculiar bahaviour and I can't seem to find a way to fix it. I've investigated the metadata property mappings and looked at the 'Title' property and it's retrieving the following mappings in this order:
Mail:5(Text)
People:PreferredName(Text)
Basic:displaytitle(Text)
ows_Title(Text)
As you might have guessed, these are the same as the default settings and have not been changed. I have attempted to adjust the mappings and reorder them but nothing fixes the problem. I don't see how any of these mappings would return the first line of text from a document when none of them detail it.
How the blazes do I get the search results to show the Title field of the documents?
This is the SPItem's XML:
ows_ContentTypeId="0x01010088DB89BAACA04F38A0BEE018DD0A5206009C6E9BFBC6CE4C099BF7D9D3BF986B550037DF08371674094BBD60CFE875673FD0"
ows_FileLeafRef="68;#LOE_CO_GRO600_310110.doc"
ows_Modified_x0020_By="SHAREPOINT\system"
ows_Created_x0020_By="SHAREPOINT\system"
ows_File_x0020_Type="doc"
ows_Title="Growth Programme"
ows_NotesAndInstructions="Use this letter where we facilitate growth programme sessions"
ows_DocID="CO_GRO610"
ows_DocumentPublicationDate="2006-11-01 00:00:00"
ows_TaxCatchAll=""
ows_TaxCatchAllLabel=""
ows__dlc_DocId="DOC-2047-3109"
ows__dlc_DocIdUrl="http://server/_layouts/DocIdRedir.aspx?ID=DOC-2047-3109, DOC-2047-3109"
ows_SectorGroup=""
ows_ServiceLine=""
ows_ID="68"
ows_ContentType="Engagement"
ows_Created="2010-08-24 11:37:19"
ows_Author="1073741823;#System Account"
ows_Modified="2010-08-25 14:03:47"
ows_Editor="1073741823;#System Account"
ows__ModerationStatus="0"
ows_FileRef="68;#DocumentCentre/EngagementLetters/LOE_CO_GRO600_310110.doc"
ows_FileDirRef="68;#DocumentCentre/EngagementLetters"
ows_Last_x0020_Modified="68;#2010-08-25 13:56:14"
ows_Created_x0020_Date="68;#2010-08-24 11:37:20"
ows_File_x0020_Size="68;#59392"
ows_FSObjType="68;#0"
ows_SortBehavior="68;#0"
ows_PermMask="0x7fffffffffffffff"
ows_CheckedOutUserId="68;#"
ows_IsCheckedoutToLocal="68;#0"
ows_UniqueId="68;#{ACE05805-6E2A-4035-A6D2-73CDF2962374}"
ows_ProgId="68;#"
ows_ScopeId="68;#{519A3EC0-039D-4F4C-A829-C9D17A9626E1}"
ows_VirusStatus="68;#59392"
ows_CheckedOutTitle="68;#"
ows__CheckinComment="68;#"
ows__EditMenuTableStart="LOE_CO_GRO600_310110.doc"
ows__EditMenuTableStart2="68"
ows__EditMenuTableEnd="68"
ows_LinkFilenameNoMenu="LOE_CO_GRO600_310110.doc"
ows_LinkFilename="LOE_CO_GRO600_310110.doc"
ows_LinkFilename2="LOE_CO_GRO600_310110.doc"
ows_DocIcon="doc"
ows_ServerUrl="/DocumentCentre/EngagementLetters/LOE_CO_GRO600_310110.doc"
ows_EncodedAbsUrl="http://server/DocumentCentre/EngagementLetters/LOE_CO_GRO600_310110.doc"
ows_BaseName="LOE_CO_GRO600_310110"
ows_FileSizeDisplay="59392"
ows_MetaInfo="[...]vti_cachedtitle:SR|Growth Programme
vti_title:SR|Growth Programme[...]"
ows__Level="1"
ows__IsCurrentVersion="1"
ows_ItemChildCount="68;#0"
ows_FolderChildCount="68;#0"
ows_SelectTitle="68"
ows_SelectFilename="68"
ows_Edit="0"
ows_owshiddenversion="4"
ows__UIVersion="512"
ows__UIVersionString="1.0"
ows_Order="6800.00000000000"
ows_GUID="{77095282-3E97-4703-9249-A6E888F5ED70}"
ows_WorkflowVersion="1"
ows_ParentVersionString="68;#"
ows_ParentLeafName="68;#"
Etag="{ACE05805-6E2A-4035-A6D2-73CDF2962374},4"
ows_Combine="0"
ows_RepairDocument="0"
ows_ServerRedirected="0"
This seems to be an issue when SharePoint 2010 indexes 2003 word documents (.doc).
I worked around this by using the Filename as the display property for all documents.
You have to edit the Search Results web part (I have shown my changes by ** the changes **):
Add Filename to the fetched items:
<Columns> **<Column Name="Filename"/>** <Column Name="WorkId"/> <Column Name="Rank"/> <Column Name="Title"/> <Column Name="Author"/> <Column Name="Size"/> <Column Name="Path"/> <Column Name="Description"/> <Column Name="Write"/> <Column Name="SiteName"/> <Column Name="CollapsingStatus"/> <Column Name="HitHighlightedSummary"/> <Column Name="HitHighlightedProperties"/> <Column Name="ContentClass"/> <Column Name="IsDocument"/> <Column Name="PictureThumbnailURL"/> <Column Name="PopularSocialTags"/> <Column Name="PictureWidth"/> <Column Name="PictureHeight"/> <Column Name="DatePictureTaken"/> <Column Name="ServerRedirectedURL"/> </Columns>
Then you will have to edit the XSLT to display the file name if the item is a document (make sure to uncheck Use Location Visualization. if you don't your changes will not take). You will have to search the xslt to find the section below. Again the items in-between the ** ** is what I added.
**<xsl:if test="isdocument = 'True'">
<xsl:value-of select="filename"/>
</xsl:if>
<xsl:if test="isdocument = 'False'">**
<xsl:choose>
<xsl:when test="hithighlightedproperties/HHTitle[. != '']">
<xsl:call-template name="HitHighlighting">
<xsl:with-param name="hh" select="hithighlightedproperties/HHTitle" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise><xsl:value-of select="title"/></xsl:otherwise>
</xsl:choose>
**</xsl:if>**

How to set default value for a column of content type in Sharepoint

i create a content type using feature as below
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field ID ="{4C939423-2090-413d-B241-724D9B66F74B}"
Name="VersionNumer"
DisplayName="Version Number"
Type="Text"
Required="TRUE"
Group="CT" >
<Default>0</Default>
</Field>
<Field ID ="{33E51B7A-FEE2-4995-B4BB-9F3F909C1015}"
Name="DocumentType"
DisplayName="Document Type"
Type="Choice"
Required="TRUE"
Group="CT">
<Default>Other</Default>
<CHOICES>
<CHOICE>Document</CHOICE>
<CHOICE>Excel</CHOICE>
<CHOICE>PowerPoint</CHOICE>
<CHOICE>Other</CHOICE>
</CHOICES>
</Field>
<ContentType ID="0x0101000728167cd9c94899925ba69c4af6743e"
Name="myCT"
Group="myCT"
Description="myCT"
Version="0">
<FieldRefs>
<FieldRef ID="{4C939423-2090-413d-B241-724D9B66F74B}" Name="VersionNumber" DisplayName="Version Number" Required="TRUE" />
<FieldRef ID="{33E51B7A-FEE2-4995-B4BB-9F3F909C1015}" Name="DocumentType" DisplayName="Document Type" Required="TRUE" />
</FieldRefs>
</ContentType>
</Elements>
How can i set default value for VersionNumer is 0 and default value for DocumentType is Other? I used default tag but it was not efficent.
And another question, how to force user to input VersionNumer and DocumentType. I used atrtibute required="true" but it was not successful.
Thanks in advance.
I've tried this in my environment, it works perfectly. I copy 'n' pasted the contents of elements.xml and didn't make a single modification.
Try this:
Delete your existing site columns and content type (in that order)
Deactivate your feature
IISRESET
Activate your feature again and check if the default values are ok, they should be
Add your choices field and after that put the default tag
enter code here
<CHOICES>
<CHOICE>Document</CHOICE>
<CHOICE>Excel</CHOICE>
<CHOICE>Other</CHOICE>
</CHOICES>
<Default>Other</Default>

Resources