Can not edit Doctrine ArrayCollection - doctrine-orm

I have a problem with editing an Doctrine2 ArrayCollection of a many-to-many assosciation.
Persisting an new entity is no problem and works fine. But if I would like to persist an entity with new added CollectionItems I got an
Doctrine\ORM\ORMInvalidArgumentException
I use the xml-mapping, the mapping files are the following:
receipt:
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Application\Entity\Receipt" table="receipt" repository-class="Application\Repositories\ReceiptRepository">
<indexes>
<index name="FK_receipt_profession" columns="professsion"/>
<index name="FK_receipt_items_needed" columns="items"/>
</indexes>
<id name="rId" type="integer" column="r_id">
<generator strategy="IDENTITY"/>
</id>
<field name="name" type="string" column="name" length="100" nullable="false"/>
<many-to-one field="profession" target-entity="Application\Entity\Profession">
<join-columns>
<join-column name="profession" referenced-column-name="p_id"/>
</join-columns>
</many-to-one>
<many-to-many field="items" target-entity="Application\Entity\ItemsNeeded" inversed-by="receipt">
<!--<cascade><cascade-all/></cascade>-->
<join-table name="receipt_x_items_needed">
<join-columns>
<join-column name="receipt" referenced-column-name="r_id"/>
</join-columns>
<inverse-join-columns>
<join-column name="itemNeeded" referenced-column-name="in_id"/>
</inverse-join-columns>
</join-table>
</many-to-many>
</entity>
</doctrine-mapping>
ItemsNeeded:
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Application\Entity\ItemsNeeded" table="items_needed" repository-class="Application\Repositories\ItemsneededRepository">
<indexes>
<index name="FK_items_needed_receipt" columns="receipt_id"/>
<index name="item_id" columns="item_id"/>
</indexes>
<id name="inId" type="integer" column="in_id">
<generator strategy="IDENTITY"/>
</id>
<field name="count" type="integer" column="count" nullable="false"/>
<many-to-one field="item" target-entity="Application\Entity\Items">
<join-columns>
<join-column name="item_id" referenced-column-name="i_id"/>
</join-columns>
</many-to-one>
<many-to-many field="receipt" target-entity="Application\Entity\Receipt" mapped-by="items"/>
</entity>
</doctrine-mapping>
and items:
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Application\Entity\Items" table="items" repository-class="Importer\Repository\ItemRepository">
<unique-constraints>
<unique-constraint name="buffed_id" columns="buffed_id"/>
</unique-constraints>
<id name="iId" type="integer" column="i_id">
<generator strategy="IDENTITY"/>
</id>
<field name="name" type="string" column="name" length="100" nullable="false"/>
<field name="buffedId" type="integer" column="buffed_id" nullable="false"/>
</entity>
</doctrine-mapping>
The receipt table has an many-to-many relation through the crosstable "receipt_x_items_needed".
If I call $receipt->addItem($item); and $item is an already existing item from the itemtable I got the following error:
A new entity was found through the relationship 'Application\Entity\ItemsNeeded#item' that was not configured to cascade persist operations for entity: Application\Entity\Items#0000000041f6e49000000000651183aa. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example #ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem implement 'Application\Entity\Items#__toString()' to get a clue.
But this is no new entity. All data are correctly set and as I wrote, if I add e new receipt all works fine.

Related

Cocos2d-x TiledMap, return a nullptr when invoking getLayer() to get the collision layer?

I have been struggling with the null pointer for hours! It happened when I used the getLayer() method to get a layer from the tiled map in cocos2d-x (the tailed map is edited using the Tailed Map Editor).
map = TMXTiledMap::create("map/map1.tmx");
map->setAnchorPoint(Vec2(0.5, 0.5));
map->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2 - 40));
this->addChild(map, 0, 100);
collidable = map->getLayer("collide")
collidable->setVisible(false);
The program didn't find the "collide" layer (it's a tiled layer) in my tailed map. However, it indeed exists in the TMX file :
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" tiledversion="1.1.5" orientation="orthogonal" renderorder="right-down" width="24" height="18" tilewidth="40" tileheight="40" infinite="0" nextlayerid="14" nextobjectid="2">
<tileset firstgid="1" name="Background" tilewidth="40" tileheight="40" tilecount="7" columns="7">
<image source="mapItems/background.png" width="280" height="40"/>
</tileset>
<tileset firstgid="8" name="tiles" tilewidth="40" tileheight="40" tilecount="16" columns="8">
<image source="mapItems/tiles.png" width="320" height="80"/>
</tileset>
<tileset firstgid="24" source="mapItems/collide.tsx"/>
<layer id="5" name="background" width="24" height="18">
<data encoding="base64" compression="zlib">
...(some code)
</layer>
<layer id="11" name="collide" width="24" height="18">
<properties>
<property name="collidable" value="true"/>
</properties>
<data encoding="base64" compression="zlib">
...
</data>
</layer>
<layer id="6" name="bricks" width="24" height="18">
<data encoding="base64" compression="zlib">
...
</data>
</layer>
<layer id="7" name="tops" width="24" height="18">
<data encoding="base64" compression="zlib">
...
</data>
</layer>
</map>
Moreover, I set breakpoint in the getLayer() method, and the program traverses and find all layers except the collide layer. Anyone can show me how to deal with this issue?
Okay, finally I solve this problem (4 hours since it occurred)... Despite I don't even know why.
The solution is editing the collide.tsx file. I tried to read it and found a sentence:
<image source="collide.png" trans=ff00ff width="40" height="40"/>
And this "trans=" seemed quite weird... So I deleted it. Then the issue was resolved.

