Exchange file format won't import because of <views>

Started by niek T, October 19, 2017, 15:35:29 PM

Previous topic - Next topic

niek T

I've been strugling with this issue for a few hours now.

I needed to make an export to "OpenGroup Archimate Model Exchange File Format" of a query done on a model and only include the query result in the exported model. I decided to reuse the export method in the archimate tool. I get the models (IArchimateModel) for the query result, exported them to a temp folder. I used the OpenGroup Archimate3_Model.xsd to generate Java classes. Then I unmarshalled the models from the temp folder to java objects, filtered what I don't need from them and marshalled them back to XML to a folder of the users liking (not the cleanest way of doing it but ok).

Now when I try to Import these models into the archimate tool it starts to complain about the fact that my views tag is not on the correct location in the file. The issue lies in the XML propOrder of my java object properties. Whenever I marshal my object it first marshalls the parentclasses (again these are generated from the XSD)

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ReferenceableType", propOrder = {
    "nameGroup",
    "documentation",
    "any"
})
@XmlSeeAlso({
    NamedReferenceableType.class,
    ConceptType.class
})
//@XmlTransient
public abstract class ReferenceableType {

    @XmlElement(name = "name")
    protected List<LangStringType> nameGroup;
    protected List<PreservedLangStringType> documentation;
    @XmlAnyElement(lax = true)
    protected List<Object> any;
    @XmlAttribute(name = "identifier", required = true)
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlID
    @XmlSchemaType(name = "ID")
    protected String identifier;
    @XmlAnyAttribute
    private Map<QName, String> otherAttributes = new HashMap<QName, String>();
    ...
}


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "NamedReferenceableType")
@XmlSeeAlso({
    ModelType.class,
    PropertyDefinitionType.class
})
//@XmlTransient
public abstract class NamedReferenceableType
    extends ReferenceableType
{


}


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ModelType", propOrder = {
    "properties",
    "metadata",
    "elements",
    "relationships",
    "organizations",
    "propertyDefinitions"
})
public class ModelType
    extends NamedReferenceableType
{

    protected PropertiesType properties;
    protected MetadataType metadata;
    protected ElementsType elements;
    protected RelationshipsType relationships;
    protected List<OrganizationsType> organizations;
    protected PropertyDefinitionsType propertyDefinitions;
    @XmlAttribute(name = "version")
    protected String version;
    ...
}


I searched if I could alter the propOrder in the Child class (ModelType) which should be possible by placing @XmlTransient on the parent class and than including the parent properties in the propOrder of the Child class. Whenever I do this I get a stackOverflowError the moment I create the JaxbContext to marshal my java object to xml.

I was wondering if anyone ever had this issue before and if so how did you fix it since I'm not finding a solution atm.

Thanks in advance,
Kind regards,

Niek

Phil Beauvoir

Hi Niek, so this is a JAXB issue? Certainly, when importing XML in the Open Exchange format all the xml elements have to be present and in the correct order according to the XSD. Are you saying that you are exporting the views but they are in the wrong place?
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

niek T

Quote from: Phil Beauvoir on October 19, 2017, 16:15:58 PM
Hi Niek, so this is a JAXB issue? Certainly, when importing XML in the Open Exchange format all the xml elements have to be present and in the correct order according to the XSD. Are you saying that you are exporting the views but they are in the wrong place?

I was using archimate3_Model.xsd, needed to use archimate3_Diagram.xsd, stupid mistake. Same topic, other question though:
I noticed that when exporting a model that has viewpoints in archi3 all of the viewpoints just get listed under views. (is this a feature not yet implemented or is there a bug happening?)  I took the libarty of having a look in the XMLModelExporter and I see there is a few lines of code tackling viewpoints but just looks like an attribute gets set (don't have much time to look deeper but might be a bug somewhere).

Kind regards,
Niek

Phil Beauvoir

Archi imports and exports the standard viewpoint names that are documented in the ArchiMate 3 specification. These are declared as attributes. The exchange format supports the declaration of custom viewpoints, but as Archi does not implement these, they are not exported or imported.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.