use of org.bedework.calfacade.BwLocation in project bw-calendar-engine by Bedework.
the class ProcessCreate method createLocationsCsv.
private boolean createLocationsCsv() throws Throwable {
try {
open();
final String fileName = quotedVal();
if (fileName == null) {
error("Expected csv filename");
return false;
}
final File csvf = new File(fileName);
if (!csvf.exists()) {
error("File " + fileName + " does not exist");
return false;
}
final CSVParser parser = CSVFormat.DEFAULT.withHeader().withAllowMissingColumnNames().parse(new FileReader(csvf));
for (final CSVRecord rec : parser) {
final BwLocation loc = BwLocation.makeLocation();
String fld = rec.get("Address");
if (fld == null) {
error("address required for location");
continue;
}
loc.setAddressField(fld);
fld = rec.get("Room");
if (fld != null) {
loc.setRoomField(fld);
}
fld = rec.get("Code");
if (fld != null) {
loc.setCode(fld);
}
fld = rec.get("alternateAddress");
if (fld != null) {
loc.setAlternateAddress(fld);
}
fld = rec.get("Accessible");
if (fld != null) {
loc.setAccessible("Y".equals(fld));
}
fld = rec.get("oldCode");
if (fld != null) {
loc.setSubField1(fld);
}
fld = rec.get("Street");
if (fld != null) {
loc.setStreet(fld);
}
fld = rec.get("City");
if (fld != null) {
loc.setCity(fld);
}
fld = rec.get("State");
if (fld != null) {
loc.setState(fld);
}
fld = rec.get("Zip");
if (fld != null) {
loc.setZip(fld);
}
fld = rec.get("Link");
if (fld != null) {
loc.setLink(fld);
}
getSvci().getLocationsHandler().add(loc);
}
return true;
} finally {
close();
}
}
use of org.bedework.calfacade.BwLocation in project bw-calendar-engine by Bedework.
the class ProcessCreate method createLocation.
private boolean createLocation() throws Throwable {
try {
open();
final BwLocation loc = BwLocation.makeLocation();
if (!testToken("address")) {
error("address required for location");
}
assertToken('=');
loc.setAddressField(quotedVal());
if (testToken("room")) {
assertToken('=');
loc.setRoomField(quotedVal());
}
if (testToken("subField1")) {
assertToken('=');
loc.setSubField1(quotedVal());
}
if (testToken("subField2")) {
assertToken('=');
loc.setSubField1(quotedVal());
}
if (testToken("accessible")) {
loc.setAccessible(true);
}
if (testToken("geouri")) {
assertToken('=');
loc.setGeouri(quotedVal());
}
if (testToken("street")) {
assertToken('=');
loc.setStreet(quotedVal());
}
if (testToken("city")) {
assertToken('=');
loc.setCity(quotedVal());
}
if (testToken("state")) {
assertToken('=');
loc.setState(quotedVal());
}
if (testToken("zip")) {
assertToken('=');
loc.setZip(quotedVal());
}
if (testToken("link")) {
assertToken('=');
loc.setLink(quotedVal());
}
getSvci().getLocationsHandler().add(loc);
return true;
} finally {
close();
}
}
use of org.bedework.calfacade.BwLocation in project bw-calendar-engine by Bedework.
the class ProcessDelete method deleteLocation.
private boolean deleteLocation() throws Throwable {
final String wd = word();
if (!"uid".equals(wd) || !testToken('=')) {
addError("Expected \"uid\"=");
return true;
}
final String uid = qstringFor("delete location");
if (uid == null) {
addError("Must supply uid");
return true;
}
try {
open();
final BwLocation loc = getSvci().getLocationsHandler().getPersistent(uid);
if (loc == null) {
addError("Location " + uid + " not found");
return false;
}
getSvci().getLocationsHandler().delete(loc);
return true;
} finally {
close();
}
}
Aggregations