CMDBuild Forum

OSC Inventory import woes continue

In addition to the problems in the other thread I posted, I'm seeing some odd things with the basic connector. If I turn on SOAP debugging, I see the following going to the server, which to my eye looks correct:

<ExternalSync>
<cardList>
<PC identifiers="Code" key="Code">
<Code>RANCHERO-2013-07-03-08-50-49</Code>
<Description>RANCHERO</Description>
<Brand>Hewlett-Packard</Brand>
<Model>HP Z800 Workstation</Model>
<SerialNumber>2UA0120GZN</SerialNumber>
<IPAddress>10.67.5.215</IPAddress>
<RAM>0</RAM>
<CPUNumber>2</CPUNumber>
<CPUSpeed>2927</CPUSpeed>
</PC>
<Monitor identifiers="Code" domaindirection="directed" domain="PCMonitor">
<Code>71104</Code>
<Description>HWP.2954.00000000 (27/2012)</Description>
<SerialNumber>CN42270ZRV</SerialNumber>
<Brand>Hewlett Packard</Brand>
<Model>HP ZR2440w</Model>
</Monitor>
<Monitor identifiers="Code" domaindirection="directed" domain="PCMonitor">
<Code>71105</Code>
<Description>HWP.2955.01010101 (36/2012)</Description>
<SerialNumber>CN42360WS5</SerialNumber>
<Brand>Hewlett Packard</Brand>
<Model>HP ZR2440w</Model>
</Monitor>
</cardList>
<cardMaster>
<masterCardId>-1</masterCardId>
<masterClassName>PC</masterClassName>
</cardMaster>
<action>create</action>
</ExternalSync>
 
However when the import runs, it only creates the PC, not the Monitor entries, or the relations between them. If I re-run the basic-connector, it updates the PC and creates the Monitors, but with no relation between them.
<ExternalSync>
<cardList>
<PC identifiers="Code" key="Code" objid="4625">
<Code>RANCHERO-2013-07-03-08-50-49</Code>
<Description>RANCHERO</Description>
<Brand>Hewlett-Packard</Brand>
<Model>HP Z800 Workstation</Model>
<SerialNumber>2UA0120GZN</SerialNumber>
<IPAddress>10.67.5.215</IPAddress>
<RAM>0</RAM>
<CPUNumber>2</CPUNumber>
<CPUSpeed>2927</CPUSpeed>
</PC>
</cardList>
<cardMaster>
<masterCardId>4625</masterCardId>
<masterClassName>PC</masterClassName>
</cardMaster>
<action>update</action>
</ExternalSync>
 and
<ExternalSync>
<cardList>
<Monitor identifiers="Code" domaindirection="directed" domain="PCMonitor">
<Code>71104</Code>
<Description>HWP.2954.00000000 (27/2012)</Description>
<SerialNumber>CN42270ZRV</SerialNumber>
<Brand>Hewlett Packard</Brand>
<Model>HP ZR2440w</Model>
</Monitor>
</cardList>
<cardMaster>
<masterCardId>4625</masterCardId>
<masterClassName>PC</masterClassName>
</cardMaster>
<action>create</action>
</ExternalSync>
and
<ExternalSync>
<cardList>
<Monitor identifiers="Code" domaindirection="directed" domain="PCMonitor">
<Code>71105</Code>
<Description>HWP.2955.01010101 (36/2012)</Description>
<SerialNumber>CN42360WS5</SerialNumber>
<Brand>Hewlett Packard</Brand>
<Model>HP ZR2440w</Model>
</Monitor>
</cardList>
<cardMaster>
<masterCardId>4625</masterCardId>
<masterClassName>PC</masterClassName>
</cardMaster>
<action>create</action>
</ExternalSync>
 
If I run it a third time, it creates a duplicate of each monitor and will continue to do this every time I run the code. If I add a Key="Code" to the Monitor block in transforms.xsl, it will add the Monitors as PCs and delete all of the other PCs.
 
