Hybris redeclare relation - java

I'm trying to create a relation between Product2Componen
<relation code="Product2Components" localized="false" autocreate="true">
<deployment table="ProdsCompRels" typecode="30008" />
<sourceElement qualifier="product" type="Product" cardinality="one" collectiontype="list">
<modifiers read="true" write="true" search="true" optional="true" />
</sourceElement>
<targetElement qualifier="components" type="SimpleCMSComponent" cardinality="many">
<modifiers read="true" write="true" search="true" optional="true" />
</targetElement>
</relation>
However , hybris OOTB has already a relation within product2ProductDetailComponent:
<relation code="ProductDetailComponentsForProduct" generate="true" localized="false" autocreate="true">
<sourceElement qualifier="productDetailComponents" type="ProductDetailComponent" cardinality="many" collectiontype="list">
<modifiers read="true" write="true" search="true" optional="true" />
</sourceElement>
<targetElement qualifier="product" type="Product" cardinality="one">
<modifiers read="true" write="true" search="true" optional="true" />
</targetElement>
</relation>
And when I compile it returns me this error because of this already existing relation that is completly useless to me:
Attribute CmsLinkComponent.product(Product):((cms2))::YAttributeDescriptor[cms2-items.xml:190(RelationTypeTagListener)][JALO] duplicates inherited attribute SimpleCMSComponent.product(Product):((puigcore))::YAttributeDescriptor[puigcore-items.xml:488(RelationTypeTagListener)][JALO]. Remove it or specify it as redeclared
How can I redeclare a relation ? Or what should I do here ?

Since the OOTB ProductDetailComponent extends SimpleCMSComponent and you want to use SimpleCMSComponent so I think you can simply use OOTB relation.
But if you really want to decare your own attribute/relation then you have to provide a different qualifier other than "product", as the product qualifier is already been used in the OOTB relation ProductDetailComponentsForProduct, where ProductDetailComponent is the subtype of SimpleCMSComponent.
<relation code="Product2Components" localized="false" autocreate="true">
<deployment table="ProdsCompRels" typecode="30008" />
<sourceElement qualifier="productRef" type="Product" cardinality="one" collectiontype="list">
<modifiers read="true" write="true" search="true" optional="true" />
</sourceElement>
<targetElement qualifier="components" type="SimpleCMSComponent" cardinality="many">
<modifiers read="true" write="true" search="true" optional="true" />
</targetElement>
</relation>

Related

error compiling project netbeans with proguard

