Skip to content

Commit

Permalink
Introduce nahimaExported field and disable editing (for everyone) on …
Browse files Browse the repository at this point in the history
…exported records
  • Loading branch information
GenieTim committed Sep 10, 2020
1 parent 47f75a8 commit b85d507
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 24 deletions.
11 changes: 11 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,15 @@
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
</natures>
<filteredResources>
<filter>
<id>1599753380881</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,14 @@ public Specimen getSpecimen() {
return specimen;
}

public boolean save() throws SaveFailedException {
boolean result = false;
/**
* Save the specimen.
* Note that this method does not check permissions
*
* @return
* @throws SaveFailedException
*/
public void save() throws SaveFailedException {
SpecimenLifeCycle s = new SpecimenLifeCycle();
log.debug("in SpecimenControler.save: specimenId is " + specimen.getSpecimenId());
log.debug("in SpecimenControler.save: specimen barcode is " + specimen.getBarcode());
Expand All @@ -290,12 +296,10 @@ public boolean save() throws SaveFailedException {
if (updatedSpecimen != null) {
specimen = updatedSpecimen;
}
return result;
}

public boolean save(Specimen copiedSpecimen) throws SaveFailedException {
public void save(Specimen copiedSpecimen) throws SaveFailedException {
specimen = copiedSpecimen;
boolean result = false;
SpecimenLifeCycle s = new SpecimenLifeCycle();
if (specimen.getSpecimenId() != null) {
s.attachDirty(specimen);
Expand All @@ -311,7 +315,6 @@ public boolean save(Specimen copiedSpecimen) throws SaveFailedException {
// reload the specimen
// Why???
//specimen = s.findById(specimen.getSpecimenId());
return result;
}

public void displayInEditor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
<property name="country" type="string">
<column name="Country"/>
</property>
<property name="primaryDivisonISO" type="string">
<column name="ISO_3166_2_primary_division" length="11"/>
</property>
<property name="primaryDivison" type="string">
<column name="PrimaryDivison"/>
</property>
Expand Down Expand Up @@ -193,6 +196,9 @@
<property name="verbatimClusterIdentifier" type="string">
<column name="verbatimClusterIdentifier" length="255"/>
</property>
<property name="nahimaExported" type="java.lang.Boolean">
<column name="nahimaExported" default="0"/>
</property>
<property name="externalWorkflowProcess" type="string">
<column name="externalWorkflowProcess" length="900"/>
</property>
Expand Down
33 changes: 32 additions & 1 deletion src/main/java/edu/harvard/mcz/imagecapture/entity/Specimen.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
* Specimen generated by hbm2java
*/
public class Specimen implements java.io.Serializable {
public class Specimen implements Serializable {

public static final String STATUS_NOT_A_TYPE = "Not a Type";
private static final Log log = LogFactory.getLog(Specimen.class);
Expand Down Expand Up @@ -105,6 +106,8 @@ public class Specimen implements java.io.Serializable {
private Set<SpecimenPart> specimenParts = new HashSet<SpecimenPart>(0);
private Set<LatLong> georeferences = new HashSet<LatLong>(0);
private Set<ExternalHistory> externalHistory = new HashSet<ExternalHistory>(0);
private String primaryDivisonISO;
private Boolean nahimaExported;

public Specimen() {
setDefaults();
Expand Down Expand Up @@ -208,6 +211,34 @@ public Specimen(String barcode, String drawerNumber, String typeStatus,
this.specimenParts = specimenParts;
}

public Boolean getNahimaExported() {
return nahimaExported;
}

public void setNahimaExported(Boolean nahimaExported) {
this.nahimaExported = nahimaExported;
}

public Boolean isExported() {
return this.getNahimaExported();
}

public Boolean isEditable(Users user) {
return !this.isExported();
}

public Boolean isEditable() {
return this.isEditable(null);
}

public String getPrimaryDivisonISO() {
return primaryDivisonISO;
}

public void setPrimaryDivisonISO(String primaryDivisonISO) {
this.primaryDivisonISO = primaryDivisonISO;
}

/**
* Set default values for a new specimen object with no other data.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ public void actionPerformed(ActionEvent e) {
((Specimen) targetId).getLoadFlags() + "].\nSee: http://mczbase.mcz.harvard.edu/guid/MCZ:Ent:" +
((Specimen) targetId).getCatNum(),
"Migrated Specimen", JOptionPane.WARNING_MESSAGE);
// } else if (!((Specimen) targetId).isEditable()) {
// JOptionPane.showMessageDialog(
// Singleton.getSingletonInstance().getMainFrame(),
// "This Specimen record cannot be edited by you.",
// "Non-editable Specimen", JOptionPane.WARNING_MESSAGE);
} else {
// Specimen is still editable
if (table != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,12 @@ public void setPinLabelImage(Image anImage) {
}

protected boolean save() {
if (specimen.isExported()) {
JOptionPane.showMessageDialog(this,
"This Specimen is already exported. No edit will be saved.",
"Warning", JOptionPane.WARNING_MESSAGE);
return false;
}
boolean result = false;

try {
Expand Down
Loading

0 comments on commit b85d507

Please sign in to comment.