Java Code Examples for com.smartgwt.client.data.Record#getAttribute()

The following examples show how to use com.smartgwt.client.data.Record#getAttribute() . 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: DigitalObjectDataSource.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates digital object instance from record.
 * @param r record
 * @param checked {@code false} means ignore missing attributes and return {@code null}
 * @return instance of digital object
 */
private static DigitalObject create(Record r, boolean checked) {
    if (r == null) {
        throw new NullPointerException();
    }
    DigitalObject dobj = (DigitalObject) r.getAttributeAsObject(FIELD_INSTANCE);
    if (dobj != null) {
        return dobj;
    }


    Long workflowJobId = r.getAttributeAsLong(WorkflowModelConsts.JOB_ID);
    String pid = getAttribute(r, FIELD_PID, checked && workflowJobId == null);

    String modelId = getAttribute(r, FIELD_MODEL, checked);
    if ((pid == null && workflowJobId == null) || modelId == null) {
        return null;
    }
    String batchId = r.getAttribute(ModsCustomDataSource.FIELD_BATCHID);
    MetaModelRecord model = MetaModelDataSource.getModel(r);
    return new DigitalObject(pid, batchId, modelId, model, workflowJobId, r);
}
 
Example 2
Source File: ImportParentChooser.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private void setSelection(Record parentRecord) {
    this.parentRecord = parentRecord;
    if (parentRecord == null) {
        selection.setContents(i18n.ImportParentChooser_EmptySelection_Msg());
        return ;
    }
    String model = parentRecord.getAttribute(SearchDataSource.FIELD_MODEL);
    if (models != null) {
        Object obj = models.get(model);
        if (obj != null) {
            model = String.valueOf(obj);
        }
    }
    selection.setContents(ClientUtils.format("%s: <b>%s</b>, %s",
            model,
            parentRecord.getAttribute(SearchDataSource.FIELD_LABEL),
            parentRecord.getAttribute(SearchDataSource.FIELD_PID)
            ));
}
 
Example 3
Source File: DigitalObjectCopyMetadataAction.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
public static void removeSelection(Record[] removePids) {
    if (SELECTION != null) {
        ArrayList<Record> newSelection = null;
        for (Record selectionRecord : SELECTION) {
            String selectionPid = selectionRecord.getAttribute(DigitalObjectDataSource.FIELD_PID);
            boolean remove = false;
            for (Record removeRecord : removePids) {
                String removePid = removeRecord.getAttribute(DigitalObjectDataSource.FIELD_PID);
                if (selectionPid.equals(removePid)) {
                    remove = true;
                    break;
                }
            }
            if (!remove) {
                if (newSelection == null) {
                    newSelection = new ArrayList<Record>(SELECTION.length);
                }
                newSelection.add(selectionRecord);
            }
        }
        if (newSelection != null) {
            SELECTION = newSelection.toArray(new Record[newSelection.size()]);
        }
    }
}
 
Example 4
Source File: WorkflowJobView.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private void fetchAddSubjobMenu(Record job) {
    if (job == null
            || job.getAttribute(WorkflowJobDataSource.FIELD_PARENTID) != null
            || !Job.State.OPEN.name().equals(job.getAttribute(WorkflowJobDataSource.FIELD_STATE))
            ) {
        addSubjobButton.setVisible(false);
        return ;
    }
    String jobName = job.getAttribute(WorkflowJobDataSource.FIELD_PROFILE_ID);
    if (jobName == null) {
        return ;
    }
    WorkflowProfileDataSource.getInstance().getSubjobs(false, jobName, (subjobs) -> {
        Menu menu = createSubjobMenu(subjobs);
        addSubjobButton.setVisible(menu != null);
        addSubjobButton.setMenu(menu);
    });
}
 
Example 5
Source File: ImportTreeDataSource.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
@Override
    protected void transformResponse(DSResponse response, DSRequest request, Object data) {
        if (RestConfig.isStatusOk(response)) {
            for (Record record : response.getData()) {
                String path = record.getAttribute(FIELD_PATH);
                RegExp pathRegExp = RegExp.compile("(.*/)?(.*)/$");
                MatchResult mr = pathRegExp.exec(path);
                String parent = mr.getGroup(1);
                String name = mr.getGroup(2);
//                System.out.println("## ITRDS.path: " + path);
//                System.out.println("## ITRDS.parent: " + parent);
//                System.out.println("## ITRDS.name: " + name);

                record.setAttribute(FIELD_NAME, name);
                record.setAttribute(FIELD_PARENT, parent);
            }
        }
        super.transformResponse(response, request, data);
    }
 
Example 6
Source File: ImportBatchItemDataSource.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void transformResponse(DSResponse response, DSRequest request, Object data) {
    super.transformResponse(response, request, data);
    if (RestConfig.isStatusOk(response)) {
        for (Record record : response.getData()) {
            String pid = record.getAttribute(FIELD_PID);
            String batchId = record.getAttribute(FIELD_BATCHID);

            String imgParams = ClientUtils.format("%s=%s&%s=%s",
                    FIELD_PID, pid, FIELD_BATCHID, batchId);
            record.setAttribute(FIELD_PREVIEW, imgParams);
            record.setAttribute(FIELD_THUMBNAIL, imgParams);
        }
    } else {
        // In case of any error DataSource invokes further fetches in never ending loop
        // Following seems to help.
        response.setEndRow(0);
        response.setTotalRows(0);
    }
}
 
Example 7
Source File: ImportParentChooser.java    From proarc with GNU General Public License v3.0 6 votes vote down vote up
private void onParentSelection(final Record selection) {
    String parentOwner = selection.getAttribute(SearchDataSource.FIELD_OWNER);
    String username = Editor.getInstance().getUser().getAttribute(UserDataSource.FIELD_USERNAME);
    if (parentOwnerCheck && !username.equals(parentOwner)) {
        SC.ask(i18n.ImportParentChooser_SelectAction_ParentOwnerCheck_Msg(),
                new BooleanCallback() {

            @Override
            public void execute(Boolean value) {
                if (value != null && value) {
                    setParentSelection(selection);
                }
            }
        });
    } else {
        setParentSelection(selection);
    }
}
 
Example 8
Source File: LocalizationDataSource.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
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 9
Source File: WorkflowTaskFormView.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private void setOptions(FormItem item, Record profile) {
    String dataSourceId = profile.getAttribute(WorkflowModelConsts.PARAMETER_VALUEMAPID);
    if (dataSourceId != null) {
        DataSource ds = ValueMapDataSource.getInstance().getOptionDataSource(dataSourceId);
        item.setValueField(profile.getAttribute(WorkflowModelConsts.PARAMETER_OPTION_VALUE_FIELD));
        item.setOptionDataSource(ds);
        item.setDisplayField(profile.getAttribute(WorkflowModelConsts.PARAMETER_OPTION_DISPLAY_FIELD));
    }
}
 
Example 10
Source File: ImportParentChooser.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see #getSelectedParent
 */
public String getSelectedParentPid() {
    Record selectedParent = getSelectedParent();
    return selectedParent == null
            ? null
            : selectedParent.getAttribute(SearchDataSource.FIELD_PID);
}
 
Example 11
Source File: SOSSelectionChangedHandler.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onSelectionChanged(SelectionEvent event) {
	Record record = event.getRecord();
	if (event.getState() && record != null) {
		String serviceURL = record.getAttribute("url");
		parseAndStoreSOSMetadata(serviceURL, record);
		this.controller.performSOSDataRequests(serviceURL);
	}
}
 
Example 12
Source File: KrameriusExportAction.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void performAction(ActionEvent event) {
    Record[] selection = Actions.getSelection(event);
    if (selection != null && selection.length > 0) {
        ArrayList<String> pids = new ArrayList<String>(selection.length);
        for (Record record : selection) {
            String pid = record.getAttribute(SearchDataSource.FIELD_PID);
            if (pid != null) {
                pids.add(pid);
            }
        }
        export(pids);
    }
}
 