I'm trying to add proguard to obfuscate my java code with nebeans. I've followed a blog where it says that I must add some code in build.xml. I've modified build.xml but it gives me an error:
jar doesn't support the nested "property" element.
I added proguard location and all code of the blog but always gives me that error. Could you help me please? Thanks.
Blog is https://dzone.com/articles/obfuscating-netbeans-java-appl
I put the code of my build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="AFB_CONEXIONES_DENTRO" default="default" basedir=".">
<description>Builds, tests, and runs the project AFB_CONEXIONES_DENTRO.</description>
<import file="nbproject/build-impl.xml"/>
<target name="-post-jar">
<jar jarfile="dist/AFB_con_librerias.jar">
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
<zipfileset src="lib/ojdbc6.jar" excludes="META-INF/*" />
<zipfileset src="lib/proguard.jar" excludes="META-INF/*" />
<zipfileset src="lib/log4j-1.2.17.jar" excludes="META-INF/*" />
<zipfileset src="lib/postgresql-9.2-1002.jdbc4.jar" excludes="META-INF/*" />
<property name="proguard.jar.path" value="/home/y9c4db/Downloads/proguard6.1.1/lib/proguard.jar" />
<taskdef resource="proguard/ant/task.properties"
classpath="${proguard.jar.path}" />
<echo message="Obfuscating ${dist.jar}..."/>
<mkdir dir="${build.dir}/obfuscated"/>
<proguard printmapping="${build.dir}/obfuscated/${application.title}.map"
renamesourcefileattribute="SourceFile" ignorewarnings="true">
<!-- Specify the input jars, output jars, and library jars. -->
<injar file="${dist.jar}" />
<outjar file="${build.dir}/obfuscated/BalloonWindCore_JavaSE.jar" />
<libraryjar path="${javac.classpath}" />
<libraryjar file="${java.home.path}/jre/lib/rt.jar" />
<!-- Keep some useful attributes. -->
<keepattribute name="InnerClasses" />
<keepattribute name="SourceFile" />
<keepattribute name="LineNumberTable" />
<keepattribute name="Deprecated" />
<keepattribute name="*Annotation*" />
<keepattribute name="Signature" />
<!-- Preserve all public classes, and their public and protected fields and methods. -->
<keep access="public">
<field access="public protected" />
<method access="public protected" />
</keep>
<!-- Preserve all .class method names. -->
<keepclassmembernames access="public">
<method type ="java.lang.Class"
name ="class$"
parameters="java.lang.String" />
<method type ="java.lang.Class"
name ="class$"
parameters="java.lang.String,boolean" />
</keepclassmembernames>
<!-- Preserve all native method names and the names of their classes. -->
<keepclasseswithmembernames>
<method access="native" />
</keepclasseswithmembernames>
<!-- Preserve the methods that are required in all enumeration classes. -->
<keepclassmembers extends="java.lang.Enum">
<method access="public static"
type="**[]"
name="values"
parameters="" />
<method access="public static"
type="**"
name="valueOf"
parameters="java.lang.String" />
</keepclassmembers>
<!-- Explicitly preserve all serialization members. The Serializable
interface is only a marker interface, so it wouldn't save them.
You can comment this out if your library doesn't use serialization.
With this code serializable classes will be backward compatible -->
<keepnames implements="java.io.Serializable"/>
<keepclassmembers implements="java.io.Serializable">
<field access ="final"
type ="long"
name ="serialVersionUID" />
<field access ="!static !transient"
name ="**"/>
<field access ="!private"
name ="**"/>
<method access ="!private"
name ="**"/>
<method access ="private"
type ="void"
name ="writeObject"
parameters="java.io.ObjectOutputStream" />
<method access ="private"
type ="void"
name ="readObject"
parameters="java.io.ObjectOutputStream" />
<method type ="java.lang.Object"
name ="writeReplace"
parameters="" />
<method type ="java.lang.Object"
name ="readResolve"
parameters="" />
</keepclassmembers>
<!-- Your application may contain more items that need to be preserved;
typically classes that are dynamically created using Class.forName -->
</proguard>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
</manifest>
</jar>
</target>
</project>
Please any help? Thanks

Infinispan JDBC Cache Store

I want to use Infinispan JDBC Cache Store instead of LevelDb Cache Store.
Here's below my configuration:
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
xmlns="urn:infinispan:config:6.0"
xmlns:jdbc="urn:infinispan:config:jdbc:6.0" >
<global>
<globalJmxStatistics enabled="false" allowDuplicateDomains="true"/>
</global>
<!-- Define the cache loaders (i.e., cache stores). Passivation is false
because we want *all* data to be persisted, not just what doesn't fit
into memory. -->
<persistence>
<mixedKeyedJdbcStore fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
<simpleConnection connectionUrl="jdbc:postgresql://localhost:5432/infinispan_binary_based" driverClass="org.postgresql.Driver" username="postgres" password="postgres"/>
<stringKeyedTable prefix="ISPN_MIXED_STR_TABLE" createOnStart="true" dropOnExit="true">
<idColumn name="ID_COLUMN" type="VARCHAR(255)" />
<dataColumn name="DATA_COLUMN" type="BINARY" />
<timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
</stringKeyedTable>
<binaryKeyedTable prefix="ISPN_MIXED_BINARY_TABLE" createOnStart="true" dropOnExit="true">
<idColumn name="ID_COLUMN" type="VARCHAR(255)" />
<dataColumn name="DATA_COLUMN" type="BINARY" />
<timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
</binaryKeyedTable>
</mixedKeyedJdbcStore>
</persistence>
</namedCache>
but I keep getting this exception:
Message: Unexpected element '{urn:infinispan:config:jdbc:6.0}mixedKeyedJdbcStore'
at org.infinispan.configuration.parsing.ParserRegistry.parseElement(ParserRegistry.java:139) [infinispan-core-6.0.2.Final.jar:6.0.2.Final]
at org.infinispan.configuration.parsing.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:37) [infinispan-core-6.0.2.Final.jar:6.0.2.Final]
at org.infinispan.configuration.parsing.Parser60.parsePersistence(Parser60.java:558) [infinispan-core-6.0.2.Final.jar:6.0.2.Final]
I removed leveldb cache store jar from my dependencies and replace it with jdbc cache store jar.
Could you tell me if I missed anything?
Help please?
Thank you in advance.
You're declaring a namespace called jdbc, but not using it. You need to either prefix all the tags in mixedKeyedJdbcStore with jdbc:, or use a default namespace like this:
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
xmlns="urn:infinispan:config:6.0"
xmlns:jdbc="urn:infinispan:config:jdbc:6.0" >
<global>
<globalJmxStatistics enabled="false" allowDuplicateDomains="true"/>
</global>
<!-- Define the cache loaders (i.e., cache stores). Passivation is false
because we want *all* data to be persisted, not just what doesn't fit
into memory. -->
<namedCache name="testCache">
<persistence>
<mixedKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:6.0" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
<simpleConnection connectionUrl="jdbc:postgresql://localhost:5432/infinispan_binary_based" driverClass="org.postgresql.Driver" username="postgres" password="postgres"/>
<stringKeyedTable prefix="ISPN_MIXED_STR_TABLE" createOnStart="true" dropOnExit="true">
<idColumn name="ID_COLUMN" type="VARCHAR(255)" />
<dataColumn name="DATA_COLUMN" type="BINARY" />
<timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
</stringKeyedTable>
<binaryKeyedTable prefix="ISPN_MIXED_BINARY_TABLE" createOnStart="true" dropOnExit="true">
<idColumn name="ID_COLUMN" type="VARCHAR(255)" />
<dataColumn name="DATA_COLUMN" type="BINARY" />
<timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
</binaryKeyedTable>
</mixedKeyedJdbcStore>
</persistence>
</namedCache>
Your configuration was also missing a starting namedCache tag, but I assume it was a copypaste mistake, otherwise the error message would be different.

