CMDBuild Forum

Re: OCS Basic Connector Related Classes / Domains

Dear Tecnoteca,

first I love CMDBuild it'a an amazing, powerful and mature tool! I will write a testimonial in the new year after successfully implementing CM in our environment.

After a few days of debugging the automatic assessment of master-class related cards (see OCS example in the Basic Connector Reference on page 9), I think that this feature is actually not implemented in the OCS connector version 1.5.0. Cause after reading some parts of the source I can't find anything regarding the relation management. (Even a simple grep for "directed" or "inverted" doesn't show any results.)

Maybe feature is commented in italian, it's contained in the additional libs or I'm to tired. :)

Could you please give me a hint?

 

Thanks!

Sebastian

Hi,
the feature is implemented, but you will not find anything searching for "directed" or "inverted" in the connector source because  it's handled directly server side, in CMDBuild.
 
Which is your problem? What are you trying to do?
Anyhow, this is a working example on how a relation between Assets and its NetworkDevice is handled
 
<xsl:template match="/inventory/network">
<NetworkDevice domain="AssetNetworkDevice" domaindirection="directed" identify="MACAddress">
<xsl:attribute name="objid">
<xsl:value-of select="./@objid"/>
</xsl:attribute>
<IpAddress>
<xsl:value-of select="./IpAddress"/>
</IpAddress>
     <MACAddress>
<xsl:value-of select="./MACAddress"/>
     </MACAddress>
     <Netmask>
<xsl:value-of select="./Netmask"/>
     </Netmask>
     <DefaultGateway>
<xsl:value-of select="./DefaultGateway"/>
     </DefaultGateway>
</NetworkDevice>
</xsl:template>
 <xsl:template match="/CMDBUILD/NetworkDevice">
<NetworkDevice domain="AssetNetworkDevice" domaindirection="directed" identify="MACAddress">
<xsl:attribute name="objid">
<xsl:value-of select="./@objid"/>
</xsl:attribute>
<IpAddress>
<xsl:value-of select="./IpAddress"/>
</IpAddress>
     <MACAddress>
<xsl:value-of select="./MACAddress"/>
     </MACAddress>
     <Netmask>
<xsl:value-of select="./Netmask"/>
     </Netmask>
     <DefaultGateway>
<xsl:value-of select="./DefaultGateway"/>
     </DefaultGateway>
</NetworkDevice>
</xsl:template>
 
Best regards,
CMDBuild Team
 

Hi,

 

thanks for your reply! :-) After studying and testing your suggestion I wasn't not able to automatically build some relationships. Maybe I didn't get the point in the right syntax. Now I'm starting with two new Classes, Views (based on OCS) and I hope you can show me the mistake. :)

 

Class 1: "MasterCard" only with Code and Description

Class 2: "SlaveCard" only with Code and Description

Domain: "MasterSlave" (1:N) from MasterCard to SlaveCard

 

View MasterCard:

 

 

CREATE OR REPLACE VIEW CMDBuild_mastercard (DEVICE, CMDBUILD, TAG) as select ID, CONCAT(hardware.ID, '#', accountinfo.TAG, '#ocs), TAG from hardware, accountinfo;

 

select * from CMDBuild_mastercard;

173 | 173#CUSTOMER#ocs | CUSTOMER

 

View SlaveCard:

 

 

CREATE OR REPLACE VIEW CMDBuild_slavecard as select hardware.ID, CONCAT(hardware.ID, '#', accountinfo.TAG, '#ocs) AS CMDBUILD, MANUFACTURER from monitors, hardware where hardware.id=monitors.hardware_id;

 

select * from CMDBuild_slavecard;

173 | 173#CUSTOMER#ocs.ica-net.de | Samtron

 

Connector for MasterCard

:

 

cat cmdbuild-schema.xml

<?xml version="1.0"?>

<CMDBUILD>

    <MasterCard>

        <Code />

        <Description />

    </MasterCard>

</CMDBUILD>

 

cat transform.xsl

[...]

    <xsl:template match="/inventory/mastercard">

        <MasterCard key="Code">

            <Code>

                <xsl:value-of select="./CMDBUILD" />

            </Code>

            <Description>

                <xsl:value-of select="./TAG" />

            </Description>

        </MasterCard>

    </xsl:template>

    <xsl:template match="/CMDBUILD/MasterCard">

        <MasterCard key="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>

        </MasterCard>

    </xsl:template>

</xsl:stylesheet>

 

Connector for SlaveCard

:

 

cat cmdbuild-schema.xml

<?xml version="1.0"?>

<CMDBUILD>

    <SlaveCard>

        <Code />

        <Description />

    </SlaveCard>

</CMDBUILD>

 

cat transform.xsl

[...]

    <xsl:template match="/inventory/slavecard">

        <SlaveCard key="Code" domain="MasterSlave" domaindirection="directed" identify="Code">

 

            <xsl:attribute name="objid">

                <xsl:value-of select="./@objid"/>

            </xsl:attribute>

            <Code>

                <xsl:value-of select="./CMDBUILD" />

            </Code>

            <Description>

                <xsl:value-of select="./MANUFACTURER" />

            </Description>

        </SlaveCard>

    </xsl:template>

    <xsl:template match="/CMDBUILD/SlaveCard">

        <SlaveCard key="Code" domain="MasterSlave" domaindirection="directed" identify="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>

        </SlaveCard>

    </xsl:template>

</xsl:stylesheet>

 

The import of SlaveCard's and MasterCard's works perfectly, but now relationsship between them is generated. What is wrong? ;)

 

Thanks!

 

Cheers

Sebastian