Search in sources :

Example 1 with ListRecordReader

use of com.revolsys.record.io.ListRecordReader in project com.revolsys.open by revolsys.

the class RecordStore method getRecords.

default RecordReader getRecords(final PathName path) {
    final RecordStoreSchemaElement element = getRootSchema().getElement(path);
    if (element instanceof RecordDefinition) {
        final RecordDefinition recordDefinition = (RecordDefinition) element;
        final Query query = new Query(recordDefinition);
        return getRecords(query);
    } else if (element instanceof RecordStoreSchema) {
        final RecordStoreSchema schema = (RecordStoreSchema) element;
        final List<Query> queries = new ArrayList<>();
        for (final RecordDefinition recordDefinition : schema.getRecordDefinitions()) {
            final Query query = new Query(recordDefinition);
            queries.add(query);
        }
        return getRecords(queries);
    } else {
        return new ListRecordReader(null, Collections.emptyList());
    }
}
Also used : ListRecordReader(com.revolsys.record.io.ListRecordReader) Query(com.revolsys.record.query.Query) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ListRecordReader

use of com.revolsys.record.io.ListRecordReader in project com.revolsys.open by revolsys.

the class AbstractRecordLayer method copyRecordsToClipboard.

public void copyRecordsToClipboard(final List<LayerRecord> records) {
    if (!records.isEmpty()) {
        final RecordDefinition recordDefinition = getRecordDefinition();
        final List<Record> copies = new ArrayList<>();
        for (final LayerRecord record : records) {
            final ArrayRecord recordCopy = new ArrayRecord(recordDefinition, record);
            copies.add(recordCopy);
        }
        final RecordReader reader = new ListRecordReader(recordDefinition, copies);
        final RecordReaderTransferable transferable = new RecordReaderTransferable(reader);
        ClipboardUtil.setContents(transferable);
    }
}
Also used : ListRecordReader(com.revolsys.record.io.ListRecordReader) RecordReaderTransferable(com.revolsys.swing.dnd.transferable.RecordReaderTransferable) ArrayRecord(com.revolsys.record.ArrayRecord) RecordReader(com.revolsys.record.io.RecordReader) ListRecordReader(com.revolsys.record.io.ListRecordReader) ArrayList(java.util.ArrayList) ArrayRecord(com.revolsys.record.ArrayRecord) Record(com.revolsys.record.Record) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 3 with ListRecordReader

use of com.revolsys.record.io.ListRecordReader in project com.revolsys.open by revolsys.

the class RecordHttpMessageConverter method write.

@Override
public void write(final Record record, final MediaType mediaType, final HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
    if (!HttpServletUtils.getResponse().isCommitted()) {
        if (record != null) {
            final RecordDefinition recordDefinition = record.getRecordDefinition();
            final RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
            requestAttributes.setAttribute(IoConstants.SINGLE_OBJECT_PROPERTY, true, RequestAttributes.SCOPE_REQUEST);
            final ListRecordReader reader = new ListRecordReader(recordDefinition, record);
            this.readerConverter.write(reader, mediaType, outputMessage);
        }
    }
}
Also used : ListRecordReader(com.revolsys.record.io.ListRecordReader) RequestAttributes(org.springframework.web.context.request.RequestAttributes) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

ListRecordReader (com.revolsys.record.io.ListRecordReader)3 RecordDefinition (com.revolsys.record.schema.RecordDefinition)2 ArrayList (java.util.ArrayList)2 ArrayRecord (com.revolsys.record.ArrayRecord)1 Record (com.revolsys.record.Record)1 RecordReader (com.revolsys.record.io.RecordReader)1 Query (com.revolsys.record.query.Query)1 RecordReaderTransferable (com.revolsys.swing.dnd.transferable.RecordReaderTransferable)1 List (java.util.List)1 RequestAttributes (org.springframework.web.context.request.RequestAttributes)1