Search in sources :

Example 26 with BwLocation

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();
    }
}
Also used : BwLocation(org.bedework.calfacade.BwLocation) CSVParser(org.apache.commons.csv.CSVParser) FileReader(java.io.FileReader) CSVRecord(org.apache.commons.csv.CSVRecord) File(java.io.File)

Example 27 with BwLocation

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();
    }
}
Also used : BwLocation(org.bedework.calfacade.BwLocation)

Example 28 with BwLocation

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();
    }
}
Also used : BwLocation(org.bedework.calfacade.BwLocation)

Aggregations

BwLocation (org.bedework.calfacade.BwLocation)28 BwString (org.bedework.calfacade.BwString)11 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)10 BwContact (org.bedework.calfacade.BwContact)9 BwEvent (org.bedework.calfacade.BwEvent)9 BwCategory (org.bedework.calfacade.BwCategory)8 BwXproperty (org.bedework.calfacade.BwXproperty)4 Period (net.fortuna.ical4j.model.Period)3 BwAttendee (org.bedework.calfacade.BwAttendee)3 EventInfo (org.bedework.calfacade.svc.EventInfo)3 File (java.io.File)2 Parameter (net.fortuna.ical4j.model.Parameter)2 XParameter (net.fortuna.ical4j.model.parameter.XParameter)2 BwAttachment (org.bedework.calfacade.BwAttachment)2 BwDateTime (org.bedework.calfacade.BwDateTime)2 BwEventProxy (org.bedework.calfacade.BwEventProxy)2 BwFreeBusyComponent (org.bedework.calfacade.BwFreeBusyComponent)2 BwGeo (org.bedework.calfacade.BwGeo)2 BwOrganizer (org.bedework.calfacade.BwOrganizer)2 BwRelatedTo (org.bedework.calfacade.BwRelatedTo)2