org.apache.isis.core.metamodel.adapter.oid.Oid.isTransient()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.apache.isis.core.metamodel.adapter.oid.Oid.isTransient()方法的一些代码示例,展示了Oid.isTransient()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Oid.isTransient()方法的具体详情如下:
包路径:org.apache.isis.core.metamodel.adapter.oid.Oid
类名称:Oid
方法名:isTransient

Oid.isTransient介绍

[英]Flags whether this OID is temporary, and is for a transient object..
[中]标记此OID是否为临时对象,以及是否为临时对象。。

代码示例

代码示例来源:origin: org.apache.isis.viewer/wicket-model

@Override
public boolean matchesSafely(final Oid item) {
  return item.isTransient();
}

代码示例来源:origin: org.apache.isis.viewer/wicket-model

@Override
public boolean matchesSafely(final Oid item) {
  return !item.isTransient();
}

代码示例来源:origin: org.apache.isis.core/metamodel

@Override
public boolean isTransient() {
  return parentOid.isTransient();
}

代码示例来源:origin: org.apache.isis.viewer/scimpi-dispatcher

@Override
public void clear() {
  requestTransients.clear();
  final List<String> remove = new ArrayList<String>();
  for (final String id : sessionTransients.keySet()) {
    if (!sessionTransients.get(id).getOid().isTransient()) {
      remove.add(id);
      sessionTransients.put(id, null);
    }
  }
  for (final String id : remove) {
    sessionTransients.remove(id);
  }
}

代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime

/**
 * For testing purposes only.
 */
@Override
public ObjectAdapter testCreateTransient(final Object pojo, final Oid oid) {
  if (!oid.isTransient()) {
    throw new IllegalArgumentException("Oid should be transient; use standard API to recreate adapters for persistent Oids");
  }
  return map(createOrRecreateRootAdapter(pojo, oid));
}

代码示例来源:origin: org.apache.isis.core/isis-core-runtime

private void remapAsPersistentIfRequired(final ObjectAdapter serviceAdapter) {
  if (serviceAdapter.getOid().isTransient()) {
    remapAsPersistent(serviceAdapter, null);
  }
}

代码示例来源:origin: org.apache.isis.core/isis-core-runtime

private String aggregateResolveStateCode() {
  // this is an approximate re-implementation...
  final Oid oid = getOid();
  if(oid != null) {
    if(oid.isPersistent()) return "P";
    if(oid.isTransient()) return "T";
    if(oid.isViewModel()) return "V";
  }
  return "S"; // standalone adapter (value)
}
//endregion

代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime

private ObjectAdapter createOrRecreateAdapter(final Object pojo, final Oid oid) {
  final ObjectAdapter adapter = getAdapterFactory().createAdapter(pojo, oid);
  if (oid == null) {
    adapter.changeState(ResolveState.VALUE);
  } else {
    adapter.changeState(oid.isTransient() ? ResolveState.TRANSIENT : ResolveState.GHOST);
  }
  return adapter;
}

代码示例来源:origin: org.apache.isis.viewer/scimpi-dispatcher

public TransientObjectMapping(final ObjectAdapter adapter) {
  oid = adapter.getOid();
  Assert.assertTrue("OID is for persistent", oid.isTransient());
  Assert.assertTrue("adapter is for persistent", adapter.isTransient());
  memento = new Memento(adapter);
}

代码示例来源:origin: org.apache.isis.core/isis-core-runtime

private Data createReferenceData(final ObjectAdapter referencedAdapter) {
  if (referencedAdapter == null) {
    return null;
  }
  Oid refOid = clone(referencedAdapter.getOid());
  if (refOid == null) {
    return createStandaloneData(referencedAdapter);
  }
  if (    (referencedAdapter.getSpecification().isParented() || refOid.isTransient()) &&
      !transientObjects.contains(refOid)) {
    transientObjects.add(refOid);
    return createObjectData(referencedAdapter);
  }
  final String specification = referencedAdapter.getSpecification().getFullIdentifier();
  return new Data(refOid, specification);
}

代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime

private Data createReferenceData(final ObjectAdapter ref) {
  if (ref == null) {
    return null;
  }
  final Oid refOid = ref.getOid();
  if (refOid == null) {
    return createStandaloneData(ref);
  }
  if ((ref.getSpecification().isAggregated() || refOid.isTransient()) && !transientObjects.contains(refOid)) {
    transientObjects.add(refOid);
    return createObjectData(ref);
  }
  final String resolvedState = ref.getResolveState().name();
  final String specification = ref.getSpecification().getFullIdentifier();
  return new Data(refOid, resolvedState, specification);
}

代码示例来源:origin: org.apache.isis.viewer/wicket-model

private void init(final ObjectAdapter adapter) {
  final ObjectSpecification specification = specMemento.getSpecification();
  final EncodableFacet encodableFacet = specification.getFacet(EncodableFacet.class);
  final boolean isEncodable = encodableFacet != null;
  if (isEncodable) {
    encodableValue = encodableFacet.toEncodedString(adapter);
    type = Type.ENCODEABLE;
  } else {
    final Oid oid = adapter.getOid();
    if (oid.isTransient()) {
      transientMemento = new Memento(adapter);
      type = Type.TRANSIENT;
    } else {
      persistentOid = oid;
      type = Type.PERSISTENT;
    }
  }
}

代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime

@Test
public void whenValidPersistentWithPersistentPreviousThenPreviousIsPersistent() {
  final SerialOid oid = SerialOid.deString("TOID:12ABF3~OID:12");
  final Oid previousOid = oid.getPrevious();
  assertThat(previousOid.isTransient(), is(false));
}

代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime

@Test
public void whenValidPersistentWithTransientPreviousThenPreviousIsTransient() {
  final SerialOid oid = SerialOid.deString("OID:12ABF3~TOID:12");
  final Oid previousOid = oid.getPrevious();
  assertThat(previousOid.isTransient(), is(true));
}

代码示例来源:origin: org.apache.isis.runtimes.dflt.remoting/common

private ObjectAdapter deserializeObjectFromObjectData(final ObjectData data, final KnownObjectsRequest knownObjects) {
  if (knownObjects.containsKey(data)) {
    return knownObjects.get(data);
  }
  final Oid oid = data.getOid();
  /*
   * either create a new transient object, get an existing object and
   * update it if data is for resolved object, or create new object and
   * set it
   */
  ObjectAdapter adapter = getAdapterManager().getAdapterFor(oid);
  if (adapter != null) {
    updateLoadedObject(adapter, data, knownObjects);
  } else if (oid.isTransient()) {
    adapter = deserializeTransient(data, knownObjects);
  } else {
    adapter = deserializePersistentObject(data, oid, knownObjects);
  }
  return adapter;
}

代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime

public ObjectAdapter recreateObject() {
  if (state == null) {
    return null;
  }
  final ObjectSpecification spec = getSpecificationLoader().loadSpecification(state.getClassName());
  ObjectAdapter object;
  ResolveState targetState;
  if (getOid().isTransient()) {
    object = getHydrator().recreateAdapter(getOid(), spec);
    targetState = ResolveState.SERIALIZING_TRANSIENT;
  } else {
    object = getHydrator().recreateAdapter(getOid(), spec);
    targetState = ResolveState.UPDATING;
  }
  if (object.getSpecification().isCollection()) {
    populateCollection(object, (CollectionData) state, targetState);
  } else {
    updateObject(object, state, targetState);
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("recreated object " + object.getOid());
  }
  return object;
}

代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime

@Override
  public TestProxyAdapter createAdapter(final Object pojo, final Oid oid) {
    final TestProxyAdapter testProxyObjectAdapter = new TestProxyAdapter();
    testProxyObjectAdapter.setupObject(pojo);
    testProxyObjectAdapter.setupOid(oid);
    testProxyObjectAdapter.setupResolveState(oid == null ? ResolveState.VALUE : oid.isTransient() ? ResolveState.TRANSIENT : ResolveState.GHOST);
    testProxyObjectAdapter.setupSpecification(IsisContext.getSpecificationLoader().loadSpecification(pojo.getClass()));
    return testProxyObjectAdapter;
  }
}

代码示例来源:origin: org.apache.isis.core/isis-core-runtime

private void updateFieldsAndResolveState(final ObjectAdapter objectAdapter, final Data data) {
  
  boolean dataIsTransient = data.getOid().isTransient();
  
  if (!dataIsTransient) {
    updateFields(objectAdapter, data);
    objectAdapter.getOid().setVersion(data.getOid().getVersion());
  } else if (objectAdapter.isTransient() && dataIsTransient) {
    updateFields(objectAdapter, data);
    
  } else if (objectAdapter.isParentedCollection()) {
    // this branch is kind-a wierd, I think it's to handle aggregated adapters.
    updateFields(objectAdapter, data);
    
  } else {
    final ObjectData od = (ObjectData) data;
    if (od.containsField()) {
      throw new IsisException("Resolve state (for " + objectAdapter + ") inconsistent with fact that data exists for fields");
    }
  }
}

代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime

private ObjectAdapter recreateReference(final Data data) {
  final ObjectSpecification spec = getSpecificationLoader().loadSpecification(data.getClassName());
  if (data instanceof StandaloneData) {
    final StandaloneData standaloneData = (StandaloneData) data;
    return standaloneData.getAdapter();
  } else {
    final Oid oid = data.getOid();
    if (oid == null) {
      return null;
    }
    ObjectAdapter ref;
    ref = getHydrator().recreateAdapter(oid, spec);
    if (data instanceof ObjectData) {
      if (oid.isTransient() || spec.isAggregated()) {
        final ResolveState resolveState = spec.isAggregated() ? ResolveState.GHOST : ResolveState.TRANSIENT;
        if (ref.getResolveState().isValidToChangeTo(resolveState)) {
          ref.changeState(resolveState);
        }
        updateObject(ref, data, resolveState);
      }
    }
    return ref;
  }
}

代码示例来源:origin: org.apache.isis.runtimes.dflt/runtime

public ObjectAdapter adapter(final String name, final int id, final boolean isTransient) {
  final ObjectAdapter object = mockery.mock(ObjectAdapter.class, name + id);
  final Oid oid = mockery.mock(Oid.class, name + "#" + id);
  mockery.checking(new Expectations() {
    {
      atLeast(0).of(object).getOid();
      will(returnValue(oid));
      atLeast(0).of(object).getResolveState();
      will(returnValue(ResolveState.TRANSIENT));
      atLeast(0).of(object).getSpecification();
      will(returnValue(emptySpecification));
      atLeast(0).of(oid).isTransient();
      will(returnValue(isTransient));
    }
  });
  return object;
}

相关文章