Parsing xml with many attributes using Java JAXB

I have following xml which I am trying to parse using JAXB.
<?xml version="1.0" encoding="UTF-8"?>
<DataSet Name="core_donor" Version="2-0" SchemaVersion="1-0" SchemaDate="2014-01-16">
<DataPoints>
<DataPoint Name="donor_id" Value="105272" />
<DataPoint Name="surname" Value="TWO" />
<DataPoint Name="forename" Value="SCENARIO" />
<DataSubSet Name="blood_gas">
<DataPoints>
<DataPoint Name="blood_gas_no" Value="1" />
<DataPoint Name="blood_gas_date" Value="07/10/2014 10:15" />
</DataPoints>
<DataPoints>
<DataPoint Name="blood_gas_no" Value="2" />
<DataPoint Name="blood_gas_date" Value="07/10/2014 11:20" />
</DataPoints>
</DataSubSet>
<DataSubSet Name="liver_function">
<DataPoints>
<DataPoint Name="liver_function_no" Value="1" />
<DataPoint Name="liver_function_sample_date" Value="07/10/2014 11:10" />
</DataPoints>
<DataPoints>
<DataPoint Name="liver_function_no" Value="2" />
<DataPoint Name="liver_function_sample_date" Value="07/10/2014 13:52" />
</DataPoints>
</DataSubSet>
</DataPoints>
</DataSet>
I would be thankful if someone could point me how to achieve the parsing in java using JAXB.
Thanks!
For starters follow the below example
http://www.mkyong.com/java/jaxb-hello-world-example/
But DataPoints will be your RootElement , if am not wrong also refererence
check some examples for DOM parsing to traverse over the child nodes and read them.

ZK - Adding component to Treeitem depending on model content

So, I want to add a specific component (either Checkbox or Textbox) depending on the AttType field of my current node. My zul file looks like this:
<tree id="permissionTree" width="100%"
model="#bind(vm.treeModel)" style="text-align:left;">
<treecols>
<treecol label="Item" width="400px" />
<treecol label="Wert" />
</treecols>
<template name="model" var="node">
<treeitem>
<treerow>
<treecell label="#load(node.data.name)" />
<treecell> HERE COMPONENT DEPENDING ON node.data.AttType </treecell>
</treerow>
</treeitem>
</template>
</tree>
How can I accomplish this? Oh and I want the Textbox/Checkbox value to be bound to my model as a String, that would be pretty nice.
Thanks for any suggestions.
Edit: I made a little "workaround" for myself. Since I have only 3 possible input types, I just defined them hard-coded:
<tree id="permissionTree" width="100%"
model="#bind(vm.treeModel)" style="text-align:left;">
<treecols>
<treecol label="Item" />
<treecol label="Wert" />
</treecols>
<template name="model" var="node">
<treeitem open="#bind(node.open)" onClick="#command('expandNode', item=node)">
<treerow>
<treecell label="#load(node.data.name)" />
<treecell>
<textbox visible="#load(node.data.isTextbox)" value="#bind(node.data.value)" />
<textbox visible="#load(node.data.isTextarea)" rows="6" width="300px" value="#bind(node.data.value)" />
<checkbox visible="#load(node.data.isCheckbox)" checked="#bind(node.data.checkboxValue)" />
</treecell>
</treerow>
</treeitem>
</template>
</tree>
And in the constructor of a TreeNode I set the isTextbox/isTextarea/isCheckbox values according to the type. This way the model binding still works :)
As you asked in your previous question: use treeitem renderer and add items you need there. I don't think binding will work for new components.

