Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helper method for setting required fields (e.g. distributorContact) on a dataset version #761

Closed
pdurbin opened this issue Jul 23, 2014 · 6 comments
Assignees
Milestone

Comments

@pdurbin
Copy link
Member

pdurbin commented Jul 23, 2014

@sekmiller and I just discussed how it would probably be worthwhile to have a helper method to set fields that are required, such as title, authorName, distributorContact, dsDescription, and subject.

That is, I'd love to have something like

newDatasetVersion.setTitle("fooTitle");

rather than...

List<DatasetField> datasetFields = new ArrayList<>();
DatasetField titleDatasetField = new DatasetField();
DatasetFieldType titleDatasetFieldType = datasetFieldService.findByName("title");
titleDatasetField.setDatasetFieldType(titleDatasetFieldType);
List<DatasetFieldValue> datasetFieldValues = new ArrayList<>();
DatasetFieldValue titleDatasetFieldValue = new DatasetFieldValue(titleDatasetField, "fooTitle");
datasetFieldValues.add(titleDatasetFieldValue);
titleDatasetField.setDatasetFieldValues(datasetFieldValues);
datasetFields.add(titleDatasetField);
newDatasetVersion.setDatasetFields(datasetFields);

(which I was doing

)

@pdurbin pdurbin added this to the In Review - Dataverse 4.0 milestone Jul 23, 2014
@scolapasta
Copy link
Contributor

There are already some generic helper methods (and I had updated the sword code to use). @pdurbin do you feel we need more?

@scolapasta scolapasta assigned pdurbin and unassigned sekmiller Jan 6, 2015
@scolapasta scolapasta modified the milestones: Beta 11 - Dataverse 4.0, In Review - Dataverse 4.0 Jan 6, 2015
@pdurbin
Copy link
Member Author

pdurbin commented Jan 7, 2015

I'd love to have something like

newDatasetVersion.setTitle("fooTitle");

We don't have what I wished for above... the code looks more like this...

DatasetFieldType emailDatasetFieldType = datasetFieldService.findByNameOpt(DatasetFieldConstant.datasetContact);
DatasetField emailDatasetField = DatasetField.createNewEmptyDatasetField(emailDatasetFieldType, datasetVersion);
for (DatasetField childField : emailDatasetField.getDatasetFieldCompoundValues().get(0).getChildDatasetFields()) {
    if (DatasetFieldConstant.datasetContactEmail.equals(childField.getDatasetFieldType().getName())) {
        childField.getSingleValue().setValue(user.getDisplayInfo().getEmailAddress());
    }
}
datasetVersion.getDatasetFields().add(emailDatasetField);

... which is better but still a fair amount of code for adding a value, in my opinion. I'll give this back to @scolapasta since he asked me to comment. Do with this ticket what you will. It certainly isn't user-facing. :)

@pdurbin pdurbin assigned scolapasta and unassigned pdurbin Jan 7, 2015
@scolapasta
Copy link
Contributor

OK, we'll consider for later, if we need anything more.

@scolapasta scolapasta modified the milestones: Post 4.0, Beta 11 - Dataverse 4.0 Jan 7, 2015
@scolapasta scolapasta modified the milestones: In Review - Long Term, In Review - Short Term May 8, 2015
@raprasad
Copy link
Contributor

this is cobol:)

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 TITLE PIC X(100) VALUE 'FOOTITLE'.

@eaquigley
Copy link
Contributor

Passing to QA to close (@kcondon) per @scolapasta

@eaquigley eaquigley modified the milestones: 4.2, In Review Aug 24, 2015
@eaquigley eaquigley assigned kcondon and unassigned scolapasta Aug 24, 2015
@kcondon
Copy link
Contributor

kcondon commented Sep 3, 2015

Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants