I've created a custom component with these attributes:
CustomComponent
String id
Integer sku
String color
List variants
Price price
Variant and price are custom objects.
When this CmsComponent gets populated and converted using the DefaultCmsItemConverter OOTB :
de.hybris.platform.cmsfacades.rendering.populators.CMSComponentModelToDataRenderingPopulator#populate (line 46)
de.hybris.platform.cmsfacades.cmsitems.converter.DefaultCMSItemConverter#convert(de.hybris.platform.core.model.ItemModel)
It only populates simple attributes like id, sku and color. The Custom Objects like Price and Variants doesn't populate into componentData.setOtherProperties(getCmsItemConverter().convert(componentModel));
How can I get a complete population including inner Object attributes ?
The steps are:
Create new Populator for variants and price
Assign the newly created Populator to the existing Converter
Check https://wiki.hybris.com/pages/viewpage.action?pageId=294094358 for an example.
Update: one of the following should work for you
<bean parent="modifyPopulatorList">
<property name="list" ref="cmsItemConverter" />
<property name="add" ref="myPopulatorVariantAndPrice" />
</bean>
or
<bean parent="modifyPopulatorList">
<property name="list" ref="cmsItemConverterCustomPopulators" />
<property name="add" ref="myPopulatorVariantAndPrice" />
</bean>
Related
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).
I would like to change values in domain.xml ( JBoss Configuration file ). Please suggest me the best way to do it with sample examples to change it.
I have found the following ways. But No idea, How to use the following functions for xml files.
( i ) inline_template
( ii ) regsubst
I have to change the following four property as per each group. For Each Group, values of the 4 properties will be changed. Please suggest me the best Industry practise standard.
<system-properties>
<property name="jboss.default.multicast.address" value="230.0.1.1" boot-time="true"/>
<property name="modcluster.balancer.name" value="mylb" boot-time="true"/>
<property name="modcluster.proxylist" value="172.28.168.153:6777" boot-time="true"/>
<property name="mycluster.modcluster.lbgroup" value="coollb" boot-time="true"/>
</system-properties>
inline_template are executed on master, so they won't solve your problem.
The easiest solution is erb templates. But this means that you will control from puppet the entire file, not only the properties.
The best solution: there seems to be an augeas lens for xml: https://twiki.cern.ch/twiki/bin/view/Main/TerjeAndersenAugeas
Edit:
have an erb template in your module (templates/jboss_config.xml.erb)
<bla bla>....
<system-properties>
<property name="jboss.default.multicast.address" value="<%= #multicast_address %>" boot-time="true"/>
<property name="modcluster.balancer.name" value="<%= #balancer_name %>" boot-time="true"/>
<property name="modcluster.proxylist" value="<%= #proxylist %>" boot-time="true"/>
<property name="mycluster.modcluster.lbgroup" value="<%= #lbgroup %>" boot-time="true"/>
</system-properties>
</bla bla>....
In your puppet class declare the parameters/variables (those can came from hiera also, if you want to do overwrites based on some facts):
$multicast_address = '230.0.1.1'
$balancer_name = 'mylb'
$proxylist = '172.28.168.153:6777'
$lbgroup = 'coollb'
# and write your file:
file { 'jboss_config_file':
ensure => file,
path => '/path/to/jboss/config/file.xml',
content => template("${module_name}/jboss_config.xml.erb"),
}
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
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>
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>