提交 5a28f0d1 编写于 作者: H hot13399

refactor. clean code for Json, MailSender, pojo and properties.

上级 e5743c80
...@@ -16,9 +16,9 @@ import com.spring.mvc.mini.pojo.ObjectClass; ...@@ -16,9 +16,9 @@ import com.spring.mvc.mini.pojo.ObjectClass;
import com.spring.mvc.mini.properties.Properties; import com.spring.mvc.mini.properties.Properties;
@Component @Component
public class RequestStatusJsonMapping { public class RequestStatusJsonParser {
static Logger LOG = LoggerFactory.getLogger(RequestStatusJsonMapping.class); static Logger LOG = LoggerFactory.getLogger(RequestStatusJsonParser.class);
@Autowired @Autowired
private Properties properties; private Properties properties;
...@@ -27,7 +27,7 @@ public class RequestStatusJsonMapping { ...@@ -27,7 +27,7 @@ public class RequestStatusJsonMapping {
ArrayList<RequestStatus> list = this.readStatus(); ArrayList<RequestStatus> list = this.readStatus();
ArrayList<ObjectClass> objectClasses = list.get(list.size() - 1).getObjectClassListType().getObjectclasslist(); ArrayList<ObjectClass> objectClasses = list.get(list.size() - 1).getObjectClassListType().getObjectClasses();
return objectClasses.get(objectClasses.size() - 1).getIntclass(); return objectClasses.get(objectClasses.size() - 1).getIntclass();
} }
......
...@@ -21,36 +21,37 @@ import com.spring.mvc.mini.properties.Properties; ...@@ -21,36 +21,37 @@ import com.spring.mvc.mini.properties.Properties;
@Component @Component
public class MailSender { public class MailSender {
static Logger LOGGER = LoggerFactory.getLogger(MailSender.class); static Logger LOG = LoggerFactory.getLogger(MailSender.class);
@Autowired @Autowired
private Properties properties; private Properties properties;
public void sendMail(final String username,final String password, String fromAddress, Address[] toAddress, String subject, String text) throws AddressException, MessagingException { public void sendMail(final String username,final String password, String fromAddress, Address[] toAddress, String subject, String text) throws Exception {
java.util.Properties props = new java.util.Properties();
props.put("mail.smtp.starttls.enable", properties.getStarttlsEnable());
props.put("mail.smtp.auth", properties.getAuth());
props.put("mail.smtp.host", properties.getHost());
props.put("mail.smtp.port", properties.getPort());
Authenticator au = new javax.mail.Authenticator() { Authenticator au = new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() { protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password); return new PasswordAuthentication(username, password);
} }
}; };
Session session = Session.getInstance(props, au); Message message = new MimeMessage(Session.getInstance(getProperties(), au));
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(fromAddress)); message.setFrom(new InternetAddress(fromAddress));
message.setSubject(subject); message.setSubject(subject);
message.setText(text); message.setText(text);
message.setRecipients(Message.RecipientType.TO, toAddress); message.setRecipients(Message.RecipientType.TO, toAddress);
Transport.send(message); Transport.send(message);
LOGGER.info("Send Mail Done: "+fromAddress+" to" + toAddress); LOG.info("Send Mail Done: " + fromAddress + " to" + toAddress);
} }
private java.util.Properties getProperties() {
java.util.Properties props = new java.util.Properties();
props.put("mail.smtp.starttls.enable", properties.getStarttlsEnable());
props.put("mail.smtp.auth", properties.getAuth());
props.put("mail.smtp.host", properties.getHost());
props.put("mail.smtp.port", properties.getPort());
return props;
}
} }
...@@ -4,106 +4,119 @@ import java.io.Serializable; ...@@ -4,106 +4,119 @@ import java.io.Serializable;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
public class ObjectClass implements Serializable{ public class ObjectClass implements Serializable {
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@NotNull @NotNull
String id; String id;
@NotNull @NotNull
int intclass; int intclass;
@NotNull @NotNull
String abbrev; String abbreviation;
@NotNull @NotNull
String adaID; String packageName;
@NotNull @NotNull
String name; String name;
@NotNull @NotNull
String parents; String parents;
String comment; String comment;
public String getId() { public String getId() {
return id; return id;
} }
public void setId(String id) {
this.id = id; public void setId(String id) {
} this.id = id;
public int getIntclass() { }
return intclass;
} public int getIntclass() {
public void setIntclass(int intclass) { return intclass;
this.intclass = intclass; }
}
public String getAbbrev() { public void setIntclass(int intclass) {
return abbrev; this.intclass = intclass;
} }
public void setAbbrev(String abbrev) {
this.abbrev = abbrev; public String getAbbreviation() {
} return abbreviation;
public String getAdaID() { }
return adaID;
} public void setAbbreviation(String abbreviation) {
public void setAdaID(String adaID) { this.abbreviation = abbreviation;
this.adaID = adaID; }
}
public String getName() { public String getPackageName() {
return name; return packageName;
} }
public void setName(String name) {
this.name = name; public void setPackageName(String packageName) {
} this.packageName = packageName;
public String getParents() { }
return parents;
} public String getName() {
public void setParents(String parents) { return name;
this.parents = parents; }
}
public void setName(String name) {
public String getComment() { this.name = name;
return comment; }
}
public void setComment(String comment) { public String getParents() {
this.comment = comment; return parents;
} }
@Override
public String toString() { public void setParents(String parents) {
return "ObjectClass [id=" + id + ", intclass=" + intclass + ", abbrev=" this.parents = parents;
+ abbrev + ", adaID=" + adaID + ", name=" + name + ", parents=" }
+ parents + ", comment=" + comment + "]";
} public String getComment() {
return comment;
public boolean match(String searchcritical){ }
if (this.abbrev.contains(searchcritical)){ public void setComment(String comment) {
return true; this.comment = comment;
} }
if (this.abbrev.contains(searchcritical)){
return true; @Override
} public String toString() {
if (this.adaID.contains(searchcritical)){ return "ObjectClass [id=" + id + ", intclass=" + intclass + ", abbreviation="
return true; + abbreviation + ", packageName=" + packageName + ", name=" + name + ", parents="
} + parents + ", comment=" + comment + "]";
if (this.comment.contains(searchcritical)){ }
return true;
} public boolean match(String searchcritical) {
if (this.id.contains(searchcritical)){
return true; if (this.abbreviation.contains(searchcritical)) {
} return true;
if (this.name.contains(searchcritical)){ }
return true; if (this.abbreviation.contains(searchcritical)) {
} return true;
if (this.parents.contains(searchcritical)){ }
return true; if (this.packageName.contains(searchcritical)) {
} return true;
if (String.valueOf(this.intclass).contains(searchcritical)){ }
return true; if (this.comment.contains(searchcritical)) {
} return true;
return false; }
} if (this.id.contains(searchcritical)) {
return true;
}
if (this.name.contains(searchcritical)) {
return true;
}
if (this.parents.contains(searchcritical)) {
return true;
}
if (String.valueOf(this.intclass).contains(searchcritical)) {
return true;
}
return false;
}
} }
...@@ -3,22 +3,23 @@ package com.spring.mvc.mini.pojo; ...@@ -3,22 +3,23 @@ package com.spring.mvc.mini.pojo;
import java.util.ArrayList; import java.util.ArrayList;
public class ObjectClassListType { public class ObjectClassListType {
ArrayList<ObjectClass> objectclasslist;
public ArrayList<ObjectClass> getObjectclasslist() { ArrayList<ObjectClass> objectClasses;
return objectclasslist;
}
public void setObjectclasslist(ArrayList<ObjectClass> objectclasslist) { public ArrayList<ObjectClass> getObjectClasses() {
this.objectclasslist = objectclasslist; return objectClasses;
} }
@Override public void setObjectClasses(ArrayList<ObjectClass> objectClasses) {
public String toString() { this.objectClasses = objectClasses;
StringBuffer sb = new StringBuffer(); }
for (ObjectClass item:objectclasslist){
sb.append(item); @Override
} public String toString() {
return "ObjectClassListType [objectclasslist=" + sb.toString() + "]"; StringBuffer sb = new StringBuffer();
} for (ObjectClass item : objectClasses) {
sb.append(item);
}
return "ObjectClassListType [objectClasses=" + sb + "]";
}
} }
...@@ -5,35 +5,41 @@ import javax.validation.constraints.NotNull; ...@@ -5,35 +5,41 @@ import javax.validation.constraints.NotNull;
import com.spring.mvc.mini.password.PasswordJasypter; import com.spring.mvc.mini.password.PasswordJasypter;
public class UserInfo { public class UserInfo {
@NotNull @NotNull
String username; String username;
@NotNull @NotNull
String email; String email;
@NotNull @NotNull
String password; String password;
public String getUsername() { public String getUsername() {
return username; return username;
} }
public void setUsername(String username) {
this.username = username; public void setUsername(String username) {
} this.username = username;
public String getEmail() { }
return email;
} public String getEmail() {
public void setEmail(String email) { return email;
this.email = email; }
}
public String getPassword() { public void setEmail(String email) {
this.email = email;
return PasswordJasypter.decryption(this.password); }
}
public void setPassword(String password) { public String getPassword() {
this.password = PasswordJasypter.encryption(password);
} return PasswordJasypter.decryption(this.password);
@Override }
public String toString() {
return "UserInfo [username=" + username + ", email=" + email public void setPassword(String password) {
+ ", password=******]"; this.password = PasswordJasypter.encryption(password);
} }
@Override
public String toString() {
return "UserInfo [username=" + username + ", email=" + email
+ ", password=******]";
}
} }
...@@ -5,8 +5,6 @@ import java.util.Calendar; ...@@ -5,8 +5,6 @@ import java.util.Calendar;
import java.util.Date; import java.util.Date;
import javax.mail.Address; import javax.mail.Address;
import javax.mail.MessagingException;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
import org.joda.time.DateTime; import org.joda.time.DateTime;
...@@ -15,7 +13,7 @@ import org.slf4j.Logger; ...@@ -15,7 +13,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.spring.mvc.mini.json.RequestStatusJsonMapping; import com.spring.mvc.mini.json.RequestStatusJsonParser;
import com.spring.mvc.mini.mail.MailSender; import com.spring.mvc.mini.mail.MailSender;
import com.spring.mvc.mini.pojo.RequestStatus; import com.spring.mvc.mini.pojo.RequestStatus;
import com.spring.mvc.mini.pojo.RequestStatusListType; import com.spring.mvc.mini.pojo.RequestStatusListType;
...@@ -26,75 +24,82 @@ import com.spring.mvc.mini.svn.SVNHandler; ...@@ -26,75 +24,82 @@ import com.spring.mvc.mini.svn.SVNHandler;
import com.spring.mvc.mini.xml.ObjectClassXMLPaser; import com.spring.mvc.mini.xml.ObjectClassXMLPaser;
public class ScheduleFileUpdator { public class ScheduleFileUpdator {
static Logger LOGGER = LoggerFactory.getLogger(ScheduleFileUpdator.class); static Logger LOG = LoggerFactory.getLogger(ScheduleFileUpdator.class);
@Autowired @Autowired
RequestStatusJsonMapping rsjm; RequestStatusJsonParser jsonParser;
@Autowired @Autowired
SVNHandler sh; SVNHandler svnHandler;
@Autowired @Autowired
ObjectClassXMLPaser ocxp; ObjectClassXMLPaser objectClassXMLPaser;
@Autowired @Autowired
MailSender ms; MailSender mailSender;
public void commitObjectClassXml() public void commitObjectClassXml() {
{ Calendar calendar = Calendar.getInstance();
Calendar cal = Calendar.getInstance(); Date currentTime = calendar.getTime();
Date currenttime = cal.getTime();
LOG.info("Scheduler start at:" + currentTime);
LOGGER.info("Scheduler start at:"+ currenttime);
ArrayList<RequestStatus> requestStatuses = jsonParser.readStatus();
ArrayList<RequestStatus> mrsList = rsjm.readStatus();
int requestStatusIndex = 0;
int mrsIndex = 0; for (RequestStatus status : requestStatuses) {
for(RequestStatus mrs:mrsList){
int daysBetweenSubmitAndCurrent = Days.daysBetween(new DateTime(status.getSubmitDate()), new DateTime(currentTime)).getDays();
int days = Days.daysBetween(new DateTime(mrs.getSubmitDate()), new DateTime(currenttime)).getDays();
if (StatusType.ongoing.equals(status.getStatus())) {
if(StatusType.ongoing.equals(mrs.getStatus())){ if (daysBetweenSubmitAndCurrent >= 5) {
if(days >= 5){
setCommitDateAndStatus(currentTime, requestStatuses, status);
mrsIndex = mrsList.indexOf(mrs);
mrsList.get(mrsIndex).setCommitDate(currenttime); LOG.info("MO CR " + status.getmocrid() + " was checked at:" + new Date());
mrsList.get(mrsIndex).setStatus(StatusType.commited);
try {
StringBuffer subjectsb = new StringBuffer(); this.commitAndSendMail(status.getUserinfo(), appendCommitMessage(status), "Congratulation!");
subjectsb.append("Final approval of MO CR "); } catch (Exception e) {
subjectsb.append(mrs.getmocrid()); LOG.error(e.toString());
subjectsb.append(" for "); }
}
for(ObjectClass objcls:mrs.getObjectClassListType().getObjectclasslist()){ }
ocxp.AddObjectClass(objcls);
subjectsb.append(objcls.getAbbrev()); }
} RequestStatusListType type = new RequestStatusListType();
type.setRequestStatuses(requestStatuses);
LOGGER.info("MO CR "+mrs.getmocrid()+" was checked at:"+ new Date()); jsonParser.writeStatus(type);
try { svnHandler.svnCheckin();
this.commitAndSendMail(mrs.getUserinfo(), subjectsb.toString(), "Congratulation!"); }
} catch (MessagingException e) {
LOGGER.error(e.toString()); private String appendCommitMessage(RequestStatus status) {
}
} StringBuffer s = new StringBuffer();
} s.append("Final approval of MO CR ");
s.append(status.getmocrid());
} s.append(" for ");
RequestStatusListType mrslt = new RequestStatusListType();
mrslt.setRequestStatuses(mrsList); for (ObjectClass objcls : status.getObjectClassListType().getObjectClasses()) {
rsjm.writeStatus(mrslt); objectClassXMLPaser.AddObjectClass(objcls);
s.append(objcls.getAbbreviation());
sh.svnCheckin(); }
return s.toString();
}
private void setCommitDateAndStatus(Date currentTime, ArrayList<RequestStatus> requestStatuses, RequestStatus status) {
int requestStatusIndex;
requestStatusIndex = requestStatuses.indexOf(status);
requestStatuses.get(requestStatusIndex).setCommitDate(currentTime);
requestStatuses.get(requestStatusIndex).setStatus(StatusType.commited);
}
public void commitAndSendMail(UserInfo userInfo, String subject, String text) throws Exception {
Address[] toAddress = {new InternetAddress(userInfo.getEmail())};
mailSender.sendMail(userInfo.getUsername(), userInfo.getPassword(), userInfo.getEmail(), toAddress, subject, text);
} }
public void commitAndSendMail(UserInfo userinfo ,String subject, String text) throws AddressException, MessagingException{
Address[] toAddress = {new InternetAddress(userinfo.getEmail())};
ms.sendMail(userinfo.getUsername(),userinfo.getPassword(),userinfo.getEmail(),toAddress, subject, text);
}
} }
...@@ -25,110 +25,102 @@ import com.spring.mvc.mini.properties.Properties; ...@@ -25,110 +25,102 @@ import com.spring.mvc.mini.properties.Properties;
@Component @Component
public class SVNHandler { public class SVNHandler {
static Logger LOGGER = LoggerFactory.getLogger(SVNHandler.class); static Logger LOG = LoggerFactory.getLogger(SVNHandler.class);
@Autowired @Autowired
private Properties properties; private Properties properties;
public void svnCheckin(){ public void svnCheckin() {
SVNRepository repository = null; SVNRepository repository = null;
SVNClientManager ourClientManager = SVNClientManager.newInstance(); SVNClientManager ourClientManager = SVNClientManager.newInstance();
try{ try {
//initiate the reporitory from the url repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(properties.getRepURL()));
repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(properties.getRepURL()));
ISVNAuthenticationManager authManager =
//create authentication data SVNWCUtil.createDefaultAuthenticationManager(properties.getUsername(), properties.getPassword());
ISVNAuthenticationManager authManager = repository.setAuthenticationManager(authManager);
SVNWCUtil.createDefaultAuthenticationManager(properties.getUsername(), properties.getPassword());
repository.setAuthenticationManager(authManager); LOG.info("Repository Root: " + repository.getRepositoryRoot(true));
LOG.info("Repository UUID: " + repository.getRepositoryUUID(true));
//output some data to verify connection
System.out.println( "Repository Root: " + repository.getRepositoryRoot( true ) ); LOG.info("Repository Latest Revision: " + repository.getLatestRevision());
System.out.println( "Repository UUID: " + repository.getRepositoryUUID( true ) );
ourClientManager.setAuthenticationManager(authManager);
//need to identify latest revision
long latestRevision = repository.getLatestRevision(); SVNCommitClient commitClient = ourClientManager.getCommitClient();
System.out.println( "Repository Latest Revision: " + latestRevision); SVNDiffClient diffClient = ourClientManager.getDiffClient();
//create client manager and set authentication File xmlfile = new File(properties.getXmlPath());
File jsonfile = new File(properties.getJsonPath());
ourClientManager.setAuthenticationManager(authManager); File[] xmlfilearray = {xmlfile};
File[] jsonfilearray = {jsonfile};
//use commitClient to do the export
SVNCommitClient commitClient = ourClientManager.getCommitClient(); final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
SVNDiffClient diffClient = ourClientManager.getDiffClient();
diffClient.doDiff(xmlfile, SVNRevision.UNDEFINED, SVNRevision.BASE, SVNRevision.WORKING,
File xmlfile = new File(properties.getXmlPath());
File jsonfile = new File(properties.getJsonPath());
File[] xmlfilearray = {xmlfile};
File[] jsonfilearray = {jsonfile};
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
diffClient.doDiff(xmlfile, SVNRevision.UNDEFINED, SVNRevision.BASE ,SVNRevision.WORKING,
SVNDepth.INFINITY, true, outputStream, null);
if(outputStream.size() > 0){
commitClient.doCommit(xmlfilearray, false,outputStream.toString() , false, true);
LOGGER.info("XML Checked in at "+new Date());
}
diffClient.doDiff(jsonfile, SVNRevision.UNDEFINED, SVNRevision.BASE ,SVNRevision.WORKING,
SVNDepth.INFINITY, true, outputStream, null); SVNDepth.INFINITY, true, outputStream, null);
if(outputStream.size() > 0){ if (outputStream.size() > 0) {
commitClient.doCommit(jsonfilearray, false,outputStream.toString() , false, true); commitClient.doCommit(xmlfilearray, false, outputStream.toString(), false, true);
LOGGER.info("Json SVN Checked in at "+new Date()); LOG.info("XML Checked in at " + new Date());
} }
} catch (SVNException e) { diffClient.doDiff(jsonfile, SVNRevision.UNDEFINED, SVNRevision.BASE, SVNRevision.WORKING,
LOGGER.error(e.toString()); SVNDepth.INFINITY, true, outputStream, null);
} finally {
ourClientManager.dispose(); if (outputStream.size() > 0) {
} commitClient.doCommit(jsonfilearray, false, outputStream.toString(), false, true);
} LOG.info("Json SVN Checked in at " + new Date());
}
public void svnCheckout() {
} catch (SVNException e) {
File svnTempDir = new File(properties.getRepPath()); LOG.error(e.toString());
if (svnTempDir.exists()){ } finally {
return; ourClientManager.dispose();
} }
}
SVNRepository repository = null;
public void svnCheckout() {
try{
//initiate the reporitory from the url File svnTempDir = new File(properties.getRepPath());
repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(properties.getRepURL())); if (svnTempDir.exists()) {
return;
//create authentication data }
ISVNAuthenticationManager authManager =
SVNWCUtil.createDefaultAuthenticationManager(properties.getUsername(), properties.getPassword()); SVNRepository repository = null;
repository.setAuthenticationManager(authManager);
try {
//need to identify latest revision //initiate the reporitory from the url
long latestRevision = repository.getLatestRevision(); repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(properties.getRepURL()));
//create client manager and set authentication //create authentication data
SVNClientManager ourClientManager = SVNClientManager.newInstance(); ISVNAuthenticationManager authManager =
ourClientManager.setAuthenticationManager(authManager); SVNWCUtil.createDefaultAuthenticationManager(properties.getUsername(), properties.getPassword());
repository.setAuthenticationManager(authManager);
//use SVNUpdateClient to do the export
SVNUpdateClient updateClient = ourClientManager.getUpdateClient(); //need to identify latest revision
updateClient.setIgnoreExternals( false ); long latestRevision = repository.getLatestRevision();
updateClient.doCheckout(repository.getLocation(), svnTempDir, //create client manager and set authentication
SVNRevision.create(latestRevision), SVNRevision.create(latestRevision), true); SVNClientManager ourClientManager = SVNClientManager.newInstance();
ourClientManager.setAuthenticationManager(authManager);
} catch (SVNException e) {
LOGGER.error(e.toString()); //use SVNUpdateClient to do the export
} finally { SVNUpdateClient updateClient = ourClientManager.getUpdateClient();
LOGGER.info("resources/svn_temp checked outs"); updateClient.setIgnoreExternals(false);
}
} updateClient.doCheckout(repository.getLocation(), svnTempDir,
SVNRevision.create(latestRevision), SVNRevision.create(latestRevision), true);
} catch (SVNException e) {
LOG.error(e.toString());
} finally {
LOG.info("resources/svn_temp checked outs");
}
}
} }
...@@ -22,8 +22,8 @@ public class ObjectClassDataValidator { ...@@ -22,8 +22,8 @@ public class ObjectClassDataValidator {
boolean parentsMark = false; boolean parentsMark = false;
if(!objclsItemFormIn.getAbbrev().equals(objclsItemFormIn.getAbbrev().toUpperCase())){ if(!objclsItemFormIn.getAbbreviation().equals(objclsItemFormIn.getAbbreviation().toUpperCase())){
throw new ObjectClassDataValidationException("FAILED:ObjectClass abbrev:\""+objclsItemFormIn.getAbbrev()+"\" should be all uppercase."); throw new ObjectClassDataValidationException("FAILED:ObjectClass abbrev:\""+objclsItemFormIn.getAbbreviation()+"\" should be all uppercase.");
} }
for (ObjectClass objclsItemXmlIn:objclsListXmlIn){ for (ObjectClass objclsItemXmlIn:objclsListXmlIn){
...@@ -31,8 +31,8 @@ public class ObjectClassDataValidator { ...@@ -31,8 +31,8 @@ public class ObjectClassDataValidator {
if(objclsItemXmlIn.getId().equals(objclsItemFormIn.getId())){ if(objclsItemXmlIn.getId().equals(objclsItemFormIn.getId())){
throw new ObjectClassDataValidationException("FAILED:ObjectClass id:\""+objclsItemFormIn.getId()+"\" is already reserved."); throw new ObjectClassDataValidationException("FAILED:ObjectClass id:\""+objclsItemFormIn.getId()+"\" is already reserved.");
} }
if(objclsItemXmlIn.getAbbrev().equals(objclsItemFormIn.getAbbrev())){ if(objclsItemXmlIn.getAbbreviation().equals(objclsItemFormIn.getAbbreviation())){
throw new ObjectClassDataValidationException("FAILED:ObjectClass abbrev:\""+objclsItemFormIn.getAbbrev()+"\" is already reserved."); throw new ObjectClassDataValidationException("FAILED:ObjectClass abbrev:\""+objclsItemFormIn.getAbbreviation()+"\" is already reserved.");
} }
if(objclsItemXmlIn.getId().equals(objclsItemFormIn.getParents())){ if(objclsItemXmlIn.getId().equals(objclsItemFormIn.getParents())){
parentsMark = true; parentsMark = true;
......
...@@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.SessionAttributes; ...@@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.context.request.WebRequest; import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.spring.mvc.mini.json.RequestStatusJsonMapping; import com.spring.mvc.mini.json.RequestStatusJsonParser;
import com.spring.mvc.mini.mail.MailSender; import com.spring.mvc.mini.mail.MailSender;
import com.spring.mvc.mini.pojo.RequestStatus; import com.spring.mvc.mini.pojo.RequestStatus;
import com.spring.mvc.mini.properties.Properties; import com.spring.mvc.mini.properties.Properties;
...@@ -40,7 +40,7 @@ public class ObjectClassFormController { ...@@ -40,7 +40,7 @@ public class ObjectClassFormController {
static Logger LOGGER = LoggerFactory.getLogger(ObjectClassFormController.class); static Logger LOGGER = LoggerFactory.getLogger(ObjectClassFormController.class);
@Autowired @Autowired
RequestStatusJsonMapping rsjm; RequestStatusJsonParser rsjm;
@Autowired @Autowired
ObjectClassDataValidator ocdv; ObjectClassDataValidator ocdv;
...@@ -72,7 +72,7 @@ public class ObjectClassFormController { ...@@ -72,7 +72,7 @@ public class ObjectClassFormController {
ArrayList<ObjectClass> objclsList = new ArrayList<ObjectClass>(); ArrayList<ObjectClass> objclsList = new ArrayList<ObjectClass>();
objclsList.add(createObjectClassInstance(0,userinfo,mocrid)); objclsList.add(createObjectClassInstance(0,userinfo,mocrid));
ojbclslisttype.setObjectclasslist(objclsList); ojbclslisttype.setObjectClasses(objclsList);
model.addAttribute("ojbclslisttype", ojbclslisttype); model.addAttribute("ojbclslisttype", ojbclslisttype);
} }
...@@ -83,7 +83,7 @@ public class ObjectClassFormController { ...@@ -83,7 +83,7 @@ public class ObjectClassFormController {
@RequestMapping(params={"objclscount"},method=RequestMethod.POST) @RequestMapping(params={"objclscount"},method=RequestMethod.POST)
public void objectClassFormWithParam(@Valid ObjectClassListType ojbclslisttype, @ModelAttribute("userinfo") UserInfo userinfo, @ModelAttribute("mocrid") String mocrid, @RequestParam String objclscount, Model model) { public void objectClassFormWithParam(@Valid ObjectClassListType ojbclslisttype, @ModelAttribute("userinfo") UserInfo userinfo, @ModelAttribute("mocrid") String mocrid, @RequestParam String objclscount, Model model) {
ArrayList<ObjectClass> objclsList = ojbclslisttype.getObjectclasslist(); ArrayList<ObjectClass> objclsList = ojbclslisttype.getObjectClasses();
// for(int i=1;i<Integer.parseInt(objclscount)+1;i++){ // for(int i=1;i<Integer.parseInt(objclscount)+1;i++){
...@@ -91,7 +91,7 @@ public class ObjectClassFormController { ...@@ -91,7 +91,7 @@ public class ObjectClassFormController {
// } // }
ojbclslisttype.setObjectclasslist(objclsList); ojbclslisttype.setObjectClasses(objclsList);
model.addAttribute("ojbclslisttype", ojbclslisttype); model.addAttribute("ojbclslisttype", ojbclslisttype);
} }
...@@ -109,7 +109,7 @@ public class ObjectClassFormController { ...@@ -109,7 +109,7 @@ public class ObjectClassFormController {
return null; return null;
} }
ArrayList<ObjectClass> objclsList = ojbclslisttype.getObjectclasslist(); ArrayList<ObjectClass> objclsList = ojbclslisttype.getObjectClasses();
try { try {
ocdv.checkData(objclsList); ocdv.checkData(objclsList);
...@@ -151,7 +151,7 @@ public class ObjectClassFormController { ...@@ -151,7 +151,7 @@ public class ObjectClassFormController {
subjectsb.append(mocrid); subjectsb.append(mocrid);
subjectsb.append(" for "); subjectsb.append(" for ");
for(ObjectClass objcls:objclsList){ for(ObjectClass objcls:objclsList){
subjectsb.append(objcls.getAbbrev()); subjectsb.append(objcls.getAbbreviation());
} }
StringBuffer textsb = new StringBuffer(); StringBuffer textsb = new StringBuffer();
......
...@@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.request.WebRequest; import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.spring.mvc.mini.json.RequestStatusJsonMapping; import com.spring.mvc.mini.json.RequestStatusJsonParser;
import com.spring.mvc.mini.mail.MailSender; import com.spring.mvc.mini.mail.MailSender;
import com.spring.mvc.mini.pojo.RequestStatusListType; import com.spring.mvc.mini.pojo.RequestStatusListType;
import com.spring.mvc.mini.pojo.UserInfo; import com.spring.mvc.mini.pojo.UserInfo;
...@@ -34,7 +34,7 @@ public class RequestStatusController { ...@@ -34,7 +34,7 @@ public class RequestStatusController {
static Logger LOGGER = LoggerFactory.getLogger(RequestStatusController.class); static Logger LOGGER = LoggerFactory.getLogger(RequestStatusController.class);
@Autowired @Autowired
RequestStatusJsonMapping rsjm; RequestStatusJsonParser rsjm;
@Autowired @Autowired
MailSender ms; MailSender ms;
......
...@@ -78,13 +78,13 @@ public class ObjectClassXMLPaser { ...@@ -78,13 +78,13 @@ public class ObjectClassXMLPaser {
if (node instanceof Element) { if (node instanceof Element) {
objcls.setId(((Element) node).getAttribute("id").toString()); objcls.setId(((Element) node).getAttribute("id").toString());
objcls.setAbbrev(((Element) node).getAttribute("abbrev") objcls.setAbbreviation(((Element) node).getAttribute("abbrev")
.toString()); .toString());
objcls.setIntclass(Integer.parseInt(((Element) node).getAttribute("intclass"))); objcls.setIntclass(Integer.parseInt(((Element) node).getAttribute("intclass")));
objcls.setName(((Element) node).getAttribute("name").toString()); objcls.setName(((Element) node).getAttribute("name").toString());
objcls.setParents(((Element) node).getAttribute("parents") objcls.setParents(((Element) node).getAttribute("parents")
.toString()); .toString());
objcls.setAdaID(((Element) node).getAttribute("adaID") objcls.setPackageName(((Element) node).getAttribute("adaID")
.toString()); .toString());
elementcount++; elementcount++;
objclsList.add(objcls); objclsList.add(objcls);
...@@ -123,8 +123,8 @@ public class ObjectClassXMLPaser { ...@@ -123,8 +123,8 @@ public class ObjectClassXMLPaser {
Element objclselement = document.createElement("objclass"); Element objclselement = document.createElement("objclass");
objclselement.setAttribute("id", objcls.getId()); objclselement.setAttribute("id", objcls.getId());
objclselement.setAttribute("intclass", String.valueOf(objcls.getIntclass())); objclselement.setAttribute("intclass", String.valueOf(objcls.getIntclass()));
objclselement.setAttribute("abbrev", objcls.getAbbrev()); objclselement.setAttribute("abbrev", objcls.getAbbreviation());
objclselement.setAttribute("adaID", objcls.getAdaID()); objclselement.setAttribute("adaID", objcls.getPackageName());
objclselement.setAttribute("name", objcls.getName()); objclselement.setAttribute("name", objcls.getName());
objclselement.setAttribute("parents", objcls.getParents()); objclselement.setAttribute("parents", objcls.getParents());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册