Package gov.nasa.arc.mct.importExport.provider.generated

Examples of gov.nasa.arc.mct.importExport.provider.generated.ComponentType


        throws Exception {
   
      File file = new File(inputFilename);
     
      ComponentListType components = XMLPersistence.unmarshal(file);
      ComponentType component = components.getComponent().get(0);
     
      Assert.assertNotNull(component);
      Assert.assertEquals(component.getComponentId(), expectedRootID);
     
    }
View Full Code Here


      if (!file.exists()) {
        Assert.fail("XML file was not generated.");
      }
     
      ComponentListType components = XMLPersistence.unmarshal(file);
      ComponentType component = components.getComponent().get(0);
      Assert.assertNotNull(component);
      Assert.assertEquals(component.getExternalKey(), "TheExternalKey");
       
      file.delete();
    }
View Full Code Here

   
    private ComponentListType illegalComp() {
      ObjectFactory objFactory = new ObjectFactory();
      ComponentListType compList = objFactory.createComponentListType();
      compList.setSchemaVersion(new BigDecimal(1.0));
      ComponentType comp = objFactory.createComponentType();
      comp.setComponentId("askjdfskdjfk");
      compList.getComponent().add(comp);
      return compList;
    }
View Full Code Here

     
      ObjectFactory objFactory = new ObjectFactory();
      ComponentListType compList = objFactory.createComponentListType();
     
      compList.setSchemaVersion(new BigDecimal(1.0));
      ComponentType comp = objFactory.createComponentType();
      comp.setComponentId("askjdfskdjfk");
      comp.setComponentType("TheCompType");
      comp.setCreationDate(Utilities.convertToXMLGregorianCalendar(null));
      comp.setCreator("TheCreator");
      comp.setExternalKey("TheExternalKey");
      comp.setName("TheName");
      comp.setOwner("TheOwner");
      comp.setToplevel(true);
     
      compList.getComponent().add(comp);
     
      return compList;
    }
View Full Code Here

   * @param topLevelComp
   */
  private void createXmlComponent(AbstractComponent mctComp,
      ComponentListType xmlComponentList, boolean topLevelComp) {

    ComponentType xmlComp = objFactory.createComponentType();

    // Set flag to show which component(s) are at the top level in the
    // structure tree of the MCT component(s) which were chosen for export.
    // Needed for import.
    if (topLevelComp) {
      xmlComp.setToplevel(true);
    } else {
      xmlComp.setToplevel(false);
    }

    xmlComp.setComponentId(mctComp.getId());
    xmlComp.setComponentType(mctComp.getClass().getName());
    xmlComp.setCreator(mctComp.getCreator());
    xmlComp.setName(mctComp.getDisplayName());
    xmlComp.setExternalKey(mctComp.getExternalKey());
    xmlComp.setOwner(mctComp.getOwner());

    // Convert from Date to XMLGregorianCalendar
    XMLGregorianCalendar xmlGCDate = Utilities
        .convertToXMLGregorianCalendar(mctComp.getCreationDate());
    xmlComp.setCreationDate(xmlGCDate);

    marshalModelState(mctComp, xmlComp);
    marshalViewState(mctComp, xmlComp);

    // xmlComp must be added to the list before the children are processed,
    // in case there is a case of A being the parent of B being the parent of A.
    xmlComponentList.getComponent().add(xmlComp);

    // Recursively get children
    if (mctComp.getComponents() != null) {
      for (AbstractComponent child : mctComp.getComponents()) {
        updateProgressBar();

        if (isExportable(child)) {
          if (exportAsReference(child)) {
            // Add child to XML file as a reference
            // (ComponentRefType)
            ComponentRefType compReference = objFactory
                .createComponentRefType();
            compReference.setComponentId(child.getId());
            compReference.setExternalKey(child.getExternalKey());
            compReference.setClassType(child.getClass().getName());
            xmlComp.getComponentRefs().add(compReference);

          } else {
            // Add child to XML file as a component (write all of
            // its data)
            if (isNewComponent(child, xmlComponentList)) {
              // Recursive call to add child component as a
              // top-level component in the XML file
              createXmlComponent(child, xmlComponentList, false);
            }

            // Add child's component ID to associatedComponents
            AssociatedComponentType assocComp = objFactory
                .createAssociatedComponentType();
            assocComp.setId(child.getId());
            xmlComp.getAssociatedComponents().add(assocComp);
          }

        } else {
          // Child is not exportable
          unexportableComps.add(child);
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.importExport.provider.generated.ComponentType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.