Package com.alvazan.orm.api.z8spi.meta

Examples of com.alvazan.orm.api.z8spi.meta.RowToPersist


        entity = temp;
        BeanProps.copyProps(originalEntity, entity);
      }
    }
   
    RowToPersist row = metaClass.translateToRow(entity);
   
    DboTableMeta metaDbo = metaClass.getMetaDbo();
    if (metaDbo.isEmbeddable())
      throw new IllegalArgumentException("Entity type="+entity.getClass().getName()+" can not be saved as it is Embedded Entity. And Embeddable entitites are only saved along with their parent entity");
    //This is if we need to be removing columns from the row that represents the entity in a oneToMany or ManyToMany
    //as the entity.accounts may have removed one of the accounts!!!
    if(row.hasRemoves())
      session.remove(metaDbo, row.getKey(), row.getColumnNamesToRemove());

    //NOW for index removals if any indexed values change of the entity, we remove from the index
    for(IndexData ind : row.getIndexToRemove()) {
      session.removeFromIndex(metaDbo, ind.getColumnFamilyName(), ind.getRowKeyBytes(), ind.getIndexColumn());
    }
   
    //NOW for index adds, if it is a new entity or if values change, we persist those values
    for(IndexData ind : row.getIndexToAdd()) {
      session.persistIndex(metaDbo, ind.getColumnFamilyName(), ind.getRowKeyBytes(), ind.getIndexColumn());
    }

    byte[] virtKey = row.getVirtualKey();
    List<Column> cols = row.getColumns();
    session.put(metaDbo, virtKey, cols);
  }
View Full Code Here


  public void put(String colFamily, TypedRow typedRow) {
    DboTableMeta metaClass = cachedMeta.getMeta(colFamily);
    if(metaClass == null)
      throw new IllegalArgumentException("DboTableMeta for colFamily="+colFamily+" was not found");

    RowToPersist row = metaClass.translateToRow(typedRow);
   
    byte[] virtualKey = row.getVirtualKey();
    //This is if we need to be removing columns from the row that represents the entity in a oneToMany or ManyToMany
    //as the entity.accounts may have removed one of the accounts!!!
    if(row.hasRemoves())
      session.remove(metaClass, virtualKey, row.getColumnNamesToRemove());
   
    //NOW for index removals if any indexed values change of the entity, we remove from the index
    for(IndexData ind : row.getIndexToRemove()) {
      session.removeFromIndex(metaClass, ind.getColumnFamilyName(), ind.getRowKeyBytes(), ind.getIndexColumn());
    }
   
    //NOW for index adds, if it is a new entity or if values change, we persist those values
    for(IndexData ind : row.getIndexToAdd()) {
      session.persistIndex(metaClass, ind.getColumnFamilyName(), ind.getRowKeyBytes(), ind.getIndexColumn());
    }
   
    List<Column> cols = row.getColumns();
    session.put(metaClass, virtualKey, cols);
  }
View Full Code Here

  }

  @Override
  public void translateToColumn(InfoForIndex<OWNER> info) {
    OWNER entity = info.getEntity();
    RowToPersist row = info.getRow();
    if(field.getType().equals(Map.class))
      translateToColumnMap(entity, row);
    else
      translateToColumnList(entity, row);
  }
View Full Code Here

   
    addIndexRemoves(info, value, byteVal, storageType);
  }
 
  private void addIndexRemoves(InfoForIndex<OWNER> info, Object value, byte[] byteVal, StorageTypeEnum storageType) {
    RowToPersist row = info.getRow();
    Map<Field, Object> fieldToValue = info.getFieldToValue();
    //if we are here, we are indexed, BUT if fieldToValue is null, then it is a brand new entity and not a proxy
    if(valuesEqual(fieldToValue, value))
      return;

    Object originalValue = fieldToValue.get(field);
    byte[] pk = row.getKey();
    byte[] oldIndexedVal = translateValue(originalValue);
   
    List<IndexData> indexList = row.getIndexToRemove();
   
    addToList(info, oldIndexedVal, storageType, pk, indexList);
  }
