Skip to content

Commit

Permalink
More work on caNano 726
Browse files Browse the repository at this point in the history
  • Loading branch information
safrant committed Aug 23, 2021
1 parent c90ae49 commit 7be9c51
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import gov.nih.nci.cananolab.util.DateUtils;
import gov.nih.nci.cananolab.util.StringUtils;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
Expand Down Expand Up @@ -424,11 +425,17 @@ private NanomaterialEntityBean transferNanoMateriaEntityBean(
comp.setId(simpleCompBean.getId());
comp.setCreatedBy(simpleCompBean.getCreatedBy());
comp.setCreatedDate(simpleCompBean.getCreatedDate());
} else {
} else if ((nanoBean.getId()!=null)&&(nanoBean.getId()>0)){
//TODO see if there is a way to grab user directly
comp.setCreatedBy(nanoBean.getCreatedBy());
comp.setCreatedDate(nanoBean.getCreatedDate());
} else {
String currentUser = SpringSecurityUtil.getLoggedInUserName();
comp.setCreatedBy(currentUser);
comp.setCreatedDate(Calendar.getInstance().getTime());
}


comp.setMolecularFormula(simpleCompBean.getMolecularFormula());
comp.setMolecularFormulaType(simpleCompBean.getMolecularFormulaType());
comp.setValue(simpleCompBean.getValue());
Expand Down Expand Up @@ -487,8 +494,17 @@ private NanomaterialEntityBean transferNanoMateriaEntityBean(
comp.setName(simpleComp.getName());
comp.setPubChemDataSourceName(simpleComp.getPubChemDataSourceName());
comp.setPubChemId(simpleComp.getPubChemId());
if(simpleComp.getId()!=null && simpleComp.getId()>0) {
// if(simpleComp.getId()!=null && simpleComp.getId()>0) {
// comp.setId(simpleComp.getId());
// }
if((simpleComp.getId()!=null)&&(simpleComp.getId()>0)){
comp.setId(simpleComp.getId());
comp.setCreatedBy(simpleComp.getCreatedBy());
comp.setCreatedDate(simpleComp.getCreatedDate());
} else {
//TODO see if there is a way to grab user directly
comp.setCreatedBy(nanoBean.getCreatedBy());
comp.setCreatedDate(nanoBean.getCreatedDate());
}
comp.setCreatedBy(simpleComp.getCreatedBy());
comp.setCreatedDate(simpleComp.getCreatedDate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@
import gov.nih.nci.cananolab.service.sample.helper.CompositionServiceHelper;
import gov.nih.nci.cananolab.system.applicationservice.CaNanoLabApplicationService;
import gov.nih.nci.cananolab.system.applicationservice.client.ApplicationServiceProvider;

import java.util.Calendar;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;

import gov.nih.nci.cananolab.util.Constants;
import org.apache.log4j.Hierarchy;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -75,6 +78,12 @@ public void saveNanomaterialEntity(SampleBean sampleBean, NanomaterialEntityBean
.getApplicationService();
NanomaterialEntity entity = entityBean.getDomainEntity();
logger.debug("NanomaterialEntity " + entity.getCreatedBy());
String currentUser = SpringSecurityUtil.getLoggedInUserName() ;
if((entity.getId()==null)||!(entity.getId()>0) ){
entity.setCreatedBy(currentUser);
entity.setCreatedDate(Calendar.getInstance().getTime());
}
entity.setCreatedBy(currentUser);
Boolean newEntity = true;
Boolean newComp = true;
if (entity.getId() != null) {
Expand Down

0 comments on commit 7be9c51

Please sign in to comment.