Examples of Modifier


Examples of org.dmd.dmc.types.Modifier

  DmcTypeModifierMV getModifierSlice(DmcSliceInfo slice, DmcTypeModifierMV source){
    DmcTypeModifierMV rc = new DmcTypeModifierMV();
   
    Iterator<Modifier> mods = source.getMV();
    while(mods.hasNext()){
      Modifier mod = mods.next();
      if (slice.contains(mod.getAttributeID())){
        try {
          rc.add(mod);
        } catch (DmcValueException e) {
          throw(new IllegalStateException("Should not throw an exception adding a Modifier to a DmcTypeModifier"));
        }
View Full Code Here

Examples of org.dmd.dmc.types.Modifier

  public boolean thisAttributeModified(DmcAttributeInfo ai){
    if (getEventTypeDMP() == DMPEventTypeEnum.MODIFIED){
      DmcTypeModifierMV mods = getModifyAttribute();
      if (mods != null){
        for(int i=0; i<mods.getMVSize(); i++){
          Modifier mod = mods.getMVnth(i);
          DmcAttributeInfo modai = mod.getAttributeInfo();
          if (modai == null)
            throw(new IllegalStateException("Couldn't get attriute info for: " + mod.getAttributeName()));
          if (modai.id == ai.id)
            return(true);
        }
      }
    }
View Full Code Here

Examples of org.dmd.dmc.types.Modifier

        throw(new IllegalStateException("Malformed DMPEvent. Missing modify attribute for a MODIFIED event."));
     
      Iterator<Modifier>  modifiers = getModifyAttribute().getMV();
      if (modifiers != null){
        while(modifiers.hasNext()){
          Modifier mod = modifiers.next();
          if (mod.getAttribute() == null){
            if (mod.getModifyType() == ModifyTypeEnum.REM){
              AttributeDefinition ad = DmwOmni.instance().getSchema().adef(mod.getAttributeName());
              if (ad == null)
                throw(new IllegalStateException("Malformed DMPEvent. Could not get definition for attribute: " + mod.getAttributeName()));
              else
                if (ad.getDataType() == DataTypeEnum.PERSISTENT){
                  rc = true;
                  break;
                }
            }
            else if (mod.getModifyType() == ModifyTypeEnum.NTH){
              AttributeDefinition ad = DmwOmni.instance().getSchema().adef(mod.getAttributeName());
              if (ad == null)
                throw(new IllegalStateException("Malformed DMPEvent. Could not get definition for attribute: " + mod.getAttributeName()));
              else
                if (ad.getDataType() == DataTypeEnum.PERSISTENT){
                  rc = true;
                  break;
                }
            }
            else
              throw(new IllegalStateException("Malformed DMPEvent. Missing attribute for a Modifier: " + mod.toString()));
          }
          else if (mod.getAttribute().getAttributeInfo().dataType == DataTypeEnum.PERSISTENT){
            rc = true;
            break;
          }
        }
      }
View Full Code Here

Examples of org.dmd.dmc.types.Modifier

    // as a single operation, thus we create a new DmcTypeModifierMV and add the single Modifier
    // to it. We don;t attempt to reuse the same modifier because these may be used in events.
    Iterator<Modifier> it = mods.getMV();
    while(it.hasNext()){
      DmcTypeModifierMV single = new DmcTypeModifierMV();
      Modifier mod = it.next();
      try {
        // Add the Modifier to our temporary
        single.add(mod);
       
        if (cache == null)
          ((DmcObject)mod.getReferringObject()).applyModifier(single);
        else
          cache.applyModification(mod.getReferringObject(), single);
       
      } catch (DmcValueException e) {
        throw(new IllegalStateException("Adding a prebuilt Modifier to a DmcTypeModifierMV shouldn't thrown an exception."));
      } catch (DmcValueExceptionSet e) {
        throw(new IllegalStateException("Removing a back reference shouldn't thrown an exception."));
View Full Code Here

Examples of org.dmd.dmc.types.Modifier

 
  protected void addModsSV(DmcTypeModifierMV mods, DmcAttribute<?> existingValue, DmcAdapterIF adapter){
    try {
      if (existingValue == null){
        if (adapter.hasValue())
          mods.add(new Modifier(ModifyTypeEnum.SET, this.cloneIt()));
      }
      else{
        if (!adapter.hasValue())
          mods.add(new Modifier(ModifyTypeEnum.REM, attrInfo));
        else
          mods.add(new Modifier(ModifyTypeEnum.SET, this.cloneIt()));
      }
    } catch (DmcValueException e) {
      throw(new IllegalStateException("Changes to the Modifier shouldn't throw an exception.", e));
    }
  }
View Full Code Here

Examples of org.dmd.dmc.types.Modifier

            Iterator<VALUE> it = getMV();
            while(it.hasNext()){
              VALUE current = it.next();
              DmcAttribute<?> mod = getNew();
              mod.add(current);
              mods.add(new Modifier(ModifyTypeEnum.ADD, mod));
            }
          }
          else{
            for(int index=0; index<getMVSize(); index++){
              if (getMVnth(index) != null){
                DmcAttribute<?> mod = getNew();
                mod.setMVnth(index,getMVnth(index));
                mods.add(new Modifier(ModifyTypeEnum.NTH, mod, index));
              }
            }
          }
        }
      }
      else{
        if (!adapter.hasValue())
          mods.add(new Modifier(ModifyTypeEnum.REM, attrInfo));
        else{
          // Have to determine the delta
          if (attrInfo.indexSize == 0){
            Iterator<?> eit = existingValue.getMV();
            while(eit.hasNext()){
              Object current = eit.next();
              if (!contains(current)){
                // The value no longer exists, delete it
                DmcAttribute<?> mod = getNew();
                mod.add(current);
                mods.add(new Modifier(ModifyTypeEnum.DEL, mod));
              }
            }
            Iterator<VALUE> it = getMV();
            while(it.hasNext()){
              VALUE current = it.next();
              if (!existingValue.contains(current)){
                // The existing value is missing this value, add it
                DmcAttribute<?> mod = getNew();
                mod.add(current);
                mods.add(new Modifier(ModifyTypeEnum.ADD, mod));
              }
            }
          }
          else{
            for(int index=0; index<getMVSize(); index++){
              Object existing = existingValue.getMVnth(index);
              Object current  = getMVnth(index);
              boolean replace = false;
             
              if (existing == null){
                if (current != null)
                  replace = true;
              }
              else{
                if (current == null)
                  replace = true;
                else{
                  if (!existing.equals(current))
                    replace = true;
                }
              }
             
              if (replace){
                DmcAttribute<?> mod = getNew();
                mod.setMVnth(index,current);
                mods.add(new Modifier(ModifyTypeEnum.NTH, mod, index));
              }
            }
          }
        }
      }
View Full Code Here

Examples of org.dmd.dmc.types.Modifier

    }
   
    @Override
    // org.dmd.dms.util.GenUtility.dumpSVType(GenUtility.java:2010)
    public Modifier set(Object v) throws DmcValueException {
        Modifier rc = typeCheck(v);
        // We only return a value if the value actually changed. This supports
        // the applyModifier() mechanism on DmcObject where we only return true
        // if something changed as a result of the modifier
        if (value == null)
            value = rc;
View Full Code Here

Examples of org.dmd.dmc.types.Modifier

          if (DmcOmni.instance().backRefTracking() && DmcOmni.instance().trackThisAttribute(attr.ID)){
            if (attr instanceof DmcTypeNamedObjectREF){
              // We're modifying a reference attribute, so track that puppy
              DmcObject obj = ((DmcObject)((DmcNamedObjectREF<?>)attr.getSV()).getObject());
              if (obj != null){
                Modifier backrefMod = new Modifier(ModifyTypeEnum.SET,attr,this);
                obj.addBackref(backrefMod);
               
                // Let the reference know the backref modifier - this allows us to
                // easily remove the backref if the reference is deleted
                ((DmcNamedObjectREF<?>)attr.getSV()).setBackrefModifier(backrefMod);
              }
            }
          }
        }
      }
      else{
        getModifier().add(new Modifier(ModifyTypeEnum.SET, attr));
      }
     
//    if ( (getContainer() != null) && (getContainer().getListenerManager() == null) ){
//      // TODO implement attribute change listener hooks
//    }
View Full Code Here

Examples of org.dmd.dmc.types.Modifier

                // We're modifying a reference attribute, so track that puppy
                DmcAttribute<?> mod = attr.getNew();
                mod.setAttributeInfo(ai);
                mod.add(getLastValue());
               
                Modifier backrefMod = new Modifier(ModifyTypeEnum.ADD,mod,this);
                ((DmcObject)((DmcNamedObjectREF<?>)getLastValue()).getObject()).addBackref(backrefMod);
               
                // Let the reference know the backref modifier - this allows us to
                // easily remove the backref if the reference is deleted
                ((DmcNamedObjectREF<?>)getLastValue()).setBackrefModifier(backrefMod);
              }
            }
          }
        }
      }
     
      if (getModifier() != null){
        if (getLastValue() == null){
          // Last value can be null in the case of SET attributes since we don't
          // actually add a value to the SET if it already exists. However, in other
          // cases, this is a code error - so pitch a fit!
          if ( (ai.valueType != ValueTypeEnum.HASHMAPPED) && (ai.valueType != ValueTypeEnum.TREEMAPPED)){
            // This is okay
          }
          else if ( (ai.valueType != ValueTypeEnum.HASHSET) && (ai.valueType != ValueTypeEnum.TREESET)){
            throw(new IllegalStateException("Last value shouldn't be null."));
          }
        }
        else{
          // Get an attribute value holder of the same type and hang on to the last
          // value that was added to it
          DmcAttribute<?> mod = attr.getNew();
          mod.setAttributeInfo(ai);
         
          mod.add(getLastValue());
          getModifier().add(new Modifier(ModifyTypeEnum.ADD, mod));
        }
      }
     
     
//    if ( (getContainer() != null) && (getContainer().getListenerManager() == null) ){
View Full Code Here

Examples of org.dmd.dmc.types.Modifier

   * @param value The value to be deleted.
   */
  protected void delFromEmptyAttribute(DmcAttribute<?> mod, Object value){
    try {
      mod.add(value);
      getModifier().add(new Modifier(ModifyTypeEnum.DEL, mod));   
    } catch (DmcValueException e) {
      if ( (mod.getAttributeInfo().valueType == ValueTypeEnum.HASHMAPPED) ||
           (mod.getAttributeInfo().valueType == ValueTypeEnum.TREEMAPPED) ){
        throw(new IllegalStateException("Changes to the Modifier shouldn't throw an exception. This is a MAPPED attribute and typeCheck () should accept just the key value as well as the mapped type itself.", e));
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.