Any ideas?  I'm sure I could put a "unique" constraint on the Monitor Code to stop the duplicates, but that just hides the problem, not solves it.
 
Here is my transforms.xsl file:
<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform
version="1.0"> 
<xsl:output method="xml" version="1.0" encoding="UTF-8" 
indent="yes" /> 
<xsl:template match="/"> 
<CMDBUILD> 
<xsl:apply-templates /> 
</CMDBUILD> 
</xsl:template> 
<xsl:template match="*"> 
<xsl:apply-templates /> 
</xsl:template> 
<xsl:template match="text()"></xsl:template> 
<xsl:template match="/inventory/device"> 
<PC key="Code" identifiers="Code"> 
<Code> 
<xsl:value-of select="./DEVICEID" /> 
</Code> 
<Description> 
<xsl:value-of select="./NAME" /> 
</Description> 
<Brand> 
<xsl:value-of select="./SMANUFACTURER" /> 
</Brand> 
<Model> 
<xsl:value-of select="./SMODEL" /> 
</Model> 
<SerialNumber>
<xsl:value-of select="./SSN" /> 
</SerialNumber> 
<IPAddress> 
<xsl:value-of select="./IPADDR" /> 
</IPAddress> 
<RAM> 
<xsl:value-of select="sum(/inventory/memory/CAPACITY)" /> 
</RAM> 
<CPUNumber> 
<xsl:value-of select="./PROCESSORN" /> 
</CPUNumber> 
<CPUSpeed> 
<xsl:value-of select="./PROCESSORS" /> 
</CPUSpeed> 
</PC> 
</xsl:template> 
<xsl:template match="/inventory/monitor"> 
<Monitor domain="PCMonitor" domaindirection="directed" identifiers="Code">
<Code> 
<xsl:value-of select="./ID" /> 
</Code> 
<Description> 
<xsl:value-of select="./DESCRIPTION" /> 
</Description> 
<SerialNumber> 
<xsl:value-of select="./SERIAL" /> 
</SerialNumber> 
<Brand> 
<xsl:value-of select="./MANUFACTURER" /> 
</Brand> 
<Model> 
<xsl:value-of select="./CAPTION" /> 
</Model> 
</Monitor> 
</xsl:template> 
<xsl:template match="/CMDBUILD/PC"> 
<PC key="Code" identifiers="Code"> 
<xsl:attribute name="objid"> 
        <xsl:value-of select="./@objid" /> 
      </xsl:attribute> 
<Code> 
<xsl:value-of select="./Code" /> 
</Code> 
<Description> 
<xsl:value-of select="./Description" /> 
</Description> 
<Brand> 
<xsl:value-of select="./Brand" /> 
</Brand> 
<Model> 
<xsl:value-of select="./Model" /> 
</Model> 
<SerialNumber> 
<xsl:value-of select="./SerialNumber" /> 
</SerialNumber> 
<IPAddress> 
<xsl:value-of select="./IPAddress" /> 
</IPAddress> 
<RAM> 
<xsl:value-of select="./RAM" /> 
</RAM> 
<CPUNumber> 
<xsl:value-of select="./CPUNumber" /> 
</CPUNumber> 
<CPUSpeed> 
<xsl:value-of select="./CPUSpeed" /> 
</CPUSpeed> 
</PC> 
</xsl:template> 
<xsl:template match="/CMDBUILD/Monitor"> 
<Monitor domain="PCMonitor" domaindirection="directed" identifiers="Code">
<xsl:attribute name="objid">
<xsl:value-of select="./@objid" />
</xsl:attribute>
<Code>
<xsl:value-of select="./Code" />
</Code>
<Description>
<xsl:value-of select="./Description" />
</Description>
<SerialNumber>
<xsl:value-of select="./SerialNumber" />
</SerialNumber>
<Brand>
<xsl:value-of select="./Brand" />
</Brand>
<Model>
<xsl:value-of select="./Model" />
</Model>
</Monitor> 
</xsl:template> 
 
</xsl:stylesheet>