Why authorize purchase api returning numericString xml field

i am sending purchase request in xml with createcustomer profile.
customerProfileId is returning good but customerpayment profile id is returning in field customerPaymentProfileIdList > numericString.
here is full response.
<?xml version="1.0" encoding="utf-8"?>
<createTransactionResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<messages>
<resultCode>Ok</resultCode>
<message>
<code>I00001</code>
<text>Successful.</text>
</message>
</messages>
<transactionResponse>
<responseCode>1</responseCode>
<authCode>R7BVRZ</authCode>
<avsResultCode>Y</avsResultCode>
<cvvResultCode>P</cvvResultCode>
<cavvResultCode>2</cavvResultCode>
<transId>60032752664</transId>
<refTransID />
<transHash>C1F3242645F7F118D709452E5758AF35</transHash>
<testRequest>0</testRequest>
<accountNumber>XXXX0015</accountNumber>
<accountType>MasterCard</accountType>
<messages>
<message>
<code>1</code>
<description>This transaction has been approved.</description>
</message>
</messages>
<transHashSha2 />
</transactionResponse>
<profileResponse>
<messages>
<resultCode>Ok</resultCode>
<message>
<code>I00001</code>
<text>Successful.</text>
</message>
</messages>
<customerProfileId>1813409569</customerProfileId>
<customerPaymentProfileIdList>
<numericString>1808086931</numericString>
</customerPaymentProfileIdList>
<customerShippingAddressIdList />
</profileResponse>
</createTransactionResponse>

how to refer outputfield from derivedfield in pmml

