Search in sources :

Example 1 with DataGenerator

use of spold2.DataGenerator in project olca-modules by GreenDelta.

the class ProcessDoc method mapPublication.

private void mapPublication(DataGenerator generator) {
    if (doc.publication == null)
        return;
    Source source = addSource(doc.publication);
    generator.publishedSourceId = source.id;
    generator.publishedSourceFirstAuthor = source.firstAuthor;
    generator.publishedSourceYear = source.year;
}
Also used : Source(spold2.Source)

Example 2 with DataGenerator

use of spold2.DataGenerator in project olca-modules by GreenDelta.

the class DocImportMapper method mapPublicationSource.

private void mapPublicationSource(AdminInfo adminInfo) {
    DataGenerator gen = adminInfo.dataGenerator;
    if (gen == null || gen.publishedSourceId == null)
        return;
    SourceDao dao = new SourceDao(database);
    Source source = dao.getForRefId(gen.publishedSourceId);
    if (source == null) {
        source = new Source();
        source.refId = gen.publishedSourceId;
        StringBuilder title = new StringBuilder();
        StringBuilder shortTitle = new StringBuilder();
        if (gen.publishedSourceFirstAuthor != null) {
            title.append(gen.publishedSourceFirstAuthor);
            shortTitle.append(gen.publishedSourceFirstAuthor);
        }
        if (gen.publishedSourceYear != null) {
            title.append(gen.publishedSourceYear);
            shortTitle.append(gen.publishedSourceYear);
        }
        source.textReference = title.toString();
        source.name = shortTitle.toString();
        source = dao.insert(source);
    }
    doc.publication = source;
}
Also used : SourceDao(org.openlca.core.database.SourceDao) DataGenerator(spold2.DataGenerator) Source(org.openlca.core.model.Source)

Example 3 with DataGenerator

use of spold2.DataGenerator in project olca-modules by GreenDelta.

the class DocImportMapper method mapDataGenerator.

private void mapDataGenerator(AdminInfo adminInfo) {
    DataGenerator dataGenerator = adminInfo.dataGenerator;
    if (dataGenerator == null || dataGenerator.personId == null)
        return;
    ActorDao dao = new ActorDao(database);
    Actor actor = dao.getForRefId(dataGenerator.personId);
    if (actor == null) {
        actor = new Actor();
        actor.refId = dataGenerator.personId;
        actor.email = dataGenerator.personEmail;
        actor.name = dataGenerator.personName;
        actor = dao.insert(actor);
    }
    doc.dataGenerator = actor;
}
Also used : ActorDao(org.openlca.core.database.ActorDao) DataGenerator(spold2.DataGenerator) Actor(org.openlca.core.model.Actor)

Example 4 with DataGenerator

use of spold2.DataGenerator in project olca-modules by GreenDelta.

the class ProcessDoc method mapDataGenerator.

private void mapDataGenerator(AdminInfo adminInfo) {
    DataGenerator generator = new DataGenerator();
    adminInfo.dataGenerator = generator;
    generator.isCopyrightProtected = doc.copyright;
    mapPublication(generator);
    Actor actor = doc.dataGenerator;
    if (actor == null) {
        generator.personEmail = "no@email.com";
        generator.personId = "788d0176-a69c-4de0-a5d3-259866b6b100";
        generator.personName = "[Current User]";
    } else {
        Person person = addPerson(actor);
        generator.personEmail = person.email;
        generator.personId = person.id;
        generator.personName = person.email;
    }
}
Also used : DataGenerator(spold2.DataGenerator) Actor(org.openlca.core.model.Actor) Person(spold2.Person)

Aggregations

DataGenerator (spold2.DataGenerator)3 Actor (org.openlca.core.model.Actor)2 ActorDao (org.openlca.core.database.ActorDao)1 SourceDao (org.openlca.core.database.SourceDao)1 Source (org.openlca.core.model.Source)1 Person (spold2.Person)1 Source (spold2.Source)1