Skip to content

Commit

Permalink
refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
lbownik committed Dec 9, 2024
1 parent dea424a commit e8d9555
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@ public List<DatasetVersion> getVersions() {
return versions;
}

public boolean wasReleased() {
return this.versions.stream().anyMatch(DatasetVersion::wasReleased);
}



public Dataverse getRoot() {
return getOwner().getRoot();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ public String getFriendlyVersionNumber() {
public boolean isReleased() {
return VersionState.RELEASED.equals(versionState);
}

public boolean wasReleased() {
return isReleased() || isArchived();
}

public boolean isDraft() {
return VersionState.DRAFT.equals(versionState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
/**
* @author gdurand
*/
@SuppressWarnings("serial")
@ViewScoped
@Named("DatasetPage")
public class DatasetPage implements Serializable {
Expand Down Expand Up @@ -599,7 +600,6 @@ private String init(boolean initFull) {
contributorMessageToCurator = StringUtils.EMPTY;
fileTermDiffsWithLatestReleased = Lists.newArrayList();

setExistReleasedVersion(resetExistRealeaseVersion());
//moving setVersionTabList to tab change event
//setVersionTabList(resetVersionTabList());
//setReleasedVersionTabList(resetReleasedVersionTabList());
Expand Down Expand Up @@ -931,12 +931,12 @@ private String returnToLatestVersion() {
if (workingVersion.isDeaccessioned() && dataset.getReleasedVersion() != null) {
workingVersion = dataset.getReleasedVersion();
}
return "/dataset.xhtml?persistentId=" + dataset.getGlobalIdString() + "&version=" + workingVersion.getFriendlyVersionNumber() + "&faces-redirect=true";
return "/dataset.xhtml?persistentId=" + dataset.getGlobalId().asString() + "&version=" + workingVersion.getFriendlyVersionNumber() + "&faces-redirect=true";
}

private String returnToDatasetOnly() {
dataset = datasetPageFacade.retrieveDataset(dataset.getId());
return "/dataset.xhtml?persistentId=" + dataset.getGlobalIdString() + "&faces-redirect=true";
return "/dataset.xhtml?faces-redirect=true&persistentId=".concat(dataset.getGlobalId().asString());
}

public void refreshAllLocks() {
Expand Down Expand Up @@ -1031,25 +1031,8 @@ public void setStateChanged(boolean stateChanged) {
}


private boolean existReleasedVersion;

public boolean isExistReleasedVersion() {
return existReleasedVersion;
}

public void setExistReleasedVersion(boolean existReleasedVersion) {
this.existReleasedVersion = existReleasedVersion;
}

private boolean resetExistRealeaseVersion() {

for (DatasetVersion version : dataset.getVersions()) {
if (version.isReleased() || version.isArchived()) {
return true;
}
}
return false;

return this.dataset.wasReleased();
}


Expand Down Expand Up @@ -1132,6 +1115,11 @@ public String getTitle() {
public String getDescription() {
return workingVersion.getDescriptionPlainText();
}

public String getDescriptionUpTo(final int length) {
final String desc = getDescription();
return desc.length() > length ? desc.substring(0, length - 3).concat("...") : desc;
}

/**
* dataset authors
Expand Down
2 changes: 1 addition & 1 deletion dataverse-webapp/src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
content="#{systemConfig.dataverseSiteUrl.concat(resource['images/favicondataverse.png'])}"/>
<meta property="og:site_name" content="#{DatasetPage.publisher}"/>
<meta property="og:description"
content="#{(DatasetPage.description.length()>150 ? DatasetPage.description.substring(0,147).concat('...'): DatasetPage.description)}"/>
content="#{DatasetPage.getDescriptionUpTo(150)}"/>
<ui:repeat var="author" value="#{DatasetPage.datasetAuthors}">
<meta property="article:author" content="#{author}"/>
</ui:repeat>
Expand Down

0 comments on commit e8d9555

Please sign in to comment.