Example 13
Source File: WorkflowTaskFormView.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private DynamicForm createParameterForm(Record[] records) {
    if (records == null || records.length == 0) {
        return createDefaultParameterForm();
    }
    DynamicForm df = new DynamicForm();
    df.setUseFlatFields(true);
    df.setWrapItemTitles(false);
    df.setTitleOrientation(TitleOrientation.TOP);
    df.setNumCols(3);
    df.setColWidths("*", "*", "*");
    df.setItemHoverWidth(300);
    FormItem[] items = new FormItem[records.length];
    Record values = new Record();
    for (int i = 0; i < records.length; i++) {
        Record record = records[i];
        ValueType valueType = ValueType.fromString(
                record.getAttribute(WorkflowModelConsts.PARAMETER_VALUETYPE));
        DisplayType displayType = DisplayType.fromString(
                record.getAttribute(WorkflowModelConsts.PARAMETER_DISPLAYTYPE));
        displayType = valueType == ValueType.DATETIME ? DisplayType.DATETIME : displayType;

        String paramName = record.getAttribute(WorkflowParameterDataSource.FIELD_NAME);
        String fieldName = "f" + i;
        items[i] = createFormItem(record, valueType, displayType);
        items[i].setName(fieldName);
        // use dataPath to solve cases where the valid JSON name is not a valid javascript ID (param.id).
        items[i].setDataPath("/" + paramName);
        items[i].setTitle(record.getAttribute(WorkflowModelConsts.PARAMETER_PROFILELABEL));
        items[i].setTooltip(record.getAttribute(WorkflowModelConsts.PARAMETER_PROFILEHINT));
        Object val = getParameterValue(record, valueType, displayType);
        if (val != null) {
            values.setAttribute(paramName, val);
        }
    }
    df.setItems(items);
    df.editRecord(values);
    df.addItemChangedHandler(itemChangedHandler);
    return df;
}
 
Example 14
Source File: WorkflowTaskFormView.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void refresh() {
    Record task = taskForm.getValuesAsRecord();
    if (task.getAttribute(WorkflowTaskDataSource.FIELD_ID) != null) {
        setTask(task);
    }
}
 
Example 15
Source File: ModsBatchEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private void copyAttribute(boolean enabled, Record src, Record dst, String attrName) {
    if (enabled) {
        String value = src.getAttribute(attrName);
        if (value != null) {
            dst.setAttribute(attrName, value);
        }
    }
}
 
Example 16
Source File: WorkflowJobView.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private void fetchModelMenu(Record job) {
    if (job == null
            // not subjob
            || job.getAttribute(WorkflowJobDataSource.FIELD_PARENTID) != null
            || !Job.State.OPEN.name().equals(job.getAttribute(WorkflowJobDataSource.FIELD_STATE))
            ) {
        createNewObjectButton.setVisible(false);
        return;
    }
    String jobName = job.getAttribute(WorkflowJobDataSource.FIELD_PROFILE_ID);
    Long jobId = job.getAttributeAsLong(WorkflowJobDataSource.FIELD_ID);

    if (jobName == null) {
        return;
    }

    Criteria criteria = new Criteria();
    criteria.setAttribute(WorkflowMaterialDataSource.FIELD_JOB_ID, jobId);
    criteria.setAttribute(WorkflowMaterialDataSource.FIELD_TYPE, MaterialType.DIGITAL_OBJECT.name());
    WorkflowMaterialDataSource.getInstance().fetchData(criteria, (dsResponse, o, dsRequest) -> {
        RecordList records = dsResponse.getDataAsRecordList();
        if (records.getLength() == 1 && records.get(0)
                .getAttribute(WorkflowMaterialDataSource.FIELD_DIGITAL_PID) == null) {
            createNewObjectButton.enable();
        } else {
            createNewObjectButton.disable();
        }
    });


    WorkflowProfileDataSource.getInstance().getModels(false, jobName, (models) -> {
        Menu menu = new Menu();

        for (Record model : models) {
            MenuItem menuItem = new MenuItem(model.getAttribute(WorkflowProfileConsts.MODEL_TITLE));
            menu.addItem(menuItem);

            menuItem.addClickHandler(event -> {
                saveNewDigitalObject(model.getAttributeAsString(WorkflowProfileConsts.MODEL_NAME), jobId);
                createNewObjectButton.disable();
                actionSource.fireEvent();
                jobFormView.refreshState();
                jobFormView.refresh();
            });

        }

        createNewObjectButton.setVisible(models.length > 0);
        createNewObjectButton.setMenu(menu);
    });
}
 
