-
Notifications
You must be signed in to change notification settings - Fork 9
Introduce a subclass of DomainProps for Datasets #2483
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
131 changes: 131 additions & 0 deletions
131
src/org/labkey/test/params/study/DatasetDefinition.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package org.labkey.test.params.study; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.labkey.remoteapi.domain.Domain; | ||
import org.labkey.remoteapi.domain.PropertyDescriptor; | ||
import org.labkey.test.params.property.DomainProps; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class DatasetDefinition extends DomainProps | ||
{ | ||
private String _name; | ||
private String _description; | ||
private List<PropertyDescriptor> _fields = new ArrayList<>(); | ||
private String _kindName; | ||
private Boolean _demographics; | ||
private Boolean _managedKeyField; | ||
private String _keyPropertyName; | ||
private Boolean _timeKeyField; | ||
|
||
public static final String VISIT_BASED_STUDY = "StudyDatasetVisit"; | ||
public static final String DATE_BASED_STUDY = "StudyDatasetDate"; | ||
|
||
public static DatasetDefinition create(String name) | ||
{ | ||
return new DatasetDefinition(name); | ||
} | ||
|
||
public DatasetDefinition(String name) | ||
{ | ||
this(name, VISIT_BASED_STUDY); | ||
} | ||
|
||
public DatasetDefinition(String name, String kindName) | ||
{ | ||
_name = name; | ||
_kindName = kindName; | ||
} | ||
|
||
public DatasetDefinition setDescription(String description) | ||
{ | ||
_description = description; | ||
return this; | ||
} | ||
|
||
public DatasetDefinition setFields(List<PropertyDescriptor> fields) | ||
{ | ||
_fields = fields; | ||
return this; | ||
} | ||
|
||
public DatasetDefinition setKindName(String kindName) | ||
{ | ||
_kindName = kindName; | ||
return this; | ||
} | ||
|
||
public DatasetDefinition setDemographics(Boolean demographics) | ||
{ | ||
_demographics = demographics; | ||
return this; | ||
} | ||
|
||
public DatasetDefinition setKeyPropertyName(String keyPropertyName) | ||
{ | ||
_keyPropertyName = keyPropertyName; | ||
return this; | ||
} | ||
|
||
public DatasetDefinition setKeyPropertyName(String keyPropertyName, Boolean managedKeyField) | ||
{ | ||
_keyPropertyName = keyPropertyName; | ||
_managedKeyField = managedKeyField; | ||
return this; | ||
} | ||
|
||
public DatasetDefinition setTimeKeyField(Boolean timeKeyField) | ||
{ | ||
_timeKeyField = timeKeyField; | ||
return this; | ||
} | ||
|
||
@Override | ||
protected @NotNull Domain getDomainDesign() | ||
{ | ||
Domain domain = new Domain(_name); | ||
|
||
domain.setDescription(_description); | ||
domain.setFields(_fields); | ||
|
||
return domain; | ||
} | ||
|
||
@Override | ||
protected @NotNull String getKind() | ||
{ | ||
return _kindName; | ||
} | ||
|
||
@Override | ||
protected @NotNull Map<String, Object> getOptions() | ||
{ | ||
Map<String, Object> options = new HashMap<>(); | ||
|
||
if (_demographics != null) | ||
options.put("demographics", _demographics); | ||
if (_keyPropertyName != null) | ||
options.put("keyPropertyName", _keyPropertyName); | ||
if (_managedKeyField != null) | ||
options.put("keyPropertyManaged", _managedKeyField); | ||
if (_timeKeyField != null) | ||
options.put("useTimeKeyField", _timeKeyField); | ||
|
||
return options; | ||
} | ||
|
||
@Override | ||
protected @NotNull String getSchemaName() | ||
{ | ||
return "study"; | ||
} | ||
|
||
@Override | ||
protected @NotNull String getQueryName() | ||
{ | ||
return _name; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This static
create
method is a little confusing becauseDomainProps
has a non-staticcreate
method that actually creates the domain.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's true, I was thinking of maybe
init
, not sure if there is a better verb.