EDI file generation using SMOOKS

How can I convert XML file to EDI file using SMOOKS?
I am able to convert EDI to XML, in fact this is part of examples provided by SMOOKS.
Based on your question i tried to do some research on it . Please check if it helps you .
So here's the source edi file that is to be transformed:
HDR*1*0*59.97*64.92*4.95*Wed Nov 15 13:45:28 EST 2006
CUS*user1*Harry^Fletcher*SD
ORD*1*1*364*The 40-Year-Old Virgin*29.98
ORD*2*1*299*Pulp Fiction*29.99
And this is the expected result of our transformation:
<Order>
<header>
<order-id>1</order-id>
<status-code>0</status-code>
<net-amount>59.97</net-amount>
<total-amount>64.92</total-amount>
<tax>4.95</tax>
<date>Wed Nov 15 13:45:28 EST 2006</date>
</header>
<customer-details>
<username>user1</username>
<name>
<firstname>Harry</firstname>
<lastname>Fletcher</lastname>
</name>
<state>SD</state>
</customer-details>
<order-item>
<position>1</position>
<quantity>1</quantity>
<product-id>364</product-id>
<title>The 40-Year-Old Virgin</title>
<price>29.98</price>
</order-item>
<order-item>
<position>2</position>
<quantity>1</quantity>
<product-id>299</product-id>
<title>Pulp Fiction</title>
<price>29.99</price>
</order-item>
</Order>
The Smooks Configuration
We simply specify the SmooksEDIParser  as the stream parser. More transformation configurations could be added to transform this message further.
Here's the configuration ("smooks-config.xml"):
<?xml version="1.0"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:edi="http://www.milyn.org/xsd/smooks/edi-1.1.xsd">
<!--
Configure the EDI Reader to process the message stream into a stream of SAX events.
-->
<edi:reader mappingModel="/example/edi-to-xml-order-mapping.xml" />
</smooks-resource-list>
Here's the edi mapping ("/src/main/java/example/edi-to-xml-order-mapping.xml"):
<?xml version="1.0" encoding="UTF-8"?>
<medi:edimap xmlns:medi="http://www.milyn.org/schema/edi-message-mapping-1.0.xsd">
<medi:description name="DVD Order" version="1.0" />
<medi:delimiters segment="
" field="*" component="^" sub-component="~" />
<medi:segments xmltag="Order">
<medi:segment segcode="HDR" xmltag="header">
<medi:field xmltag="order-id" />
<medi:field xmltag="status-code" />
<medi:field xmltag="net-amount" />
<medi:field xmltag="total-amount" />
<medi:field xmltag="tax" />
<medi:field xmltag="date" />
</medi:segment>
<medi:segment segcode="CUS" xmltag="customer-details">
<medi:field xmltag="username" />
<medi:field xmltag="name">
<medi:component xmltag="firstname" />
<medi:component xmltag="lastname" />
</medi:field>
<medi:field xmltag="state" />
</medi:segment>
<medi:segment segcode="ORD" xmltag="order-item" maxOccurs="-1">
<medi:field xmltag="position" />
<medi:field xmltag="quantity" />
<medi:field xmltag="product-id" />
<medi:field xmltag="title" />
<medi:field xmltag="price" />
</medi:segment>
</medi:segments>
</medi:edimap>
Executing The Transformation:
// Instantiate Smooks with the config...
Smooks smooks = new Smooks("smooks-config.xml");
try {
// Filter the input message to the outputWriter...
smooks.filterSource(new StreamSource(messageIn), new
StreamResult(messageOut));
} finally {
smooks.close();
}

Categories

Resources