Search in sources :

Example 51 with Identifier

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;
}
Also used : Identifier(com.revolsys.identifier.Identifier) SingleIdentifier(com.revolsys.identifier.SingleIdentifier)

Example 52 with Identifier

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);
    }
}
Also used : Identifier(com.revolsys.identifier.Identifier) SingleIdentifier(com.revolsys.identifier.SingleIdentifier) ArrayList(java.util.ArrayList) List(java.util.List)

Example 53 with Identifier

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;
    }
}
Also used : Identifier(com.revolsys.identifier.Identifier) SingleIdentifier(com.revolsys.identifier.SingleIdentifier) ListIdentifier(com.revolsys.identifier.ListIdentifier) FieldDefinition(com.revolsys.record.schema.FieldDefinition) Record(com.revolsys.record.Record) Timestamp(java.sql.Timestamp) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 54 with Identifier

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;
    }
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable) Identifier(com.revolsys.identifier.Identifier) Record(com.revolsys.record.Record) ArrayRecord(com.revolsys.record.ArrayRecord) TreeMap(java.util.TreeMap)

Example 55 with Identifier

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;
}
Also used : Identifier(com.revolsys.identifier.Identifier) Icon(javax.swing.Icon)

Aggregations

Identifier (com.revolsys.identifier.Identifier)56 Record (com.revolsys.record.Record)17 ArrayList (java.util.ArrayList)12 RecordDefinition (com.revolsys.record.schema.RecordDefinition)11 SingleIdentifier (com.revolsys.identifier.SingleIdentifier)8 ListIdentifier (com.revolsys.identifier.ListIdentifier)7 TypedIdentifier (com.revolsys.identifier.TypedIdentifier)6 CodeTable (com.revolsys.record.code.CodeTable)6 RecordReader (com.revolsys.record.io.RecordReader)5 RecordStore (com.revolsys.record.schema.RecordStore)5 Transaction (com.revolsys.transaction.Transaction)5 List (java.util.List)5 Geometry (com.revolsys.geometry.model.Geometry)4 BaseCloseable (com.revolsys.io.BaseCloseable)4 PathName (com.revolsys.io.PathName)4 ArrayRecord (com.revolsys.record.ArrayRecord)4 Query (com.revolsys.record.query.Query)4 OsmElement (com.revolsys.record.io.format.openstreetmap.model.OsmElement)3 FieldDefinition (com.revolsys.record.schema.FieldDefinition)3 CompoundCoordinateSystem (com.revolsys.geometry.cs.CompoundCoordinateSystem)2