eu.agrosense.client.activity.mapping.ActivityTarget Maven / Gradle / Ivy
The newest version!
/**
* Copyright (C) 2008-2013 LimeTri. All rights reserved.
*
* AgroSense is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* There are special exceptions to the terms and conditions of the GPLv3 as it
* is applied to this software, see the FLOSS License Exception
* .
*
* AgroSense is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* AgroSense. If not, see .
*/
package eu.agrosense.client.activity.mapping;
import eu.agrosense.api.mapping.AttributeDescriptor;
import eu.agrosense.api.mapping.MappableSource;
import eu.agrosense.api.mapping.Mapper;
import eu.agrosense.api.mapping.Mapping;
import eu.agrosense.api.mapping.MappingTarget;
import eu.agrosense.api.mapping.TargetAttributeDescriptor;
import java.util.Collection;
import org.openide.util.lookup.ServiceProvider;
/**
*
* @author johan
*/
@ServiceProvider(service = MappingTarget.class)
public class ActivityTarget implements MappingTarget {
public static final String TARGET_ID = "ACTIVITY LIST";
public static final int TARGET_VERSION = 1;
@Override
public String getId() {
return TARGET_ID;
}
@Override
public long getVersion() {
return TARGET_VERSION;
}
@Override
public String getDescription() {
return "Activity list";
}
@Override
public Collection getAttributeDescriptors() {
return AttributeDescriptor.extract(Attribute.values());
}
@Override
public Mapper createMapper(Mapping mapping, MappableSource source) {
return new ActivityMapper(source, mapping);
}
public enum Attribute implements AttributeDescriptor.Provider {
FARM_URI("Farm URI", String.class, true),
NAME("Activity name", String.class, true),
DESCRIPTION("Activity description", String.class, true),
// current mapper impl expects column attr for code, and constants for system & table:
SOURCE_REF_SYSTEM("source reference system", String.class, true),
SOURCE_REF_TABLE("source reference table", String.class, true),
SOURCE_REF_CODE("source reference code", String.class, true),
//
DATE_START("Date start", String.class, false),
DATE_END("Date end", String.class, false),
;
private final TargetAttributeDescriptor descriptor;
private Attribute(String name, Class> clazz, boolean required) {
this.descriptor = new TargetAttributeDescriptor(name, clazz, required);
}
@Override
public TargetAttributeDescriptor getDescriptor() {
return descriptor;
}
}
}