yankeebushsoftware
asked on
Can someone comment what this if statements are doing in this method?
Can someone comment what this if statements are doing in this method?
public Attribute[] saveLab(Lab lab) throws ManagementSupportException {
// creating "request" object using service's method
TEServiceStub.SaveLab request = new TEServiceStub.SaveLab();
TEServiceStub.AttributeArr ay array = new TEServiceStub.AttributeArr ay();
List<TEServiceStub.Attribu te> attrs = new ArrayList<TEServiceStub.At tribute>() ;
if(lab.getId() > 0) {
TEServiceStub.Attribute attr = new TEServiceStub.Attribute();
attr.setName("LAB_ID");
attr.setValue(String.value Of(lab.get Id()));
attrs.add(attr);
}
if(lab.getDescription() != null && lab.getDescription().lengt h() > 0) {
TEServiceStub.Attribute attr = new TEServiceStub.Attribute();
attr.setName("DESCRIPTION" );
attr.setValue(lab.getDescr iption());
attrs.add(attr);
}
if(lab.getLocation() != null && lab.getLocation().length() > 0) {
TEServiceStub.Attribute attr = new TEServiceStub.Attribute();
attr.setName("LOCATION");
attr.setValue(lab.getLocat ion());
attrs.add(attr);
}
if(lab.getOwner() != null && lab.getOwner().length() > 0) {
TEServiceStub.Attribute attr = new TEServiceStub.Attribute();
attr.setName("OWNER");
attr.setValue(lab.getOwner ());
attrs.add(attr);
}
array.setAttributes((TESer viceStub.A ttribute[] ) attrs.toArray());
request.setAttributes(arra y);
// declaring "response" object
TEServiceStub.SaveLabRespo nse response = null;
try {
// invoking web service's method
response = stub.saveLab(request);
} catch (RemoteException e) {
logger.warn("Fail to call TEService :" + e);
throw new ManagementSupportException ("Fail to call TEService :" + e);
}
// processing "response" object
if(!response.getStatus().g etSuccess( )) {
logger.warn("TEService return failure while call saveLab()");
throw new ManagementSupportException ("TEServic e return failure while call saveLab()");
}
return cast(response.getAttribute s());
}
public Attribute[] saveLab(Lab lab) throws ManagementSupportException
// creating "request" object using service's method
TEServiceStub.SaveLab request = new TEServiceStub.SaveLab();
TEServiceStub.AttributeArr
List<TEServiceStub.Attribu
if(lab.getId() > 0) {
TEServiceStub.Attribute attr = new TEServiceStub.Attribute();
attr.setName("LAB_ID");
attr.setValue(String.value
attrs.add(attr);
}
if(lab.getDescription() != null && lab.getDescription().lengt
TEServiceStub.Attribute attr = new TEServiceStub.Attribute();
attr.setName("DESCRIPTION"
attr.setValue(lab.getDescr
attrs.add(attr);
}
if(lab.getLocation() != null && lab.getLocation().length()
TEServiceStub.Attribute attr = new TEServiceStub.Attribute();
attr.setName("LOCATION");
attr.setValue(lab.getLocat
attrs.add(attr);
}
if(lab.getOwner() != null && lab.getOwner().length() > 0) {
TEServiceStub.Attribute attr = new TEServiceStub.Attribute();
attr.setName("OWNER");
attr.setValue(lab.getOwner
attrs.add(attr);
}
array.setAttributes((TESer
request.setAttributes(arra
// declaring "response" object
TEServiceStub.SaveLabRespo
try {
// invoking web service's method
response = stub.saveLab(request);
} catch (RemoteException e) {
logger.warn("Fail to call TEService :" + e);
throw new ManagementSupportException
}
// processing "response" object
if(!response.getStatus().g
logger.warn("TEService return failure while call saveLab()");
throw new ManagementSupportException
}
return cast(response.getAttribute
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.