Again, i'm guessing that this is a creation ordering problem.  The Drug
(and the Concept referenced by the Drug) needs to be created before the
ConceptAnswer?

d

On Thu, Mar 1, 2012 at 12:33 PM, Dave Thomas <[email protected]> wrote:

> Hi.  No, I'm the one doing the export, and i'm trying to send the export
> to Rowan.  And all of my ConceptAnswer.answerDrug fields point to real
> Drugs in the export database.
>
> i.e.,
>
> select answer_drug from concept_answer where answer_drug is not null and
> answer_drug not in (select drug_id from drug);
> returns 0 rows.
>
> So there's no wrong data in the export DB.
>
> On the import database, the Drug should just be created.  And this is
> what's not working.
>
> d
>
> On Thu, Mar 1, 2012 at 11:50 AM, Rafal Korytkowski <[email protected]>wrote:
>
>> Dave, it's Hibernate that complains about the violated FK constraint
>> which throws an exception while initializing the object. It should be
>> possible to catch that runtime exception. We would have to watch out for
>> that as it may happen either while loading an object or calling one of its
>> getters (depending on the lazy-loading setting). The catch should be
>> somewhere in OpenmrsObjectVisitor where the exception is thrown (see
>> Rowan's stacktrace).
>>
>> The question is if MDS should be handling wrong data in your db :-)
>>
>> -Rafal
>>
>>
>>
>> On 1 March 2012 20:10, Rowan Seymour <[email protected]> wrote:
>>
>>> Rafal was right - we were missing the drug in the database after a
>>> previous SQL import of concepts... which is why SQL dumps are not a great
>>> way to move concepts around and why we really appreciate the work you guys
>>> are doing on MDS
>>>
>>>
>>> On 1 March 2012 20:48, Dave Thomas <[email protected]> wrote:
>>>
>>>> Why wouldn't the drug just be added to the metadata sharing package
>>>> when referenced by answer_drug?
>>>>
>>>> I don't see why you'd ever want to import/export a concept with an
>>>> answer_drug where you wouldn't want the package to include the drug.
>>>>
>>>> (rolling up sleeves to look at metadatasharing code)
>>>>
>>>> d
>>>>
>>>>
>>>> On Thu, Mar 1, 2012 at 4:35 AM, Rafal Korytkowski <[email protected]>wrote:
>>>>
>>>>> It's possible that you may have imported it. Normally MySQL dumps are
>>>>> imported with foreign_key_checks=OFF.
>>>>>
>>>>> I'd assume this drug is in the concept_answer table so execute this
>>>>> query:
>>>>>
>>>>> select * from concept_answer where answer_drug = 142;
>>>>>
>>>>> -Rafal
>>>>>
>>>>>
>>>>> On 1 March 2012 13:10, Rowan Seymour <[email protected]> wrote:
>>>>>
>>>>>> There is no drug 142. Am looking in the database to see where we
>>>>>> could have a FK constraint violation. It's InnoDB tables
>>>>>> with foreign_key_checks=ON so I don't see how it's possible. What do you
>>>>>> think is referencing that drug?
>>>>>>
>>>>>> I'll create a ticket for the other exception.
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>>
>>>>>> On 1 March 2012 13:15, Rafal Korytkowski <[email protected]> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> The export fails since you've got a FK constraint violation in your
>>>>>>> db: *No row with the given identifier exists:
>>>>>>> [org.openmrs.Drug#142]. *Make sure that a drug with id 142 exists
>>>>>>> or don't reference it in your concepts.
>>>>>>>
>>>>>>> Regarding the import it's trying to save concepts in the wrong
>>>>>>> order. Can you please create a ticket and attach your package if it's
>>>>>>> possible or else I'll ask you to help me inspect the xml further.
>>>>>>>
>>>>>>> -Rafal
>>>>>>>
>>>>>>> On 1 March 2012 11:29, Rowan Seymour <[email protected]> wrote:
>>>>>>>
>>>>>>>> Another exception - this time trying to export all concepts from
>>>>>>>> the same server:
>>>>>>>>
>>>>>>>> *Caused by: org.openmrs.module.metadatasharing.task.TaskException:
>>>>>>>> Export failed*
>>>>>>>> * at
>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ExportPackageTask.execute(ExportPackageTask.java:125)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.openmrs.module.metadatasharing.api.impl.MetadataSharingServiceImpl.executeTask(MetadataSharingServiceImpl.java:198)
>>>>>>>> *
>>>>>>>> * ...*
>>>>>>>> *Caused by: org.hibernate.ObjectNotFoundException: No row with the
>>>>>>>> given identifier exists: [org.openmrs.Drug#142]*
>>>>>>>> * at
>>>>>>>> org.hibernate.impl.SessionFactoryImpl$1.handleEntityNotFound(SessionFactoryImpl.java:377)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:79)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:68)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.openmrs.module.metadatasharing.visitor.impl.OpenmrsObjectVisitor$1.visit(OpenmrsObjectVisitor.java:89)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:129)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.openmrs.module.metadatasharing.visitor.impl.OpenmrsObjectVisitor.visitFields(OpenmrsObjectVisitor.java:83)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ExportPackageTask.resolveRelatedItems(ExportPackageTask.java:176)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ExportPackageTask.access$2(ExportPackageTask.java:175)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ExportPackageTask$1.visitMetadata(ExportPackageTask.java:202)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ExportPackageTask$1.visit(ExportPackageTask.java:184)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.openmrs.module.metadatasharing.visitor.impl.OpenmrsObjectVisitor$1.visit(OpenmrsObjectVisitor.java:96)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:129)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.openmrs.module.metadatasharing.visitor.impl.OpenmrsObjectVisitor.visitFields(OpenmrsObjectVisitor.java:83)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ExportPackageTask.resolveRelatedItems(ExportPackageTask.java:176)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ExportPackageTask.exportSubpackage(ExportPackageTask.java:148)
>>>>>>>> *
>>>>>>>> * at
>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ExportPackageTask.execute(ExportPackageTask.java:98)
>>>>>>>> *
>>>>>>>> * ... 44 more*
>>>>>>>>
>>>>>>>>
>>>>>>>> It also outputted about 15MB to my catalina.out log, most of which
>>>>>>>> appears to be repetition of this warning:
>>>>>>>>
>>>>>>>> *WARN - StringLocaleConverter.getDecimalFormat(281) |2012-03-01
>>>>>>>> 11:54:50,961| No pattern provided, using default.*
>>>>>>>>
>>>>>>>>
>>>>>>>> On 1 March 2012 12:13, Rowan Seymour <[email protected]>wrote:
>>>>>>>>
>>>>>>>>> Am trying to import a package with MDS 1.0.2 and getting the
>>>>>>>>> exception below. The package was also made with 1.0.2
>>>>>>>>> *
>>>>>>>>> *
>>>>>>>>> *Caused by:
>>>>>>>>> org.openmrs.module.metadatasharing.task.TaskException: Import failed
>>>>>>>>> *
>>>>>>>>> *...*
>>>>>>>>> *Caused by: org.openmrs.api.db.DAOException: Error saving
>>>>>>>>> org.openmrs.Concept [e44dae58-fec8-4567-bd44-e989232af0e7]*
>>>>>>>>> *...*
>>>>>>>>> *Caused by: org.openmrs.api.APIException: Cannot save 7073.
>>>>>>>>> Failed with the following exception:*
>>>>>>>>> *java.lang.reflect.InvocationTargetException*
>>>>>>>>> *
>>>>>>>>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>>>>>>>>> Method)
>>>>>>>>> at
>>>>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>>>>>>  at
>>>>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>>>>>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>>>>>>>>  at
>>>>>>>>> org.openmrs.module.metadatasharing.reflection.OpenmrsClassScanner.invokeServiceSaveItem(OpenmrsClassScanner.java:254)
>>>>>>>>> at
>>>>>>>>> org.openmrs.module.metadatasharing.reflection.OpenmrsClassScanner.serviceSaveItem(OpenmrsClassScanner.java:174)
>>>>>>>>>  at
>>>>>>>>> org.openmrs.module.metadatasharing.handler.impl.OpenmrsObjectHandler.saveItem(OpenmrsObjectHandler.java:107)
>>>>>>>>> at
>>>>>>>>> org.openmrs.module.metadatasharing.handler.impl.OpenmrsObjectHandler.saveItem(OpenmrsObjectHandler.java:1)
>>>>>>>>>  at
>>>>>>>>> org.openmrs.module.metadatasharing.handler.Handler.saveItem(Handler.java:38)
>>>>>>>>> at
>>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ImportPackageTask.saveItem(ImportPackageTask.java:284)
>>>>>>>>>  at
>>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ImportPackageTask.saveItem(ImportPackageTask.java:278)
>>>>>>>>> at
>>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ImportPackageTask.saveItem(ImportPackageTask.java:278)
>>>>>>>>>  at
>>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ImportPackageTask.saveItem(ImportPackageTask.java:278)
>>>>>>>>> at
>>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ImportPackageTask.saveItem(ImportPackageTask.java:278)
>>>>>>>>>  at
>>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ImportPackageTask.importItems(ImportPackageTask.java:199)
>>>>>>>>> at
>>>>>>>>> org.openmrs.module.metadatasharing.task.impl.ImportPackageTask.execute(ImportPackageTask.java:85)
>>>>>>>>>  at
>>>>>>>>> org.openmrs.module.metadatasharing.api.impl.MetadataSharingServiceImpl.executeTask(MetadataSharingServiceImpl.java:198)
>>>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>>>> *
>>>>>>>>> *...*
>>>>>>>>> *Caused by: org.hibernate.PropertyValueException: not-null
>>>>>>>>> property references a null or transient value:
>>>>>>>>> org.openmrs.ConceptAnswer.answerConcept*
>>>>>>>>> *
>>>>>>>>>         at
>>>>>>>>> org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)
>>>>>>>>>         at
>>>>>>>>> org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:290)
>>>>>>>>> *
>>>>>>>>>
>>>>>>>>> I assume "*Cannot save 7073*" refers to the item with id=7073
>>>>>>>>> which would be this ConceptMap in the metadata.xml:
>>>>>>>>>
>>>>>>>>>                       <org.openmrs.ConceptMap id="*7073*"
>>>>>>>>> uuid="75591ABBBBBBBBBBBBBBBBBBBBBBBBBBBBBB">
>>>>>>>>>                         <conceptMapId>13,329</conceptMapId>
>>>>>>>>>                         <concept reference="7046"/>
>>>>>>>>>                         <source reference="671"/>
>>>>>>>>>                         <sourceCode>283025007</sourceCode>
>>>>>>>>>                         <comment>Map Type: 1</comment>
>>>>>>>>>                         <creator/>
>>>>>>>>>                         <dateCreated id="7074">2010-04-25
>>>>>>>>> 11:29:41</dateCreated>
>>>>>>>>>                       </org.openmrs.ConceptMap>
>>>>>>>>>
>>>>>>>>> And the concept with that UUID is:
>>>>>>>>>
>>>>>>>>>                 <org.openmrs.ConceptAnswer id="10576"
>>>>>>>>> uuid="575e736e-347a-4487-aced-10c7cdd9ec5f">
>>>>>>>>>                   <conceptAnswerId>6,850</conceptAnswerId>
>>>>>>>>>                   <concept reference="5900"/>
>>>>>>>>>                   <answerConcept id="10577"
>>>>>>>>> resolves-to="org.openmrs.Concept" uuid="*
>>>>>>>>> e44dae58-fec8-4567-bd44-e989232af0e7*">
>>>>>>>>>                     <conceptId>7,181</conceptId>
>>>>>>>>>                     <retired>false</retired>
>>>>>>>>>                     <datatype reference="37"/>
>>>>>>>>>                     <conceptClass reference="897"/>
>>>>>>>>>                     <set>false</set>
>>>>>>>>>                     <version>1</version>
>>>>>>>>>                     <creator/>
>>>>>>>>>                     <dateCreated id="10579">2011-12-15
>>>>>>>>> 04:22:46</dateCreated>
>>>>>>>>>                     <changedBy/>
>>>>>>>>>                     <dateChanged id="10580">2012-01-16
>>>>>>>>> 20:03:00</dateChanged>
>>>>>>>>>                     <names class="set" id="10581">
>>>>>>>>>                       <org.openmrs.ConceptName id="10582"
>>>>>>>>> uuid="435c4cb9-5527-491c-87c6-43c3bd64c2e5">
>>>>>>>>>                         <conceptNameId>14,688</conceptNameId>
>>>>>>>>>                         <concept reference="10577"/>
>>>>>>>>>                         <name>Obstructed Labor, Antepartum</name>
>>>>>>>>>                         <locale id="10583">en</locale>
>>>>>>>>>                         <creator/>
>>>>>>>>>                         <dateCreated id="10584">2011-12-15
>>>>>>>>> 04:22:46</dateCreated>
>>>>>>>>>                         <voided>false</voided>
>>>>>>>>>                         <tags class="set" id="10585">
>>>>>>>>>                           <org.openmrs.ConceptNameTag
>>>>>>>>> reference="28"/>
>>>>>>>>>                         </tags>
>>>>>>>>>                       </org.openmrs.ConceptName>
>>>>>>>>>                     </names>
>>>>>>>>>                     <answers class="set" id="10586"/>
>>>>>>>>>                     <conceptSets class="set" id="10587"/>
>>>>>>>>>                     <descriptions class="set" id="10588"/>
>>>>>>>>>                     <conceptMappings class="set" id="10589">
>>>>>>>>>                       <org.openmrs.ConceptMap id="10590"
>>>>>>>>> uuid="12e8f7ab-c801-4c4e-9ba0-d5a516a8ac81">
>>>>>>>>>                         <conceptMapId>13,442</conceptMapId>
>>>>>>>>>                         <concept reference="10577"/>
>>>>>>>>>                         <source reference="1428"/>
>>>>>>>>>                         <sourceCode>O66.9</sourceCode>
>>>>>>>>>                         <creator/>
>>>>>>>>>                         <dateCreated id="10591">2011-12-15
>>>>>>>>> 04:22:46</dateCreated>
>>>>>>>>>                       </org.openmrs.ConceptMap>
>>>>>>>>>                       <org.openmrs.ConceptMap id="10592"
>>>>>>>>> uuid="06e77deb-29b4-423b-bfb3-51f7670dae71">
>>>>>>>>>                         <conceptMapId>14,034</conceptMapId>
>>>>>>>>>                         <concept reference="10577"/>
>>>>>>>>>                         <source reference="76"/>
>>>>>>>>>                         <sourceCode>7181</sourceCode>
>>>>>>>>>                         <creator/>
>>>>>>>>>                         <dateCreated id="10593">2012-01-16
>>>>>>>>> 20:03:00</dateCreated>
>>>>>>>>>                       </org.openmrs.ConceptMap>
>>>>>>>>>                       <org.openmrs.ConceptMap id="10594"
>>>>>>>>> uuid="0332cfca-4aa4-46a9-9b76-6fa45c9ba336">
>>>>>>>>>                         <conceptMapId>13,441</conceptMapId>
>>>>>>>>>                          <concept reference="10577"/>
>>>>>>>>>                         <source reference="71"/>
>>>>>>>>>                         <sourceCode>7558</sourceCode>
>>>>>>>>>                         <creator/>
>>>>>>>>>                         <dateCreated id="10595">2011-12-15
>>>>>>>>> 09:20:01</dateCreated>
>>>>>>>>>                       </org.openmrs.ConceptMap>
>>>>>>>>>                     </conceptMappings>
>>>>>>>>>                     <compatibleCache id="10596">
>>>>>>>>>                       <entry>
>>>>>>>>>                         <locale reference="92"/>
>>>>>>>>>                         <vector id="10597">
>>>>>>>>>                           <org.openmrs.ConceptName
>>>>>>>>> reference="10582"/>
>>>>>>>>>                         </vector>
>>>>>>>>>                       </entry>
>>>>>>>>>                     </compatibleCache>
>>>>>>>>>                   </answerConcept>
>>>>>>>>>                   <creator/>
>>>>>>>>>                   <dateCreated id="10598">2011-12-15
>>>>>>>>> 04:23:05</dateCreated>
>>>>>>>>>                 </org.openmrs.ConceptAnswer>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> *Rowan Seymour*
>>>>>>>> tel: +250 783835665
>>>>>>>> http://twitter.com/rowanseymour
>>>>>>>>
>>>>>>>>  ------------------------------
>>>>>>>> Click here to 
>>>>>>>> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-devel-l>from
>>>>>>>>  OpenMRS Developers' mailing list
>>>>>>>>
>>>>>>>
>>>>>>> ------------------------------
>>>>>>> Click here to 
>>>>>>> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-devel-l>from
>>>>>>>  OpenMRS Developers' mailing list
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> *Rowan Seymour*
>>>>>> tel: +250 783835665
>>>>>> http://twitter.com/rowanseymour
>>>>>>
>>>>>>  ------------------------------
>>>>>> Click here to 
>>>>>> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-devel-l>from
>>>>>>  OpenMRS Developers' mailing list
>>>>>>
>>>>>
>>>>> ------------------------------
>>>>> Click here to 
>>>>> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-devel-l>from
>>>>>  OpenMRS Developers' mailing list
>>>>>
>>>>
>>>> ------------------------------
>>>> Click here to 
>>>> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-devel-l>from
>>>>  OpenMRS Developers' mailing list
>>>>
>>>
>>>
>>>
>>> --
>>> *Rowan Seymour*
>>> tel: +250 783835665
>>> http://twitter.com/rowanseymour
>>>
>>> ------------------------------
>>> Click here to 
>>> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-devel-l>from 
>>> OpenMRS Developers' mailing list
>>>
>>
>> ------------------------------
>> Click here to 
>> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-devel-l>from 
>> OpenMRS Developers' mailing list
>>
>
>

_________________________________________

To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to 
[email protected] with "SIGNOFF openmrs-devel-l" in the  body (not 
the subject) of your e-mail.

[mailto:[email protected]?body=SIGNOFF%20openmrs-devel-l]

Reply via email to