public Record getRecord() { Record record = new Record(); if(this.id != null && this.id.trim().length() > 0) { record.setRecordId(this.id); } record.setValue("target", this.target); record.setValue("lastSync", this.lastSync); record.setValue("nextSync", this.nextSync); return record; }
public ChangeLogEntry(Record record) { this.id = record.getRecordId(); this.nodeId = record.getValue("storageId"); this.operation = record.getValue("operation"); this.recordId = record.getValue("sync-recordId"); }
private void prepareToPersist(Record record, BusRegistration reg) { String dirtyStatus = record.getDirtyStatus(); record.getState().clear(); record.setRecordId(reg.getBusId()); if(reg.getInvocationHandlers() != null) { for(String handler:reg.getInvocationHandlers()) { record.setValue(handler, handler); } } if(dirtyStatus != null) { record.setDirtyStatus(dirtyStatus); } }
public boolean isStoreable() { long size = 0; Set<String> names = this.getNames(); for(String name:names) { String value = this.getValue(name); /* * Alteração feita na versão 2.4-M3.1 do OpenMobster. * Suporte a valores nulos para o contorno feito em OpenMobsterBugUtils.onBeforeInsertRecord. */ if (value == null) { continue; } size += name.length(); size += value.length(); } //Object is too big for local storage if(size > 2000000) { return false; } return true; } }
Record record = new Record(); record.setRecordId(this.recordId); record.setDirtyStatus(this.dirtyStatus); record.setValue("serverRecordId", this.serverRecordId); record.setValue("storageId", storageId); record.setValue("isCreatedOnDevice", Boolean.TRUE.toString()); record.setValue("isCreatedOnDevice", Boolean.FALSE.toString()); record.setValue("isLocked", Boolean.TRUE.toString()); record.setValue("isLocked", Boolean.FALSE.toString()); record.setValue("isProxy", Boolean.TRUE.toString()); record.setValue("isProxy", Boolean.FALSE.toString()); record.setValue("count", String.valueOf(this.fields.size())); record.setValue("field["+index+"].uri", field.getUri()); record.setValue("field["+index+"].name", field.getName()); record.setValue("field["+index+"].value", field.getValue());
private void addRecord(String table,Record record) throws DBException String recordId = record.getRecordId(); record.setDirtyStatus(GeneralTools.generateUniqueId()); Set<String> names = record.getNames(); Map<String,String> nameValuePairs = new HashMap<String,String>(); for(String name: names) String value = record.getValue(name); boolean addProperty = true; String jsonPointer = record.toJson(); String insert = "INSERT INTO "+table+" (recordid,name,value) VALUES (?,?,?);"; this.db.execSQL(insert,new Object[]{recordId,"om:json",jsonPointer});
private BusRegistration parse(Record record) { BusRegistration reg = new BusRegistration(record.getRecordId()); Set<String> names = record.getNames(); for(String name: names) { if(name.equals("recordId") || name.equals("dirty")) { continue; } reg.addInvocationHandler(record.getValue(name)); } return reg; }
this.storageId = record.getValue("storageId"); this.recordId = record.getRecordId(); this.dirtyStatus = record.getDirtyStatus(); if(record.getValue("serverRecordId") != null) this.serverRecordId = record.getValue("serverRecordId"); if(record.getValue("isCreatedOnDevice").equals(Boolean.TRUE.toString())) if(record.getValue("isLocked").equals(Boolean.TRUE.toString())) if(record.getValue("isProxy").equals(Boolean.TRUE.toString())) if(record.getValue("count") != null) int count = Integer.parseInt(record.getValue("count")); for(int index=0; index < count; index++) field.setUri(record.getValue("field["+index+"].uri")); field.setName(record.getValue("field["+index+"].name")); field.setValue(record.getValue("field["+index+"].value")); if(record.getValue("arrayMetaDataCount") != null) int count = Integer.parseInt(record.getValue("arrayMetaDataCount")); for(int index=0; index < count; index++) local.setArrayUri(record.getValue("arrayMetaData["+index+"].arrayUri")); local.setArrayLength(record.getValue("arrayMetaData["+index+"].arrayLength"));
public String getDirtyStatus() { return this.getValue("dirty"); }
public void setDirtyStatus(String dirtyStatus) { this.setValue("dirty", dirtyStatus); }
Record record = new Record(state); all.add(record); this.cache.put(from,record.getRecordId(),record);
record.setRecordId(local); record.setDirtyStatus(local); record.setValue("serverRecordId", local); record.setValue("storageId", local); record.setValue("isCreatedOnDevice", Boolean.TRUE.toString()); record.setValue("isCreatedOnDevice", Boolean.FALSE.toString()); record.setValue("isLocked", Boolean.TRUE.toString()); record.setValue("isLocked", Boolean.FALSE.toString()); record.setValue("isProxy", Boolean.TRUE.toString()); record.setValue("isProxy", Boolean.FALSE.toString()); record.setValue("count", ""+fieldCount); record.setValue("field["+index+"].uri", local); record.setValue("field["+index+"].uri", ""); record.setValue("field["+index+"].name", local); record.setValue("field["+index+"].name", "");
@Override public Uri insert(Uri uri, ContentValues contentValues) { try { Context context = this.getContext(); Database database = Database.getInstance(context); //insert Record errorRecord = new Record(); this.prepareRecord(errorRecord, contentValues); database.insert(Database.system_errors, errorRecord); return uri; } catch(Exception e) { throw new RuntimeException(e); } }
String recordId = contentValues.getAsString("recordId"); Record recordToBeUpdated = new Record(); this.prepareRecord(recordToBeUpdated, contentValues); String dirtyStatus = recordToBeUpdated.getDirtyStatus(); if(dirtyStatus == null || dirtyStatus.trim().length() == 0) recordToBeUpdated.setDirtyStatus(currentRecord.getDirtyStatus());
if(!record.isStoreable()) String recordId = record.getRecordId(); if(recordId == null || recordId.trim().length() == 0) record.setRecordId(recordId); Log.i("OpenMobster Info", String.format("Record inserted: channel = %s, id = %s.", table, record.getRecordId()));
@Override public boolean equals(Object o) { if(!(o instanceof Record)) { return false; } Record incoming = (Record)o; String recordId = this.getRecordId(); String incomingRecordId = incoming.getRecordId(); if(recordId == null || incomingRecordId == null) { return false; } if(recordId.equals(incomingRecordId)) { return true; } return false; }
provisioningRecord.setValue("deviceId", this.deviceId); provisioningRecord.setValue("serverId", this.serverId); provisioningRecord.setValue("serverIp", this.serverIp); provisioningRecord.setValue("plainServerPort", this.plainServerPort); provisioningRecord.setValue("secureServerPort", this.secureServerPort); provisioningRecord.setValue("authenticationHash", this.authenticationHash); provisioningRecord.removeValue("authenticationHash"); provisioningRecord.setValue("authenticationNonce", this.authenticationNonce); provisioningRecord.removeValue("authenticationNonce"); provisioningRecord.setValue("email", this.email); provisioningRecord.removeValue("email"); provisioningRecord.setValue("cometMode", this.cometMode); provisioningRecord.setValue("cometPollInterval", ""+this.cometPollInterval); provisioningRecord.setValue("httpPort", this.httpPort); provisioningRecord.setValue("isSSLActive",
public void update(String into, Record record) throws DBException { //Validate this.validateConnection(into, "update"); //Note: With Android, write threads lock the entire database. //so this operation is thread-safe //Check Dirty Status (support for long transactions) Record stored = this.cloudbMetaData.getCRUDProvider().select(into, record.getRecordId()); if(!stored.getDirtyStatus().equals(record.getDirtyStatus())) { throw new DBException(this.getClass().getName(),"update",new Object[]{into},DBException.ERROR_RECORD_STALE); } this.cloudbMetaData.getCRUDProvider().update(into, record); }