I have derivedfields in my pmml I want to use them as outputfields. So I want to refer outputfield from derivedfield. But sas application throw an error. Error is :
ERROR: Variable Z_DD_OCCUPATION_ID is not defined.
How can I set outputfield from derived field?
Here is my pmml which doesn't work
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<PMML version="4.2"
xmlns="http://www.dmg.org/PMML-4_2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header copyright="Copyright(c) 2002 SAS Institute Inc., Cary, NC, USA. All Rights Reserved.">
<Application name="SAS(r)" version="9.4"/>
<Timestamp>2016-06-23 15:36:04</Timestamp>
</Header>
<DataDictionary numberOfFields="26">
<DataField name="CH_INT_FLG_CRR" optype="continuous" dataType="double"/>
<DataField name="TD_SALE_FLG_00M_5" optype="categorical" dataType="string"/>
<DataField name="TARGET_NUM" optype="categorical" dataType="double"/>
</DataDictionary>
<TransformationDictionary>
</TransformationDictionary>
<RegressionModel functionName="classification" targetFieldName="TARGET_NUM" normalizationMethod="logit">
<MiningSchema>
<MiningField name="CH_INT_FLG_CRR" usageType="active" optype="continuous"/>
<MiningField name="TD_SALE_FLG_00M_5" usageType="active" optype="categorical"/>
<MiningField name="TARGET_NUM" usageType="target" optype="categorical"/>
</MiningSchema>
<Output>
<OutputField name="I_TARGET_NUM" displayName="Into: TARGET_NUM" optype="categorical" dataType="string" targetField="TARGET_NUM" feature="predictedValue"/>
<OutputField name="U_TARGET_NUM" displayName="Unnormalized Into: TARGET_NUM" optype="categorical" dataType="string" targetField="TARGET_NUM" feature="predictedDisplayValue"/>
<OutputField name="P_TARGET_NUM1" displayName="Predicted: TARGET_NUM=1" optype="continuous" dataType="double" targetField="TARGET_NUM" feature="probability" value="1"/>
<OutputField name="P_TARGET_NUM0" displayName="Predicted: TARGET_NUM=0" optype="continuous" dataType="double" targetField="TARGET_NUM" feature="probability" value="0"/>
<OutputField name="out_1" optype="continuous" dataType="double" feature="transformedValue">
<FieldRef field="Z_DD_OCCUPATION_ID"/>
</OutputField>
<OutputField name="out_2" optype="continuous" dataType="double" feature="transformedValue">
<FieldRef field="Z_CH_INT_FLG_CRR"/>
</OutputField>
</Output>
<Targets>
<Target field="TARGET_NUM" optype="categorical">
<TargetValue value="1" displayValue="1" priorProbability="0.5000049143"/>
<TargetValue value="0" displayValue="0" priorProbability="0.4999950857"/>
</Target>
</Targets>
<LocalTransformations>
<DerivedField name="Z_DD_OCCUPATION_ID" displayName="Z_DD_OCCUPATION_ID" optype="continuous" dataType="double" >
<MapValues outputColumn="return" defaultValue="99.9">
<FieldColumnPair column="condition" field="TD_SALE_FLG_00M_5"/>
<InlineTable>
<row>
<condition>9999</condition>
<return>-0.0992686543837357</return>
</row>
<row>
<condition>7130</condition>
<return>-0.010300374749499</return>
</row>
</InlineTable>
</MapValues>
</DerivedField>
<DerivedField name="Z_CH_INT_FLG_CRR" displayName="Z_CH_INT_FLG_CRR" optype="continuous" dataType="double">
<Discretize field="CH_INT_FLG_CRR" >
<DiscretizeBin binValue="0.0154213834">
<Interval closure="openOpen" rightMargin="0"/>
</DiscretizeBin>
<DiscretizeBin binValue="-0.025845983">
<Interval closure="closedClosed" leftMargin="0" rightMargin="0"/>
</DiscretizeBin>
<DiscretizeBin binValue="0.0154213834">
<Interval closure="openOpen" leftMargin="0"/>
</DiscretizeBin>
</Discretize>
</DerivedField>
</LocalTransformations>
<RegressionTable intercept="0.0203226371" targetCategory="1">
<NumericPredictor name="Z_CH_INT_FLG_CRR" coefficient="7.5086455767" />
<NumericPredictor name="Z_DD_OCCUPATION_ID" coefficient="3.2" />
</RegressionTable>
<RegressionTable intercept="0" targetCategory="0"/>
</RegressionModel>
</PMML>
If I use datadictionary columns instead of derived fields, it works perfectly.
For example If I convert
<OutputField name="out_1" optype="continuous" dataType="double" feature="transformedValue">
<FieldRef field="Z_DD_OCCUPATION_ID"/>
</OutputField>
<OutputField name="out_2" optype="continuous" dataType="double" feature="transformedValue">
<FieldRef field="Z_CH_INT_FLG_CRR"/>
</OutputField>
to
<OutputField name="out_1" optype="continuous" dataType="double" feature="transformedValue">
<FieldRef field="TD_SALE_FLG_00M_5"/>
</OutputField>
<OutputField name="out_2" optype="continuous" dataType="double" feature="transformedValue">
<FieldRef field="CH_INT_FLG_CRR"/>
</OutputField>
it works. Because in this case, I refer outputfield from datadictionary columns. But actually I need to use derivedfields in outputfields. How can I refer outputfields from derivedfields?
You need to move your derived fields from LocalTransformations (ie. local scope) to TransformationDictionary (ie. global scope).
PMML 4.2 does not permit referencing local derived fields from output fields. The "logic" is that you cannot reference a field before it has been seen by the PMML parser. In you example, OutputField#name=out_1 element occurs before DerivedField#name=Z_DD_OCCUPATION_ID element.
PMML 4.3 relaxed this rule. See http://mantis.dmg.org/view.php?id=142 for details.

Doctrine value object with one field only

Currently I use Doctrine2 with value object, it's working great. The problem when I use value object with only one field, for example:
$this->repository->findBy(array('email' => 'name#domain.com')); //This is not working
$this->repository->findBy(array('email.email' => 'name#domain.com')); //This is work great
The question is, how to make $this->repository->findBy(array('email' => 'name#domain.com')); working?
This is my doctrine mapping
User.orm.xml
<!-- User.orm.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
<entity name="Domain\User\Entity\User" table="users" repository-class="Infrastructure\User\Repository\UserRepository">
<id name="id" type="guid">
<generator strategy="UUID"/>
</id>
<embedded name="email" class="Shared\ValueObject\Email" use-column-prefix="false" />
</entity>
</doctrine-mapping>
Email.orm.xml
<!-- Email.orm.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<embeddable name="Shared\ValueObject\Email">
<field name="email" type="string" length="80" />
</embeddable>
</doctrine-mapping>
Thank you for your help, and sorry for my bad english.
Unfortunately according to code this is not possible. Field name always be
$property . "." . $fieldMapping['fieldName'];

