Skip to content

Commit

Permalink
Merge pull request #36 from safrant/master
Browse files Browse the repository at this point in the history
CANANOLAB 720 and 726
  • Loading branch information
lexevs authored Aug 23, 2021
2 parents 16a2324 + 300a573 commit 8646e69
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ public SimpleNanomaterialEntityBean saveComposingElement(SimpleNanomaterialEntit
entity = transferNanoMateriaEntityBean(nanoBean, request);
List<String> msgs =new ArrayList<String>();
//Trusting form set theComposingElement to element being edited
ComposingElementBean composingElement = entity.getTheComposingElement();
composingElement.setupDomain(SpringSecurityUtil.getLoggedInUserName());
// ComposingElementBean composingElement = entity.getTheComposingElement();
// composingElement.setupDomain(SpringSecurityUtil.getLoggedInUserName());
// entity.addComposingElement(composingElement);

// save nanomaterial entity
Expand All @@ -368,7 +368,9 @@ public SimpleNanomaterialEntityBean saveComposingElement(SimpleNanomaterialEntit



compositionService.assignAccesses(composingElement.getDomain());
for (ComposingElementBean composingElementBean:entity.getComposingElements()) {
compositionService.assignAccesses(composingElementBean.getDomain());
}

// return to setupUpdate to retrieve the correct entity from database
// after saving to database.
Expand All @@ -381,7 +383,7 @@ public SimpleNanomaterialEntityBean saveComposingElement(SimpleNanomaterialEntit

private NanomaterialEntityBean transferNanoMateriaEntityBean(
SimpleNanomaterialEntityBean nanoBean, HttpServletRequest request) {
NanomaterialEntityBean bean = new NanomaterialEntityBean();
NanomaterialEntityBean nanomaterialEntityBean = new NanomaterialEntityBean();
NanomaterialEntity nanoEntity = null;

Collection<ComposingElement> coll = new HashSet<ComposingElement>();
Expand All @@ -399,85 +401,95 @@ private NanomaterialEntityBean transferNanoMateriaEntityBean(
//Setting up the ComposingElement
ComposingElementBean compBean = new ComposingElementBean();

SimpleComposingElementBean sBean = nanoBean.getSimpleCompBean();
SimpleComposingElementBean simpleCompBean = nanoBean.getSimpleCompBean();

ComposingElement comp = new ComposingElement();

FunctionBean func = new FunctionBean();

ImagingFunction img = new ImagingFunction();
Collection<Function> hash = new HashSet<Function>();
List<Map<String, Object>> funclist;
List<FunctionBean> inherentFunctions = new ArrayList<FunctionBean>();
List<ComposingElementBean> compList = new ArrayList<ComposingElementBean>();
if(sBean!=null){
comp.setDescription(sBean.getDescription());
comp.setType(sBean.getType());
comp.setName(sBean.getName());
comp.setPubChemDataSourceName(sBean.getPubChemDataSourceName());
comp.setPubChemId(sBean.getPubChemId());
if((sBean.getId()!=null)&&(sBean.getId()>0)){
comp.setId(sBean.getId());
comp.setCreatedBy(sBean.getCreatedBy());
comp.setCreatedDate(sBean.getCreatedDate());
if(simpleCompBean!=null){
if(simpleCompBean.getId()!=null && simpleCompBean.getId()>0) {
comp.setId(simpleCompBean.getId());
}
comp.setDescription(simpleCompBean.getDescription());
comp.setType(simpleCompBean.getType());
comp.setName(simpleCompBean.getName());
comp.setPubChemDataSourceName(simpleCompBean.getPubChemDataSourceName());
comp.setPubChemId(simpleCompBean.getPubChemId());
if((simpleCompBean.getId()!=null)&&(simpleCompBean.getId()>0)){
comp.setId(simpleCompBean.getId());
comp.setCreatedBy(simpleCompBean.getCreatedBy());
comp.setCreatedDate(simpleCompBean.getCreatedDate());
} else {
//TODO see if there is a way to grab user directly
comp.setCreatedBy(nanoBean.getCreatedBy());
comp.setCreatedDate(nanoBean.getCreatedDate());
}
comp.setMolecularFormula(sBean.getMolecularFormula());
comp.setMolecularFormulaType(sBean.getMolecularFormulaType());
comp.setValue(sBean.getValue());
comp.setValueUnit(sBean.getValueUnit());
funclist = sBean.getInherentFunction();
comp.setMolecularFormula(simpleCompBean.getMolecularFormula());
comp.setMolecularFormulaType(simpleCompBean.getMolecularFormulaType());
comp.setValue(simpleCompBean.getValue());
comp.setValueUnit(simpleCompBean.getValueUnit());
funclist = simpleCompBean.getInherentFunction();
FunctionBean functionBean = new FunctionBean();
if(funclist!= null){
for(int j=0;j<funclist.size();j++){
func = new FunctionBean();
// func = new FunctionBean();
img.setModality((String) funclist.get(j).get("modality"));
func.setType((String) funclist.get(j).get("type"));
func.setDescription((String) funclist.get(j).get("description"));
func.setImagingFunction(img);
functionBean.setType((String) funclist.get(j).get("type"));
functionBean.setDescription((String) funclist.get(j).get("description"));
functionBean.setImagingFunction(img);
Function function = new Function();
function.setDescription((String) funclist.get(j).get("description"));
if(new Long((String) funclist.get(j).get("id"))>0){
function.setCreatedBy((String) funclist.get(j).get("createdBy"));
function.setCreatedDate(new Date((Long) funclist.get(j).get("createdDate")));
function.setId(new Long((String) funclist.get(j).get("id")));
}else {
function.setCreatedBy(nanoBean.getCreatedBy());
function.setCreatedDate(nanoBean.getCreatedDate());
}
func.setDomainFunction(function);
if(new Long((String) funclist.get(j).get("id"))>0){
function.setId(new Long((String) funclist.get(j).get("id")));
functionBean.setId((String) funclist.get(j).get("id"));
function.setCreatedBy((String) funclist.get(j).get("createdBy"));
function.setCreatedDate(new Date((Long) funclist.get(j).get("createdDate")));
} else {
function.setCreatedBy(nanoBean.getCreatedBy());
function.setCreatedDate(nanoBean.getCreatedDate());
}
functionBean.setDomainFunction(function);
hash.add(function);
inherentFunctions.add(func);
inherentFunctions.add(functionBean);

}
}
compBean.setTheFunction(func);
compBean.setTheFunction(functionBean);
comp.setNanomaterialEntityPkId(nanoBean.getId().toString());
comp.setInherentFunctionCollection(hash);
compBean.setDomain(comp);
compBean.setInherentFunctions(inherentFunctions);
bean.addComposingElement(compBean);
bean.setTheComposingElement(compBean);

nanomaterialEntityBean.addComposingElement(compBean);
nanomaterialEntityBean.setTheComposingElement(compBean);
compList.add(compBean);
}
//setting up composing elements if there exists composingElements
List<SimpleComposingElementBean> list = nanoBean.getComposingElements();

func = new FunctionBean();

img = new ImagingFunction();
hash = new HashSet<Function>();


// List<ComposingElementBean> compList = new ArrayList<ComposingElementBean>();
if(list!=null){
for(SimpleComposingElementBean simpleComp : list){
hash = new HashSet<Function>();
compBean = new ComposingElementBean();
comp = new ComposingElement();
comp.setDescription(simpleComp.getDescription());
comp.setType(simpleComp.getType());
comp.setName(simpleComp.getName());
comp.setPubChemDataSourceName(simpleComp.getPubChemDataSourceName());
comp.setPubChemId(simpleComp.getPubChemId());
comp.setId(simpleComp.getId());
if(simpleComp.getId()!=null && simpleComp.getId()>0) {
comp.setId(simpleComp.getId());
}
comp.setCreatedBy(simpleComp.getCreatedBy());
comp.setCreatedDate(simpleComp.getCreatedDate());
comp.setMolecularFormula(simpleComp.getMolecularFormula());
Expand All @@ -487,29 +499,45 @@ private NanomaterialEntityBean transferNanoMateriaEntityBean(
funclist = simpleComp.getInherentFunction();
if(funclist!= null){
for(int j=0;j<funclist.size();j++){
FunctionBean functionBean = new FunctionBean();
img.setModality((String) funclist.get(j).get("modality"));
func.setType((String) funclist.get(j).get("type"));
func.setDescription((String) funclist.get(j).get("description"));
func.setImagingFunction(img);
functionBean.setType((String) funclist.get(j).get("type"));
functionBean.setDescription((String) funclist.get(j).get("description"));
functionBean.setImagingFunction(img);
Function function = new Function();
function.setDescription((String) funclist.get(j).get("description"));
if(new Long((String) funclist.get(j).get("id"))>0){
function.setId(new Long((String) funclist.get(j).get("id")));
functionBean.setId((String) funclist.get(j).get("id"));
function.setCreatedBy((String) funclist.get(j).get("createdBy"));
function.setCreatedDate(new Date((Long) funclist.get(j).get("createdDate")));
} else {
function.setCreatedBy(nanoBean.getCreatedBy());
function.setCreatedDate(nanoBean.getCreatedDate());
}
}
hash.add(function);
func.setDomainFunction(function);
functionBean.setDomainFunction(function);
compBean.addFunction(functionBean);
}
}
comp.setInherentFunctionCollection(hash);
comp.setNanomaterialEntityPkId(nanoBean.getId().toString());
coll.add(comp);
compBean.setTheFunction(func);
// compBean.setTheFunction(func);
compBean.setDomain(comp);
compList.add(compBean);

if (simpleCompBean != null) {
Long id1 = simpleComp.getId();
Long id2 = simpleCompBean.getId();
if (!id1.equals(id2)) {
compList.add(compBean);
}
} else {
compList.add(compBean);
}
// if(!(simpleCompBean.getId().equals(simpleComp.getId()))) {
// compList.add(compBean);
// }
}
}
//setting up theFile
Expand All @@ -533,7 +561,7 @@ private NanomaterialEntityBean transferNanoMateriaEntityBean(
}
fileBean.setDomainFile(file);
}
bean.setTheFile(fileBean);
nanomaterialEntityBean.setTheFile(fileBean);

//setting up files
List<SimpleFileBean> filelist = nanoBean.getFiles();
Expand Down Expand Up @@ -590,7 +618,7 @@ private NanomaterialEntityBean transferNanoMateriaEntityBean(
}
fullerene.setComposingElementCollection(coll);
fullerene.setFileCollection(filecoll);
bean.setFullerene(fullerene);
nanomaterialEntityBean.setFullerene(fullerene);
nanoEntity = fullerene;
}

Expand All @@ -613,7 +641,7 @@ else if(nanoBean.getType().equalsIgnoreCase("dendrimer")){
den.setComposingElementCollection(coll);
den.setFileCollection(filecoll);
nanoEntity = den;
bean.setDendrimer(den);
nanomaterialEntityBean.setDendrimer(den);
}

else if(nanoBean.getType().equalsIgnoreCase("biopolymer")){
Expand All @@ -636,7 +664,7 @@ else if(nanoBean.getType().equalsIgnoreCase("biopolymer")){
}
bio.setComposingElementCollection(coll);
bio.setFileCollection(filecoll);
bean.setBiopolymer(bio);
nanomaterialEntityBean.setBiopolymer(bio);
nanoEntity = bio;

}
Expand All @@ -645,7 +673,7 @@ else if(nanoBean.getType().equalsIgnoreCase("Liposome")){
if(nanoBean.getDomainEntity()!=null){
if(nanoBean.getDomainEntity().get("isPolymerized")!=null){
lipo.setPolymerized(Boolean.valueOf((String) nanoBean.getDomainEntity().get("isPolymerized")));
bean.setIsPolymerized((String) nanoBean.getDomainEntity().get("isPolymerized"));
nanomaterialEntityBean.setIsPolymerized((String) nanoBean.getDomainEntity().get("isPolymerized"));
}
if(nanoBean.getDomainEntity().get("polymerName")!=null)
lipo.setPolymerName((String) nanoBean.getDomainEntity().get("polymerName"));
Expand All @@ -661,14 +689,14 @@ else if(nanoBean.getType().equalsIgnoreCase("Liposome")){
lipo.setComposingElementCollection(coll);
lipo.setFileCollection(filecoll);
nanoEntity = lipo;
bean.setLiposome(lipo);
nanomaterialEntityBean.setLiposome(lipo);
}
else if(nanoBean.getType().equalsIgnoreCase("Emulsion")){
Emulsion em = new Emulsion();
if(nanoBean.getDomainEntity()!=null){
if(nanoBean.getDomainEntity().get("isPolymerized")!=null){
em.setPolymerized(Boolean.valueOf((String) nanoBean.getDomainEntity().get("isPolymerized")));
bean.setIsPolymerized((String) nanoBean.getDomainEntity().get("isPolymerized"));
nanomaterialEntityBean.setIsPolymerized((String) nanoBean.getDomainEntity().get("isPolymerized"));
}
if(nanoBean.getDomainEntity().get("polymerName")!=null)
em.setPolymerName((String) nanoBean.getDomainEntity().get("polymerName"));
Expand All @@ -683,15 +711,15 @@ else if(nanoBean.getType().equalsIgnoreCase("Emulsion")){
}
em.setComposingElementCollection(coll);
em.setFileCollection(filecoll);
bean.setEmulsion(em);
nanomaterialEntityBean.setEmulsion(em);
nanoEntity = em;
}
else if(nanoBean.getType().equalsIgnoreCase("Polymer")){
Polymer poly = new Polymer();
if(nanoBean.getDomainEntity()!=null){
if(nanoBean.getDomainEntity().get("isCrossLinked")!=null){
poly.setCrossLinked(Boolean.valueOf((String) nanoBean.getDomainEntity().get("isCrossLinked")));
bean.setIsCrossLinked((String) nanoBean.getDomainEntity().get("isCrossLinked"));
nanomaterialEntityBean.setIsCrossLinked((String) nanoBean.getDomainEntity().get("isCrossLinked"));
}
if(nanoBean.getDomainEntity().get("crossLinkDegree")!=null)
poly.setCrossLinkDegree(new Float((String) nanoBean.getDomainEntity().get("crossLinkDegree")));
Expand All @@ -708,7 +736,7 @@ else if(nanoBean.getType().equalsIgnoreCase("Polymer")){
}
poly.setComposingElementCollection(coll);
poly.setFileCollection(filecoll);
bean.setPolymer(poly);
nanomaterialEntityBean.setPolymer(poly);
nanoEntity = poly;
}

Expand Down Expand Up @@ -738,7 +766,7 @@ else if(nanoBean.getType().equalsIgnoreCase("carbon nanotube")){
}
ctube.setComposingElementCollection(coll);
ctube.setFileCollection(filecoll);
bean.setCarbonNanotube(ctube);
nanomaterialEntityBean.setCarbonNanotube(ctube);
nanoEntity = ctube;

}else{
Expand All @@ -758,13 +786,13 @@ else if(nanoBean.getType().equalsIgnoreCase("carbon nanotube")){
nanoEntity.setFileCollection(filecoll);
}

bean.setComposingElements(compList);
bean.setFiles(fileBeanList);
bean.setType(nanoBean.getType());
bean.setDescription(nanoBean.getDescription());
bean.setDomainEntity(nanoEntity);
nanomaterialEntityBean.setComposingElements(compList);
nanomaterialEntityBean.setFiles(fileBeanList);
nanomaterialEntityBean.setType(nanoBean.getType());
nanomaterialEntityBean.setDescription(nanoBean.getDescription());
nanomaterialEntityBean.setDomainEntity(nanoEntity);

return bean;
return nanomaterialEntityBean;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,12 @@ protected List transferCharacterizationResultsDataAndCondition(FindingBean findi
rowVals = new ArrayList<String>();
List<TableCell> cells = aRow.getCells();
for (TableCell cell : cells) {
rowVals.add(cell.getValue());
if(cell.getOperand().equals("=")) {
rowVals.add(cell.getValue());
} else
{
rowVals.add(cell.getOperand()+cell.getValue());
}
}

if (rowVals.size() == colSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.List;

import org.apache.log4j.Hierarchy;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@

import gov.nih.nci.cananolab.domain.common.PurityDatumCondition;
import gov.nih.nci.cananolab.domain.common.Supplier;
import gov.nih.nci.cananolab.domain.particle.*;

import gov.nih.nci.cananolab.domain.particle.Sample;
import gov.nih.nci.cananolab.domain.particle.SfeInherentFunction;
import gov.nih.nci.cananolab.domain.particle.SmeInherentFunction;
import gov.nih.nci.cananolab.domain.particle.Synthesis;
import gov.nih.nci.cananolab.domain.particle.SynthesisFunctionalization;
import gov.nih.nci.cananolab.domain.particle.SynthesisFunctionalizationElement;
import gov.nih.nci.cananolab.domain.particle.SynthesisMaterial;
import gov.nih.nci.cananolab.domain.particle.SynthesisMaterialElement;
import gov.nih.nci.cananolab.domain.particle.SynthesisPurification;
import gov.nih.nci.cananolab.domain.particle.SynthesisPurity;
import gov.nih.nci.cananolab.dto.common.FileBean;

import gov.nih.nci.cananolab.dto.particle.SampleBean;
Expand Down Expand Up @@ -58,7 +68,7 @@
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.security.access.method.P;
import org.springframework.stereotype.Component;
import sun.tools.tree.ThisExpression;
//import sun.tools.tree.ThisExpression;

@Component("synthesisService")
public class SynthesisServiceLocalImpl extends BaseServiceLocalImpl implements SynthesisService {
Expand Down

0 comments on commit 8646e69

Please sign in to comment.