com.smartgwt.client.data.Record Java Examples
The following examples show how to use
com.smartgwt.client.data.Record.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorkflowMaterialDataSource.java From proarc with GNU General Public License v3.0 | 6 votes |
@Override protected void transformResponse(DSResponse dsResponse, DSRequest dsRequest, Object data) { if (RestConfig.isStatusOk(dsResponse)) { Record[] records = dsResponse.getData(); for (Record record : records) { String mid = record.getAttribute(FIELD_ID); String way = record.getAttribute(FIELD_WAY); String pk = mid; if (way != null) { pk = mid + way; } record.setAttribute(PRIMARY_KEY, pk); } // #509: do not use the data object as it breaks super.transformResponse data = null; } super.transformResponse(dsResponse, dsRequest, data); }
Example #2
Source File: NdkExportAction.java From proarc with GNU General Public License v3.0 | 6 votes |
protected void exportOrValidate(final Record export) { DSRequest dsRequest = new DSRequest(); //dsRequest.setPromptStyle(PromptStyle.DIALOG); //dsRequest.setPrompt(i18n.KrameriusExportAction_Add_Msg()); dsRequest.setShowPrompt(false); DataSource ds = ExportDataSource.getNdk(); dsAddData(ds, export, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { if (RestConfig.isStatusOk(response)) { Record[] data = response.getData(); RecordList erl = errorsFromExportResult(data); if (erl.isEmpty()) { String dryRun = export.getAttribute(ExportResourceApi.DESA_DRYRUN_PARAM); SC.say(dryRun == null ? i18n.NdkExportAction_ExportDone_Msg() : i18n.DesaExportAction_ValidationDone_Msg()); } else { ExportResultWidget.showErrors(erl.toArray()); } } } }, dsRequest); }
Example #3
Source File: ChangeClippingsVolumeToNdkMonographVolumeAction.java From proarc with GNU General Public License v3.0 | 6 votes |
private boolean acceptModel(Record[] records) { boolean accept = false; for (Record record : records) { DigitalObjectDataSource.DigitalObject dobj = DigitalObjectDataSource.DigitalObject.createOrNull(record); if (dobj != null) { String modelId = dobj.getModelId(); if (modelId != null && CollectionOfClippingsPlugin.MODEL_COLLECTION_OF_CLIPPINGS_VOLUME.equals(modelId) || CollectionOfClippingsPlugin.MODEL_COLLECTION_OF_CLIPPINGS_TITLE.equals(modelId)) { accept = true; continue; } } accept = false; break; } return accept; }
Example #4
Source File: Options.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
/** * Sends the options in the grid to the server to save them. */ private void onSave() { Record[] records = list.getRecords(); String[] values = new String[records.length]; int i = 0; for (Record record : records) values[i++] = record.getAttributeAsString("value"); ContactingServer.get().show(); AttributeSetService.Instance.get().saveOptions(setId, attribute, values, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { ContactingServer.get().hide(); Log.serverError(caught); } @Override public void onSuccess(Void arg0) { ContactingServer.get().hide(); SC.say(I18N.message("optionssaved")); } }); }
Example #5
Source File: DigitalObjectNavigateAction.java From proarc with GNU General Public License v3.0 | 6 votes |
@Override public void performAction(ActionEvent event) { Record[] selectedRecords = Actions.getSelection(event); if (accept(selectedRecords)) { DigitalObject dobj = DigitalObject.create(selectedRecords[0]); String pid = dobj.getPid(); switch (navigation) { case PARENT: openParent(pid); break; case NEXT: case PREV: openSibling(pid, false); break; case CHILD: openChild(pid, getChildSelection(event)); break; } } }
Example #6
Source File: RepeatableFormItem.java From proarc with GNU General Public License v3.0 | 6 votes |
/** * Replace string values of record attributes with types declared by item children. * This is necessary as declarative forms do not use DataSource stuff. * @param record record to scan for attributes * @param item item with possible profile * @return resolved record */ private static Record resolveRecordValues(Record record, FormItem item) { Field f = getProfile(item); if (f != null) { for (Field field : f.getFields()) { String fType = field.getType(); if ("date".equals(fType) || "datetime".equals(fType)) { // parses ISO dateTime to Date; otherwise DateItem cannot recognize the value! Object value = record.getAttributeAsObject(field.getName()); if (!(value instanceof String)) { continue; } String sd = (String) value; // ClientUtils.severe(LOG, "name: %s, is date, %s", field.getName(), sd); // Date d = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).parse("1994-11-05T13:15:30Z"); try { Date d = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).parse(sd); record.setAttribute(field.getName(), d); } catch (IllegalArgumentException ex) { LOG.log(Level.WARNING, sd, ex); } } } } return record; }
Example #7
Source File: DigitalObjectEditor.java From proarc with GNU General Public License v3.0 | 6 votes |
private String checkSearchedRecordsConsistency(Record[] records) { String error = null; HashSet<String> pidSet = new HashSet<String>(Arrays.asList(pids)); for (Record record : records) { String recordPid = record.getAttribute(SearchDataSource.FIELD_PID); if (!pidSet.remove(recordPid)) { error = ClientUtils.format("PID %s not requested!", recordPid); break; } else if (SearchDataSource.isDeleted(record)) { error = ClientUtils.format("PID %s is deleted!", recordPid); break; } } if (error == null && !pidSet.isEmpty()) { error = ClientUtils.format("PID %s not found!", pidSet.toString()); } return error; }
Example #8
Source File: DigitalObjectCopyMetadataAction.java From proarc with GNU General Public License v3.0 | 6 votes |
public boolean accept(Record[] records) { if (records == null || records.length == 0) { return false; } for (Record record : records) { DigitalObject dobj = DigitalObject.createOrNull(record); if (dobj != null) { String modelId = dobj.getModelId(); if (NdkPlugin.MODEL_PAGE.equals(modelId) || NdkPlugin.MODEL_NDK_PAGE.equals(modelId) || OldPrintPlugin.MODEL_PAGE.equals(modelId)) { continue; } } return false; } return true; }
Example #9
Source File: WorkflowTasksView.java From proarc with GNU General Public License v3.0 | 6 votes |
public void edit(String taskId) { if (taskId == null) { init(); return ; } int taskRec = taskGrid.findIndex( new AdvancedCriteria(WorkflowTaskDataSource.FIELD_ID, OperatorId.EQUALS, taskId)); if (taskRec >= 0) { taskGrid.selectSingleRecord(taskRec); taskGrid.scrollToRow(taskRec); } else { lastSelection = null; taskGrid.deselectAllRecords(); Record r = new Record(); r.setAttribute(WorkflowTaskDataSource.FIELD_ID, taskId); taskFormView.setTask(r); } }
Example #10
Source File: DesaExportAction.java From proarc with GNU General Public License v3.0 | 6 votes |
private void exportOrValidate(final Record export) { DSRequest dsRequest = new DSRequest(); dsRequest.setPromptStyle(PromptStyle.DIALOG); dsRequest.setPrompt(i18n.KrameriusExportAction_Add_Msg()); DataSource ds = ExportDataSource.getDesa(); dsAddData(ds, export, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { if (RestConfig.isStatusOk(response)) { Record[] data = response.getData(); RecordList erl = errorsFromExportResult(data); if (erl.isEmpty()) { String dryRun = export.getAttribute(ExportResourceApi.DESA_DRYRUN_PARAM); SC.say(dryRun == null ? i18n.DesaExportAction_ExportDone_Msg() : i18n.DesaExportAction_ValidationDone_Msg()); } else { ExportResultWidget.showErrors(erl.toArray()); } } } }, dsRequest); }
Example #11
Source File: DesaExportAction.java From proarc with GNU General Public License v3.0 | 6 votes |
private boolean acceptDesa(Record[] records) { boolean accept = false; for (Record record : records) { DigitalObject dobj = DigitalObject.createOrNull(record); if (dobj != null) { // MetaModelRecord model = dobj.getModel(); // String metadataFormat = model.getMetadataFormat(); String modelId = dobj.getModelId(); // XXX hack; it needs support to query model/object for action availability if (MODELS.contains(modelId)) { accept = true; continue; } } accept = false; break; } return accept; }
Example #12
Source File: ImportPresenter.java From proarc with GNU General Public License v3.0 | 6 votes |
private void loadBatch(final String batchId, final Runnable callback) { Criteria criteria = new Criteria(ImportBatchDataSource.FIELD_ID, batchId); ImportBatchDataSource.getInstance().fetchData(criteria, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { BatchRecord batchRecord = null; if (RestConfig.isStatusOk(response)) { Record[] records = response.getData(); if (records.length > 0) { batchRecord = new BatchRecord(records[0]); } else { SC.warn("Batch not found! " + batchId); } } getImportContext().setBatch(batchRecord); callback.run(); } }); }
Example #13
Source File: WorkflowNewJobView.java From proarc with GNU General Public License v3.0 | 6 votes |
private void fireOnCreateNew(Record model) { if (handler != null) { String mods = catalogBrowser.getMods(); optionForm.setValue(WorkflowResourceApi.NEWJOB_METADATA, mods); optionForm.getField(WorkflowResourceApi.NEWJOB_METADATA).setVisible(mods == null); optionForm.setValue(WorkflowResourceApi.NEWJOB_CATALOGID, catalogBrowser.getCatalogId()); // rdcz is available only in rd search if (catalogBrowser.getRdczId() != null) { optionForm.setValue(WorkflowResourceApi.NEWJOB_RDCZID, catalogBrowser.getRdczId()); } boolean valid = optionForm.validate(); if (valid) { handler.onCreateNew(model.getAttributeAsString("name"), optionForm.getValuesAsRecord()); } } }
Example #14
Source File: DeviceManager.java From proarc with GNU General Public License v3.0 | 6 votes |
private void addDevice(String model) { addingDevice = true; Record record = new Record(); record.setAttribute(DeviceDataSource.FIELD_MODEL, model); deviceList.addData(record, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { addingDevice = false; if (RestConfig.isStatusOk(response)) { StatusView.getInstance().show(i18n.SaveAction_Done_Msg()); Record r = response.getData()[0]; deviceList.selectSingleRecord(r); } } }); }
Example #15
Source File: DeviceManager.java From proarc with GNU General Public License v3.0 | 6 votes |
private void saveImpl(final BooleanCallback callback) { Record update = new Record(valuesManager.getValues()); update = ClientUtils.normalizeData(update); updatingDevice = true; DeviceDataSource.getInstance().updateData(update, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { updatingDevice = false; boolean status = RestConfig.isStatusOk(response); if (status) { StatusView.getInstance().show(i18n.SaveAction_Done_Msg()); Record[] data = response.getData(); if (data != null && data.length == 1) { Record deviceRecord = data[0]; setDescription(deviceRecord); } } callback.execute(status); } }); }
Example #16
Source File: DesaExportAction.java From proarc with GNU General Public License v3.0 | 6 votes |
private void download(final String[] pids) { Record export = new Record(); export.setAttribute(ExportResourceApi.DESA_PID_PARAM, pids[0]); export.setAttribute(ExportResourceApi.DESA_FORDOWNLOAD_PARAM, true); DSRequest dsRequest = new DSRequest(); //dsRequest.setPromptStyle(PromptStyle.DIALOG); //dsRequest.setPrompt(i18n.KrameriusExportAction_Add_Msg()); dsRequest.setShowPrompt(false); DataSource ds = ExportDataSource.getDesa(); dsAddData(ds, export, new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { if (RestConfig.isStatusOk(response)) { Record[] data = response.getData(); Record[] errors = data[0].getAttributeAsRecordArray(ExportResourceApi.RESULT_ERRORS); if (errors != null && errors.length > 0) { ExportResultWidget.showErrors(errors); } else { String token = data[0].getAttribute(ExportResourceApi.RESULT_TOKEN); openResult(pids[0], token); } } } }, dsRequest); }
Example #17
Source File: CrossrefExportAction.java From proarc with GNU General Public License v3.0 | 6 votes |
private void askForExportOptions(String[] pids) { if (pids == null || pids.length == 0) { return ; } Record export = new Record(); export.setAttribute(ExportResourceApi.CROSSREF_PID_PARAM, pids); // ExportOptionsWidget.showOptions(export, new Callback<Record, Void>() { // // @Override // public void onFailure(Void reason) { // // no-op // } // // @Override // public void onSuccess(Record result) { // exportOrValidate(result); // } // }); exportOrValidate(export); }
Example #18
Source File: ModsCustomDataSource.java From proarc with GNU General Public License v3.0 | 6 votes |
public void saveXmlDescription(DigitalObject dobj, String xml, long timestamp, DescriptionSaveHandler callback, Boolean ignoreValidation) { Record update = new Record(); dobj.toCriteria(); update.setAttribute(FIELD_PID, dobj.getPid()); if (ignoreValidation != null && ignoreValidation) { update.setAttribute(DigitalObjectResourceApi.MODS_CUSTOM_IGNOREVALIDATION, true); } if (dobj.getBatchId() != null) { update.setAttribute(FIELD_BATCHID, dobj.getBatchId()); } if (xml == null || xml.isEmpty()) { return ; } update.setAttribute(DigitalObjectResourceApi.MODS_CUSTOM_CUSTOMXMLDATA, xml); // timestamp -1 stands for rewrite without concurrency check update.setAttribute(FIELD_TIMESTAMP, timestamp); update.setAttribute(FIELD_EDITOR, dobj.getModel().getEditorId()); callback.setUpdateRecord(update); updateData(update, callback, callback.getUpdateRequest()); }
Example #19
Source File: Editor.java From proarc with GNU General Public License v3.0 | 6 votes |
private Canvas createLangMenu() { String activeLocale = LanguagesDataSource.activeLocale(); IconMenuButton langMenuButton = Actions.asIconMenuButton(Actions.emptyAction(activeLocale, null, null), this); langMenuButton.setCanFocus(Boolean.FALSE); Menu m = new Menu(); m.setShowShadow(Boolean.TRUE); m.addItem(createLangItem("cs", "Česky", activeLocale)); m.addItem(createLangItem("en", "English", activeLocale)); langMenuButton.setMenu(m); m.addItemClickHandler(new ItemClickHandler() { @Override public void onItemClick(ItemClickEvent event) { MenuItem item = event.getItem(); if (!Boolean.TRUE.equals(item.getChecked())) { switchLocale(item.getAttribute(LOCALE_ATTRIBUTE)); } } }); Record rec = m.getDataAsRecordList().find(LOCALE_ATTRIBUTE, activeLocale); langMenuButton.setTitle(rec.getAttribute("title")); return langMenuButton; }
Example #20
Source File: CopyObjectAction.java From proarc with GNU General Public License v3.0 | 6 votes |
@Override public void performAction(ActionEvent event) { Record[] records = Actions.getSelection(event); String modelId = ""; String pidOld = ""; Record record = new Record(); for (Record recordLocal : records){ DigitalObject dobj = DigitalObject.createOrNull(recordLocal); if (dobj != null) { modelId = dobj.getModelId(); pidOld = dobj.getPid(); record = recordLocal; continue; } } register(pidOld, pidOld, modelId, record); }
Example #21
Source File: DigitalObjectFormValidateAction.java From proarc with GNU General Public License v3.0 | 5 votes |
private void consumeValidation(Record r, boolean valid) { if (valid) { validatable.clearErrors(r); } else { ++invalidItemsCount; validatable.setErrors(r, i18n.DigitalObjectFormValidateAction_ListRowError_Hint()); } }
Example #22
Source File: ModsCustomEditor.java From proarc with GNU General Public License v3.0 | 5 votes |
private void handleFetch(DSResponse response, DynamicForm editor, BooleanCallback loadCallback) { if (RestConfig.isStatusOk(response)) { Record[] data = response.getData(); if (LOG.isLoggable(Level.FINE)) { ClientUtils.fine(LOG, "fetch custom data: %s", ClientUtils.dump(data)); } if (data != null && data.length == 1) { Record customRecord = data[0]; DescriptionMetadata dm = new DescriptionMetadata(customRecord); Record customModsRecord = dm.getDescription(); if (customModsRecord != null) { metadata = dm; editor.editRecord(customModsRecord); editor.clearErrors(true); loadCallback.execute(Boolean.TRUE); fireEvent(new EditorLoadEvent(false)); return ; } } else { String msg = data != null && data.length > 1 ? "Unexpected data in server response!" : "No data in server response!"; SC.warn(msg); } } widget.setMembers(); loadCallback.execute(Boolean.FALSE); fireEvent(new EditorLoadEvent(true)); }
Example #23
Source File: UrnNbnAction.java From proarc with GNU General Public License v3.0 | 5 votes |
/** * Shows errors in the shared window instance. * @param result array of errors */ public static void showErrors(Record[] result) { if (INSTANCE == null) { INSTANCE = new ExportResultWidget(); } INSTANCE.showWindow(result); }
Example #24
Source File: ConverterAssociationsDialog.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
protected void onApply() { for (Record rec : associationsGrid.getRecordList().toArray()) { if (rec.getAttributeAsBoolean("selected")) { String id = rec.getAttributeAsString("id").trim(); String selectedConverter = converter.getValueAsString(); Record record = srcGrid.find(new AdvancedCriteria("id", OperatorId.EQUALS, id)); if (record != null) { record.setAttribute("converter", selectedConverter); srcGrid.updateData(record); } } } destroy(); }
Example #25
Source File: DigitalObjectChildrenEditor.java From proarc with GNU General Public License v3.0 | 5 votes |
@Override public void edit(DigitalObject digitalObject) { this.digitalObject = digitalObject; if (digitalObject == null) { return ; } detachListFromEditor(); detachListResultSet(); String pid = digitalObject.getPid(); Criteria criteria = new Criteria(RelationDataSource.FIELD_ROOT, pid); criteria.addCriteria(RelationDataSource.FIELD_PARENT, pid); DigitalObjectCopyMetadataAction.resetSelection(); ResultSet resultSet = childrenListGrid.getResultSet(); if (resultSet != null) { Boolean willFetchData = resultSet.willFetchData(criteria); // init editor for cached record when DataArrivedHandler is not called if (!willFetchData) { showCopySelection(new Record[0]); initOnEdit(); } } // use DataArrivedHandler instead of callback as it is not called // for refresh in SmartGWT 3.0 childrenListGrid.fetchData(criteria); MetaModelDataSource.getModels(false, new Callback<ResultSet, Void>() { @Override public void onFailure(Void reason) { } @Override public void onSuccess(ResultSet result) { Map<?,?> valueMap = result.getValueMap( MetaModelDataSource.FIELD_PID, MetaModelDataSource.FIELD_DISPLAY_NAME); childrenListGrid.getField(RelationDataSource.FIELD_MODEL).setValueMap(valueMap); createAddMenu(result); } }); }
Example #26
Source File: LocalizationDataSource.java From proarc with GNU General Public License v3.0 | 5 votes |
public LinkedHashMap<String, String> asValueMap(BundleName bundleName) { LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(); if (cache != null) { Record[] findAll = cache.findAll(LocalizationResourceApi.ITEM_BUNDLENAME, bundleName.toString()); for (Record record : findAll) { String key = record.getAttribute(LocalizationResourceApi.ITEM_KEY); String value = record.getAttribute(LocalizationResourceApi.ITEM_VALUE); map.put(key, value); } } return map; }
Example #27
Source File: ImportBatchDataSource.java From proarc with GNU General Public License v3.0 | 5 votes |
public Record newBatch(String folderPath, String profile, String device, Boolean indices) { Record r = new Record(); r.setAttribute(FIELD_PATH, folderPath); if (profile != null) { r.setAttribute(FIELD_PROFILE_ID, profile); } if (indices != null) { r.setAttribute(FIELD_INDICES, indices); } if (device != null) { r.setAttribute(FIELD_DEVICE, device); } return r; }
Example #28
Source File: ChronicleExportAction.java From proarc with GNU General Public License v3.0 | 5 votes |
@Override public void performAction(ActionEvent event) { Record[] records = Actions.getSelection(event); String[] pids = ClientUtils.toFieldValues(records, ExportResourceApi.NDK_PID_PARAM); if (pids == null || pids.length == 0) { return ; } Record export = new Record(); export.setAttribute(ExportResourceApi.NDK_PID_PARAM, pids); export.setAttribute(ExportResourceApi.NDK_PACKAGE, ExportResourceApi.Package.CHRONICLE.name()); exportOrValidate(export); }
Example #29
Source File: DigitalObjectEditor.java From proarc with GNU General Public License v3.0 | 5 votes |
private Record[] processRecords() { Record[] records; if (pids != null) { records = searchList.toArray(); String error = checkSearchedRecordsConsistency(records); if (error != null) { SC.warn(error); places.goTo(Place.NOWHERE); return null; } } else { records = digitalObjects; } return records; }
Example #30
Source File: DigitalObjectEditor.java From proarc with GNU General Public License v3.0 | 5 votes |
private DigitalObject findRecentSelection(DigitalObject... objects) { if (objects == null || objects.length == 0 || objects[0] == null) { return null; } else if (objects.length == 1) { return objects[0]; } for (DigitalObject object : objects) { Record record = object.getRecord(); Boolean isLastSelection = record.getAttributeAsBoolean(DigitalObjectChildrenEditor.LAST_CLICKED_ATTR); if (isLastSelection != null && isLastSelection) { return object; } } return null; }