Adding New Artifact Types and New Record to Artifact Types in WSO2 Gov. Reg 4.6

I am getting an error when adding a new record to a new artifact type I created. The error is as follows
failed to add/edit artifact details. A valid qualified name was not set for this artifact
I created a new artifact type called 'Domain'. The artifact type was added but I cannot add new records to it. Get the same error as above when I add new record to Domain artifact type. My xml is attached.
<?xml version="1.0"?>
<artifactType type="application/vnd.wso2-domain+xml" shortName="domain" singularLabel="Domain" pluralLabel="Domains" hasNamespace="false" iconSet="9">
<storagePath>/domains/#{overview_domain}/#{overview_parentname}/domain</storagePath>
<nameAttribute>overview_domain</nameAttribute>
<ui>
<list>
<column name="Domain">
<data type="text" value="overview_domain"/>
</column>
<column name="Parent Domain">
<data type="text" value="overview_parentname"/>
</column>
</list>
</ui>
<content>
<table name="Domain">
<field type="options" required="true">
<name label="Domain Name">Domain Name</name>
<values>
<value>Research</value>
<value>Development</value>
<value>Medicine</value>
<value>Marketing and Sales</value>
<value>Operations</value>
<value>Enabling Functions</value>
<value>Communications</value>
<value>Human Resources</value>
<value>Finance</value>
<value>Legal</value>
<value>Purchasing</value>
<value>Information Systems</value>
</values>
</field>
<field type="options">
<name label="Parent Domain Name">Parent Domain Name</name>
<values>
<value/>
<value>Research</value>
<value>Development</value>
<value>Medicine</value>
<value>Marketing and Sales</value>
<value>Operations</value>
<value>Enabling Functions</value>
<value>Communications</value>
<value>Human Resources</value>
<value>Finance</value>
<value>Legal</value>
<value>Purchasing</value>
<value>Information Systems</value>
</values>
</field>
</table>
</content>
</artifactType>
Also I want to know if there is a thorough document describing how to add artifact types and records. As an example I added a storage path called
/domains/#{overview_domain}/#{overview_parentname}/domain
but I do not know where this points to and if this is even valid or not. The documentation in the online help is not adequate enough to add new artifact structures and records.
Thanks
Under the <ui> tag you have listed two columns. The value attribute given to each column must be in the format {basetable}_{fieldname}
Therefor the names given under each <field> must match with the value <data attribute= of corresponding <column> under <ui>.
To get rid of the error, change the name of the first field to be "Domain" so that it matches with the name that you have given in the column(i.e. overview_domain). So that the tag of the first should look like
<name label="Domain Name">Domain</name>
You should do the same for the second field too, so that the of second field must look as follows
<name label="Parent Domain Name">ParentName</name>
Kindly find the corrected domain.rxt.
To create your own RXTs please find this article.
<?xml version="1.0"?>
<artifactType type="application/vnd.wso2-domain+xml" shortName="domain" singularLabel="Domain" pluralLabel="Domains" hasNamespace="false" iconSet="9">
<storagePath>/domains/#{overview_domain}/#{overview_parentname}/domain</storagePath>
<nameAttribute>overview_domain</nameAttribute>
<ui>
<list>
<column name="Domain">
<data type="text" value="overview_domain"/>
</column>
<column name="Parent Domain">
<data type="path" value="overview_parentname" href="#{storagePath}"/>
</column>
</list>
</ui>
<content>
<table name="Overview">
<field type="options" required="true">
<name label="Domain Name">domain</name>
<values>
<value>Research</value>
<value>Development</value>
<value>Medicine</value>
<value>Marketing and Sales</value>
<value>Operations</value>
<value>Enabling Functions</value>
<value>Communications</value>
<value>Human Resources</value>
<value>Finance</value>
<value>Legal</value>
<value>Purchasing</value>
<value>Information Systems</value>
</values>
</field>
<field type="options">
<name label="Parent Domain Name">parentname</name>
<values>
<value/>
<value>Research</value>
<value>Development</value>
<value>Medicine</value>
<value>Marketing and Sales</value>
<value>Operations</value>
<value>Enabling Functions</value>
<value>Communications</value>
<value>Human Resources</value>
<value>Finance</value>
<value>Legal</value>
<value>Purchasing</value>
<value>Information Systems</value>
</values>
</field>
</table>
</content>
</artifactType>