Package gov.nasa.arc.mct.components

Examples of gov.nasa.arc.mct.components.ModelStatePersistence


   
    if (!fullSave) {
      return;
    }
    cs.setObjVersion(ac.getVersion());
    ModelStatePersistence persistence = ac.getCapability(ModelStatePersistence.class);
    if (persistence != null) {
      cs.setModelInfo(persistence.getModelState());
    }
   
    // save relationships
    // non optimal implementation as this will require a query to get the relationships
    cs.setReferencedComponents(new ArrayList<ComponentSpec>(ac.getComponents().size()));
View Full Code Here


    initializer.setOwner(cs.getOwner());
    initializer.setId(cs.getComponentId());
    ac.setExternalKey(cs.getExternalKey());
    ac.setDisplayName(cs.getComponentName());
    ac.getCapability(Updatable.class).setVersion(cs.getObjVersion());
        ModelStatePersistence persister = ac.getCapability(ModelStatePersistence.class);
        if ((persister != null) && (cs.getModelInfo() != null)) {
            persister.setModelState(cs.getModelInfo());
        }
   
    // Add ac to cache
    List<WeakReference<AbstractComponent>> list = cache.get(cs.getComponentId());
    if (list == null) {
View Full Code Here

     * If the component's ModelStatePersistence falls out of sync with
     * the component itself, then this should break.
     */
    @Test
    public void testPersistence() {
        ModelStatePersistence persistence = testComponent.getCapability(ModelStatePersistence.class);
        Assert.assertNotNull(persistence);
       
        persistence.setModelState("test");
        Assert.assertEquals(persistence.getModelState(), "test");
        Assert.assertEquals(testComponent.getCapability(ModelStatePersistence.class).getModelState(), "test");

        persistence.setModelState("retest");
        Assert.assertEquals(persistence.getModelState(), "retest");
        Assert.assertEquals(testComponent.getCapability(ModelStatePersistence.class).getModelState(), "retest");       
    }
View Full Code Here

    GraphicalComponent a = new GraphicalComponent();
    GraphicalComponent b = new GraphicalComponent();
    a.getModelRole().setGraphicURI(uriOne);
    b.getModelRole().setGraphicURI(uriTwo);
   
    ModelStatePersistence persisterA = a.getCapability(ModelStatePersistence.class);
    ModelStatePersistence persisterB = b.getCapability(ModelStatePersistence.class);
    Assert.assertNotNull(persisterA);
    Assert.assertNotNull(persisterB);
   
    // Swap models
    String stateA = persisterA.getModelState();
    String stateB = persisterB.getModelState();
    persisterA.setModelState(stateB);
    persisterB.setModelState(stateA);

    // Ensure they have switched
    Assert.assertEquals(b.getModelRole().getGraphicURI(), uriOne);
    Assert.assertEquals(a.getModelRole().getGraphicURI(), uriTwo);
  }
View Full Code Here

   * Unmarshal the model state
   * @param comp
   * @param xmlComp
   */
  private void unmarshalModelState(AbstractComponent comp, ComponentType xmlComp) {
    ModelStatePersistence persister = comp.getCapability(ModelStatePersistence.class);
    if (persister != null && xmlComp.getModelState() != null) {
            persister.setModelState(xmlComp.getModelState());
    }
  }
View Full Code Here

   *
   * @param comp component whose state is to be saved
   * @param xmlComp XML component to save the data to
   */
  private void marshalModelState(AbstractComponent comp, ComponentType xmlComp) {
    ModelStatePersistence persister = comp
        .getCapability(ModelStatePersistence.class);
    if (persister != null) {
      xmlComp.setModelState(persister.getModelState());
    }
  }
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.components.ModelStatePersistence

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.