Package com.alvazan.orm.api.z8spi.action

Examples of com.alvazan.orm.api.z8spi.action.Column


  }

  public void translateFromColumn(Row row, OWNER entity, NoSqlSession session) {
    String columnName = getColumnName();
    byte[] colBytes = StandardConverters.convertToBytes(columnName);
    Column column = row.getColumn(colBytes);
    if(column == null) {
      column = new Column();
    }
   
    Object proxy;
    if(field.getType().equals(ToOneProvider.class))
      proxy = translateFromToProxy(row, column.getValue(), session);
    else {
      proxy = convertIdToProxy(row, column.getValue(), session);
    }
   
    ReflectionUtil.putFieldValue(entity, field, proxy);
  }
View Full Code Here


  @SuppressWarnings("unchecked")
  public void translateToColumn(InfoForIndex<OWNER> info) {
    OWNER entity = info.getEntity();
    RowToPersist row = info.getRow();
   
    Column col = new Column();
    row.getColumns().add(col);
   
    PROXY value = (PROXY) ReflectionUtil.fetchFieldValue(entity, field);
   
    if(value instanceof ToOneProvider)
      value = (PROXY) ((ToOneProvider)value).get();
   
    //Value is the Account.java or a Proxy of Account.java field and what we need to save in
    //the database is the ID inside this Account.java object!!!!
    byte[] byteVal = classMeta.convertEntityToId(value);
    if(byteVal == null && value != null) {
      //if value is not null but we get back a byteVal of null, it means the entity has not been
      //initialized with a key yet, BUT this is required to be able to save this object
      String owner = "'"+field.getDeclaringClass().getSimpleName()+"'";
      String child = "'"+field.getType().getSimpleName()+"'";
      String fieldName = "'"+field.getType().getSimpleName()+" "+field.getName()+"'";
      throw new ChildWithNoPkException("The entity you are saving of type="+owner+" has a field="+fieldName
          +" that does not yet have a primary key so you cannot save it.  To correct this\n" +
          "problem, you can either\n"
          +"1. SAVE the "+child+" BEFORE you save the "+owner+" OR\n"
          +"2. Call entityManager.fillInWithKey(Object entity), then SAVE your "+owner+"', then save your "+child+" NOTE that this" +
              "\nmethod #2 is used for when you have a bi-directional relationship where each is a child of the other");
    }
   
    byte[] colBytes = StandardConverters.convertToBytes(columnName);
    col.setName(colBytes);
    col.setValue(byteVal);
   
    StorageTypeEnum storageType = getStorageType();
    Object primaryKey = classMeta.fetchId(value);
    addIndexInfo(info, primaryKey, byteVal, storageType);
    removeIndexInfo(info, primaryKey, byteVal, storageType);
View Full Code Here

      DboColumnMeta colMeta = col.getColumnMeta();
      if(colMeta != null)
        continue;
     
      List<Column> columns = row.getColumns();
      Column c = new Column();
      c.setName(col.getNameRaw());
      c.setValue(col.getValueRaw());
      columns.add(c);
    }
   
    return row;
  }
View Full Code Here

      com.netflix.astyanax.model.Row<byte[], byte[]> row, Row r) {
    for(com.netflix.astyanax.model.Column<byte[]> col : row.getColumns()) {
      byte[] name = col.getName();
      byte[] val = col.getByteArrayValue();
      long timestamp = col.getTimestamp();
      Column c = new Column();
      c.setName(name);
      if(val.length != 0)
        c.setValue(val);
      c.setTimestamp(timestamp);
     
      r.put(name, c);
    }
  }
View Full Code Here

  public String toString() {
    return "MetaCommonField [field='" + field.getDeclaringClass().getName()+"."+field.getName()+"(field type=" +field.getType()+ "), columnName=" + columnName + "]";
  }
 
  public void translateFromColumn(Row row, OWNER entity, NoSqlSession session) {
    Column column = row.getColumn(getMetaDbo().getColumnNameAsBytes());
   
    if(column == null) {
      column = new Column();
    }
   
    Object value = converter.convertFromNoSql(column.getValue());
    ReflectionUtil.putFieldValue(entity, field, value);
  }
View Full Code Here

  @Override
  public void translateToColumn(InfoForIndex<OWNER> info) {
    OWNER entity = info.getEntity();
    RowToPersist row = info.getRow();
   
    Column col = new Column();
    row.getColumns().add(col);

    Object value = ReflectionUtil.fetchFieldValue(entity, field);
    byte[] byteVal = translateValue(value);
    byte[] colBytes = StandardConverters.convertToBytes(columnName);
    col.setName(colBytes);
    col.setValue(byteVal);
   
    StorageTypeEnum storageType = metaDbo.getStorageType();
    addIndexInfo(info, value, byteVal, storageType);
    removeIndexInfo(info, value, byteVal, storageType);
  }
View Full Code Here

  private Object translateFromSingleEntity(Row row, NoSqlSession session) {
    Object proxy = null;
    String columnName = getColumnName();
    byte[] colBytes = StandardConverters.convertToBytes(columnName);
    Column column = row.getColumn(colBytes);
    if (column == null) {
      column = new Column();
    }
    if (field.getType().equals(ToOneProvider.class)) {
      // THIS IS NOT DONE YET
      proxy = translateFromToComposite(row, session);
    } else {
View Full Code Here

  private Object translateFromToComposite(Row row, NoSqlSession session) {
    // THIS IS NOT DONE YET
    byte[] bytes = StandardConverters.convertToBytes(columnName);
    Collection<Column> columns = row.columnByPrefix(bytes);
    if (columns != null && !columns.isEmpty()) {
      Column column = columns.iterator().next();
      byte[] fullName = column.getName();
      // strip off the prefix to get the foreign key
      int pkLen = fullName.length - bytes.length;
      byte[] fk = new byte[pkLen];
      for (int i = bytes.length; i < fullName.length; i++) {
        fk[i - bytes.length] = fullName[i];
View Full Code Here

  private Object convertIdToProxyComposite(Row row, NoSqlSession session) {
    byte[] bytes = StandardConverters.convertToBytes(columnName);
    Collection<Column> columns = row.columnByPrefix(bytes);
    byte[] rowid = StandardConverters.convertToBytes("Id");
    if (columns != null && !columns.isEmpty()) {
      Column column = columns.iterator().next();
      byte[] fullName = column.getName();
      int bytesandrowid = bytes.length + rowid.length;
      // strip off the prefix to get the foreign key
      int pkLen = fullName.length - bytesandrowid;
      byte[] pk = new byte[pkLen];
      for (int i = bytesandrowid; i < fullName.length; i++) {
View Full Code Here

      return;
    for (PROXY proxy : toBeAdded) {
      byte[] name = formTheName(proxy);
      if (name != null) {
        // rowkey is not null. i.e., NoSqlId is present
        Column idColumn = new Column();
        idColumn.setName(name);
        idColumn.setValue(null);
        row.getColumns().add(idColumn);
        byte[] idValue = translateOne(proxy);
        Field[] fieldsinClass = proxy.getClass().getDeclaredFields();
        for (Field singleField : fieldsinClass) {
          singleField.setAccessible(true);
View Full Code Here

TOP

Related Classes of com.alvazan.orm.api.z8spi.action.Column

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.