View Full Code Here

    addToList(info, oldIndexedVal, storageType, pk, indexRemoves);
  }
 
  protected void addIndexInfo(InfoForIndex<OWNER> info, Object value, byte[] byteVal, StorageTypeEnum storageType) {
    OWNER entity = info.getEntity();
    RowToPersist row = info.getRow();
    Map<Field, Object> fieldToValue = info.getFieldToValue();
   
    if(!this.getMetaDbo().isIndexed())
      return;
    else if(storageType == StorageTypeEnum.BYTES)
      throw new IllegalArgumentException("Cannot do indexing for types that are stored as bytes at this time");
   
    if(!isNeedPersist(entity, value, fieldToValue))
      return;
   
    //original value and current value differ so we need to persist new value
    byte[] pk = row.getKey();
    List<IndexData> indexList = row.getIndexToAdd();
    addToList(info, byteVal, storageType, pk, indexList);
  }
View Full Code Here

      field.translateFromColumn(row, inst, session);
    }
  }
 
  public RowToPersist translateToRow(T entity) {
    RowToPersist row = new RowToPersist();
    Map<Field, Object> fieldToValue = null;
    if(entity instanceof NoSqlProxy) {
      fieldToValue = ((NoSqlProxy) entity).__getOriginalValues();
    }
   
View Full Code Here

    if(entity instanceof Proxy) {
      clazz = entity.getClass().getSuperclass();
    }
    String type = classToType.get(clazz.getName());
    MetaClassSingle<T> metaClassSingle = dbTypeToMeta.get(type);
    RowToPersist translateToRow = metaClassSingle.translateToRow(entity);
   
    byte[] value = StandardConverters.convertToBytes(type);
    Column typeCol = new Column();
    typeCol.setName(discColAsBytes);
    typeCol.setValue(value);
    translateToRow.getColumns().add(typeCol);
    return translateToRow;
  }
View Full Code Here

  public void put(String colFamily, TypedRow typedRow) {
    DboTableMeta metaClass = cachedMeta.getMeta(colFamily);
    if(metaClass == null)
      throw new IllegalArgumentException("DboTableMeta for colFamily="+colFamily+" was not found");

    RowToPersist row = metaClass.translateToRow(typedRow);
   
    //This is if we need to be removing columns from the row that represents the entity in a oneToMany or ManyToMany
    //as the entity.accounts may have removed one of the accounts!!!
    if(row.hasRemoves())
      session.remove(metaClass, row.getKey(), row.getColumnNamesToRemove());
   
    //NOW for index removals if any indexed values change of the entity, we remove from the index
    for(IndexData ind : row.getIndexToRemove()) {
      session.removeFromIndex(metaClass, ind.getColumnFamilyName(), ind.getRowKeyBytes(), ind.getIndexColumn());
    }
   
    //NOW for index adds, if it is a new entity or if values change, we persist those values
    for(IndexData ind : row.getIndexToAdd()) {
      session.persistIndex(metaClass, ind.getColumnFamilyName(), ind.getRowKeyBytes(), ind.getIndexColumn());
    }
   
    byte[] virtualKey = row.getVirtualKey();
    List<Column> cols = row.getColumns();
    session.put(metaClass, virtualKey, cols);
  }
View Full Code Here

 
  @Override
  public void translateToColumn(InfoForIndex<OWNER> info) {
    OWNER entity = info.getEntity();
   
    RowToPersist row = info.getRow();
    if(field.getType().equals(Map.class))
      translateToColumnMap(entity, row);
    else
      translateToColumnList(entity, row);
  }
View Full Code Here

   
    addIndexRemoves(info, value, byteVal, storageType);
  }
 
  private void addIndexRemoves(InfoForIndex<OWNER> info, Object value, byte[] byteVal, StorageTypeEnum storageType) {
    RowToPersist row = info.getRow();
    Map<Field, Object> fieldToValue = info.getFieldToValue();
    //if we are here, we are indexed, BUT if fieldToValue is null, then it is a brand new entity and not a proxy
    Object originalValue = fieldToValue.get(field);
    if(originalValue == null)
      return;
    else if(originalValue.equals(value))
      return; //previous value is the same, yeah, nothing to do here!!!
     
    byte[] pk = row.getKey();
    byte[] oldIndexedVal = translateValue(originalValue);
   
    List<IndexData> indexList = row.getIndexToRemove();
   
    addToList(info, oldIndexedVal, storageType, pk, indexList);
  }
View Full Code Here

TOP

Related Classes of com.alvazan.orm.api.z8spi.meta.RowToPersist

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.