Example 17
Source File: GridUtil.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
static public GUIDocument toDocument(Record record) {
	GUIDocument document = null;
	if (record != null) {
		document = new GUIDocument();
		document.setId(record.getAttributeAsLong("id"));
		if (record.getAttribute("docref") != null) {
			document.setDocRef(Long.parseLong(record.getAttribute("docref")));
			document.setDocRefType(record.getAttribute("docrefType"));
		}
		document.setExtResId(record.getAttributeAsString("extResId"));
		document.setCustomId(record.getAttributeAsString("customId"));
		document.setType(record.getAttribute("type"));
		document.setFileName(record.getAttribute("filename"));
		document.setTemplate(record.getAttribute("template"));
		document.setVersion(record.getAttribute("version"));
		document.setFileVersion(record.getAttribute("fileVersion"));
		document.setLanguage(record.getAttribute("language"));

		document.setPublisher(record.getAttributeAsString("publisher"));

		if (record.getAttributeAsFloat("size") != null)
			document.setFileSize(record.getAttributeAsFloat("size"));

		if (record.getAttributeAsInt("indexed") != null)
			document.setIndexed(record.getAttributeAsInt("indexed"));

		if (record.getAttributeAsInt("status") != null)
			document.setStatus(record.getAttributeAsInt("status"));

		if (record.getAttributeAsInt("immutable") != null)
			document.setImmutable(record.getAttributeAsInt("immutable"));

		if (record.getAttributeAsInt("password") != null)
			document.setPasswordProtected(record.getAttributeAsBoolean("password"));

		if (record.getAttributeAsInt("signed") != null)
			document.setSigned(record.getAttributeAsInt("signed"));

		if (record.getAttributeAsInt("stamped") != null)
			document.setStamped(record.getAttributeAsInt("stamped"));

		if (record.getAttributeAsInt("bookmarked") != null)
			document.setBookmarked(record.getAttributeAsBoolean("bookmarked"));

		if (record.getAttribute("lockUserId") != null)
			document.setLockUserId(record.getAttributeAsLong("lockUserId"));

		if (record.getAttribute("lockUser") != null)
			document.setLockUser(record.getAttribute("lockUser"));

		if (record.getAttribute("docref") != null) {
			document.setDocRef(Long.parseLong(record.getAttribute("docref")));
			document.setDocRefType(record.getAttribute("docrefType"));
		}

		if (record.getAttributeAsInt("workflowStatus") != null)
			document.setWorkflowStatus(record.getAttributeAsString("workflowStatus"));

		if (record.getAttributeAsString("workflowStatusDisplay") != null)
			document.setWorkflowStatusDisplay(record.getAttributeAsString("workflowStatusDisplay"));

		document.setIcon(record.getAttribute("icon"));
		if (record.getAttributeAsDate("lastModified") != null)
			document.setLastModified(record.getAttributeAsDate("lastModified"));
		if (record.getAttributeAsDate("published") != null)
			document.setDate(record.getAttributeAsDate("published"));
		if (record.getAttributeAsDate("created") != null)
			document.setCreation(record.getAttributeAsDate("created"));

		GUIFolder folder = new GUIFolder();
		if ("folder".equals(document.getType())) {
			folder.setId(Long.parseLong(record.getAttributeAsString("id")));
		} else if (record.getAttributeAsLong("folderId") != null)
			folder.setId(record.getAttributeAsLong("folderId"));
		else
			folder.setId(Session.get().getCurrentFolder().getId());
		folder.setName(record.getAttribute("filename"));
		folder.setDescription(record.getAttribute("comment"));

		document.setFolder(folder);
	}
	return document;
}
 
Example 18
Source File: ImportParentChooser.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private static String asPid(Record r) {
    return r == null ? null : r.getAttribute(RelationDataSource.FIELD_PID);
}
 
Example 19
Source File: SOSSelectionChangedHandler.java    From SensorWebClient with GNU General Public License v2.0 4 votes vote down vote up
private String getValueFor(Record record, String parameter) {
    String value = record.getAttribute(parameter);
       return value == null || value.isEmpty() ? null: value;
}
 
Example 20
Source File: FoxmlViewAction.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
public void view(Record selection) {
    String pid = selection.getAttribute(ImportBatchItemDataSource.FIELD_PID);
    String batchId = selection.getAttribute(ImportBatchItemDataSource.FIELD_BATCHID);
    view(pid, batchId);
}