use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.
the class AbstractCodeTable method getIdByValue.
protected Identifier getIdByValue(final List<Object> valueList) {
processValues(valueList);
Identifier id = this.valueIdCache.get(valueList);
if (id == null) {
final List<Object> normalizedValues = getNormalizedValues(valueList);
id = this.valueIdCache.get(normalizedValues);
}
return id;
}
use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.
the class AbstractCodeTable method addValues.
protected synchronized void addValues(final Map<Identifier, List<Object>> valueMap) {
for (final Entry<Identifier, List<Object>> entry : valueMap.entrySet()) {
final Identifier id = entry.getKey();
final List<Object> values = entry.getValue();
addValue(id, values);
}
}
use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.
the class CodeTableProperty method newIdentifier.
protected synchronized Identifier newIdentifier(final List<Object> values) {
if (this.createMissingCodes) {
// TODO prevent duplicates from other threads/processes
final Record code = this.recordStore.newRecord(this.typePath);
final RecordDefinition recordDefinition = code.getRecordDefinition();
Identifier id = this.recordStore.newPrimaryIdentifier(this.typePath);
if (id == null) {
final FieldDefinition idField = recordDefinition.getIdField();
if (idField != null) {
if (Number.class.isAssignableFrom(idField.getDataType().getJavaClass())) {
id = Identifier.newIdentifier(getNextId());
} else {
id = Identifier.newIdentifier(UUID.randomUUID().toString());
}
}
}
code.setIdentifier(id);
for (int i = 0; i < this.valueFieldNames.size(); i++) {
final String name = this.valueFieldNames.get(i);
final Object value = values.get(i);
code.setValue(name, value);
}
final Timestamp now = new Timestamp(System.currentTimeMillis());
if (this.creationTimestampFieldName != null) {
code.setValue(this.creationTimestampFieldName, now);
}
if (this.modificationTimestampFieldName != null) {
code.setValue(this.modificationTimestampFieldName, now);
}
this.recordStore.insertRecord(code);
return code.getIdentifier();
} else {
return null;
}
}
use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.
the class RecordReader method readRecordsById.
default Map<Identifier, Record> readRecordsById() {
try (BaseCloseable closeable = this) {
final Map<Identifier, Record> recordsById = new TreeMap<>(Identifier.comparator());
for (final Record record : this) {
final Identifier identifier = record.getIdentifier();
recordsById.put(identifier, record);
}
return recordsById;
}
}
use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.
the class AbstractRecordQueryField method setFieldValue.
@Override
public boolean setFieldValue(final Object value) {
final Identifier identifier = Identifier.newIdentifier(value);
super.setFieldValue(identifier);
final String displayText = getDisplayText(identifier);
if (this.searchField != null) {
this.searchField.setFieldValue(displayText);
}
this.originalValue = identifier;
Icon icon;
String originalText;
if (value == null) {
originalText = "-";
icon = null;
} else {
originalText = getDisplayText(this.originalValue);
icon = ICON_DELETE;
}
if (this.oldValueItem != null) {
this.oldValueItem.setIcon(icon);
this.oldValueItem.setText(originalText);
}
return true;
}
Aggregations