Skip to content

Commit

Permalink
Configure dropdown in dataset page #4233
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-a-dunlap committed Nov 9, 2017
1 parent 5519cf3 commit 5d26270
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 17 deletions.
57 changes: 43 additions & 14 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public enum DisplayMode {
private boolean removeUnusedTags;

private Boolean hasRsyncScript = false;
private List<ExternalTool> externalTools;
private Map<Long,List<ExternalTool>> externalTools = new HashMap<Long,List<ExternalTool>>(); //<List<ExternalTool>>

public Boolean isHasRsyncScript() {
return hasRsyncScript;
Expand Down Expand Up @@ -1532,17 +1532,8 @@ private String init(boolean initFull) {
//I need to generate a list of lists of external tools, one for each file. I don't understand how this data will be consumed in fileFragments...
//In the jsf it looks like I can reference #{fileMetadata.dataFile.id} and the like... so as long as I can create a list that can be referenced?
//Alternatively, maybe this info should be in the fileMetadata?

User user = session.getUser();
ApiToken apitoken = new ApiToken();
if (user instanceof AuthenticatedUser) {
apitoken = authService.findApiTokenByUser((AuthenticatedUser) user);
}

//for(FileMetadata mData : fileMetadatasSearch)
//{
externalTools = externalToolService.findAll(null, apitoken);
//}

generateExternalTools();



Expand Down Expand Up @@ -4096,9 +4087,47 @@ public List<DatasetField> getDatasetSummaryFields() {
return DatasetUtil.getDatasetSummaryFields(workingVersion, customFields);
}

//MAD: probably not the right way to do this
private void generateExternalTools() {
User user = session.getUser(); //redundant?
ApiToken apitoken = new ApiToken();
if (user instanceof AuthenticatedUser) {
apitoken = authService.findApiTokenByUser((AuthenticatedUser) user);
}

//List<List<ExternalTool>> dsTools = new ArrayList();//not convinced this structure will be processed in the correct order by jsf or that I've put things in the right place on that side

for (FileMetadata fm : fileMetadatasSearch) { //why does normal fileMetadatas not exist at this point? should I trigger it? how is search different?
DataFile fmFile = fm.getDataFile();
List<ExternalTool> fileTools = externalToolService.findAll(fmFile, apitoken); //MAD: rename these
externalTools.put(fmFile.getId(),fileTools);
}
}

// FIXME: We need to return a list of tools per file.
public List<ExternalTool> getExternalTools() {
return externalTools;
//public List<ExternalTool> getExternalTools() {
// return externalTools;
//}

//I need this to return one list of tools based upon an id
//??? How is externalTools being populated? should it be attached to an object?
//eh there is a service bean I can query... maybe I'm doing this wrong and still need that double list...
public Map getExternalTools() {
return externalTools;
}

public List<ExternalTool> getExternalToolsForDataFile(Long fileId) {
return externalTools.get(fileId);
}

//MAD : need to do this for each file and populate... ugh. Also clean up the double "findAll"

//fileMetadatasSearch is this what I'm suppose to be using???? private List<FileMetadata> fileMetadatasSearch;

//I need to generate a list of lists of external tools, one for each file. I don't understand how this data will be consumed in fileFragments...
//In the jsf it looks like I can reference #{fileMetadata.dataFile.id} and the like... so as long as I can create a list that can be referenced?
//Alternatively, maybe this info should be in the fileMetadata?

// fileMetadatasSearch

}
2 changes: 1 addition & 1 deletion src/main/webapp/file.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<h:outputText value= "#{bundle['file.delete']}"/>
</p:commandLink>
</li>
<ui:repeat value="#{FilePage.externalTools}" var="tool">
<ui:repeat value="#{FilePage.externalTools}" var="tool" rendered="#{FilePage.fileMetadata.dataFile.tabularData}">
<li>
<a href="#{tool.toolUrl}">#{tool.buttonLabel}</a>
</li>
Expand Down
5 changes: 3 additions & 2 deletions src/main/webapp/filesFragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,13 @@
</div>

<!-- MAD: This needs to be outside the download group I think, it needs that space and the like... -->
<div class="btn-group" >
<!-- Also needs restrictions so it only shows up on the correct files-->
<div class="btn-group" jsf:rendered="#{fileMetadata.dataFile.tabularData}">
<button type="button" id="editFile" class="btn btn-default btn-access dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-cog"/> #{bundle['dataset.configureBtn']} <span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right text-left" role="menu">
<ui:repeat value="#{DatasetPage.getExternalTools()}" var="tool">
<ui:repeat value="#{DatasetPage.getExternalToolsForDataFile(fileMetadata.dataFile.id)}" var="tool">
<li>
<a href="#{tool.toolUrl}">#{tool.buttonLabel}</a>
</li>
Expand Down

0 comments on commit 5d26270

Please sign in to comment.