Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

IdAS Update Proposals

The current way Digital Subjects are updated in IdAS is seen as cumbersome. Here we explore other options. First we list the options, then use cases, then apply the use cases to the different options.

note: "IdAS element" means the things that make up a context (digital subject, attributes, metadata, and their values).

Proposals

  1. Current methodology
  2. Live updates to IdAS elements
  3. Committed updates to IdAS elements
    1. Also remove build<element> methods
      1. Different transaction model
  4. Distillation of other proposals


Use Cases

Following is a list of use cases along with some pseudo-code for different proposals. These all assume one already has an IContext instance called myContext. They also ignore exceptions and probably some other things.

Add a new subject with some attributes (simple and complex) from scratch

When the user knows enough about the model to know what attribute types are allowed

Proposal 4

// Create a subject named John Doe
IDigitalSubject mySubject = myContext.addSubject(PERSON_TYPE_URI, "John Doe");

// Add a phone number attribute with two values
IAttribute myPhoneAttr = mySubject.addAttribute(PHONE_ATTR_TYPE_URI);
myPhoneAttr.addSimpleValue(STRING_TYPE_URI, "+1 801 861 8000");
myPhoneAttr.addSimpleValue(STRING_TYPE_URI, "+1 801 555 1212");

// Add a complex attribute (address which is {street, city, state, zip})
IAttribute myAddress = mySubject.addAttribute(ADDR_ATTR_TYPE_URI);
IComplexValue myAddressVal = myAddress.addComplexValue(ADDR_TYPE_URI);
IProperty myStreet myAddressVal.addProperty(STREET_PROP_TYPE);
myStreet.addSimpleValue(STRING_TYPE_URI, "123 Elm Street");
IProperty myCity myAddressVal.addProperty(CITY_PROP_TYPE);
myCity.addSimpleValue(STRING_TYPE_URI, "Springfield");
IProperty myState myAddressVal.addProperty(STATE_PROP_TYPE);
myState.addSimpleValue(STRING_TYPE_URI, "IL");
IProperty myZip myAddressVal.addProperty(ZIP_PROP_TYPE);
myZip.addSimpleValue(INT_TYPE_URI, "55123");

// Signal the CP that we're done
mySubject.applyUpdates();

When the user needs to discover the attribute types allowed

Delete a subject

Proposal 4

// Delete the "John Doe" subject
IDigitalSubject mySubject = myContext.getSubject("John Doe");
mySubject.remove();
mySubject.applyUpdates();

Add a value to a simple attribute on an existing subject

Proposal 4

IDigitalSubject mySubject = myContext.getSubject("John Doe");
IAttribute myPhoneAttr = mySubject.getAttribute(PHONE_ATTR_TYPE_URI);
myPhoneAttr.addSimpleValue(STRING_TYPE_URI, "+1 801 555 1212");
mySubject.applyUpdates();

Delete a value from a simple attribute on an existing subject

Proposal 4

// Get the phone number attr for the "John Doe" subject
IDigitalSubject mySubject = myContext.getSubject("John Doe");
IAttribute myPhoneAttr = mySubject.getAttribute(PHONE_ATTR_TYPE_URI);
// Delete just the "+1 801 555 1212" value
Iterator myPhoneVals = myPhoneAttr.getValues();
while (myPhoneVals.hasNext()) {
  IPropertyValue curVal = (IPropertyValue)myPhoneVals.next();
  if (curVal.getData().equals("+1 801 555 1212") {
    curVal.remove();
    break;
  }
}
mySubject.applyUpdates();

Add a value to a complex attribute on an existing subject

Proposal 4

IDigitalSubject mySubject = myContext.getSubject("John Doe");
IAttribute myPhoneAttr = mySubject.getAttribute(PHONE_ATTR_TYPE_URI);

// Add a complex attribute (address which is {street, city, state, zip})
IAttribute myAddress = mySubject.addAttribute(ADDR_ATTR_TYPE_URI);
IComplexValue myAddressVal = myAddress.addComplexValue(ADDR_TYPE_URI);
IProperty myStreet myAddressVal.addProperty(STREET_PROP_TYPE);
myStreet.addSimpleValue(STRING_TYPE_URI, "123 Elm Street");
IProperty myCity myAddressVal.addProperty(CITY_PROP_TYPE);
myCity.addSimpleValue(STRING_TYPE_URI, "Springfield");
IProperty myState myAddressVal.addProperty(STATE_PROP_TYPE);
myState.addSimpleValue(STRING_TYPE_URI, "IL");
IProperty myZip myAddressVal.addProperty(ZIP_PROP_TYPE);
myZip.addSimpleValue(INT_TYPE_URI, "55123");

mySubject.applyUpdates();

Delete a value from a complex attribute on an existing subject

Proposal 4

// Get the address attr for the "John Doe" subject
IDigitalSubject mySubject = myContext.getSubject("John Doe");
IAttribute myAddrAttr = mySubject.getAttribute(ADDR_ATTR_TYPE_URI);

// Delete the value where state is "IL"
Iterator myAddrVals = myAddrAttr.getValues();
while (myAddrVals.hasNext()) {
  IComplexValue curVal = (IComplexValue)myAddrVals.next();
  IPropertyValue stateVal = curVal.getProperty("STATE_PROP_TYPE");
  if (stateVal.getData().equals("IL") {
    curVal.remove();
    break;
  } 
}
mySubject.applyUpdates();

Delete and add an element to an existing value of a complex attribute on an existing subject

Proposal 4

// Get the address attr for the "John Doe" subject
IDigitalSubject mySubject = myContext.getSubject("John Doe");
IAttribute myAddrAttr = mySubject.getAttribute(ADDR_ATTR_TYPE_URI);

// Find the value where state is "IL", change it to "MN"
Iterator myAddrVals = myAddrAttr.getValues();
while (myAddrVals.hasNext()) {
  IComplexValue curVal = (IComplexValue)myAddrVals.next();
  IProperty state = curVal.getProperty("STATE_PROP_TYPE");
  ISimpleValue stateVal = ((ISimpleValue)state).getValue();
  if (stateVal.getData().equals("IL") {
    state.remove();
    IProperty newState = curVal.addProperty("STATE_PROP_TYPE");
    newState.addSimpleValue(STRING_TYPE_URI, "MN");
    break;
  } 
}

mySubject.applyUpdates();

Alternate (if we allow ISimpleValue.setData to be called after data has been already set)

// Get the address attr for the "John Doe" subject
IDigitalSubject mySubject = myContext.getSubject("John Doe");
IAttribute myAddrAttr = mySubject.getAttribute(ADDR_ATTR_TYPE_URI);

// Find the value where state is "IL", change it to "MN"
Iterator myAddrVals = myAddrAttr.getValues();
while (myAddrVals.hasNext()) {
  IComplexValue curVal = (IComplexValue)myAddrVals.next();
  IProperty state = curVal.getProperty("STATE_PROP_TYPE");
  ISimpleValue stateVal = ((ISimpleValue)state).getValue();
  if (stateVal.getData().equals("IL") {
    stateVal.setData("MN");
    break;
  } 
}

mySubject.applyUpdates();

Replace all values of an existing attribute with some new values

Copy some attributes from one subject to another

Add some metadata to an existing attribute

Update attributes on two subjects in one atomic transaction

Links

Back to the top