use of org.codehaus.jackson.annotate.JsonProperty in project openhab1-addons by openhab.
the class SystemsResponse method getOperational_at.
/**
* "operational_at": 1304566098
*/
@JsonProperty("operational_at")
public Calendar getOperational_at() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(this.operational_at * 1000);
return calendar;
}
use of org.codehaus.jackson.annotate.JsonProperty in project oxTrust by GluuFederation.
the class SchemaWebService method getSchemaInstance.
private SchemaResource getSchemaInstance(Class<? extends BaseScimResource> clazz) throws Exception {
SchemaResource resource;
Class<? extends BaseScimResource> schemaCls = SchemaResource.class;
Schema annotation = ScimResourceUtil.getSchemaAnnotation(clazz);
if (!clazz.equals(schemaCls) && annotation != null) {
Meta meta = new Meta();
meta.setResourceType(ScimResourceUtil.getType(schemaCls));
meta.setLocation(endpointUrl + "/" + annotation.id());
resource = new SchemaResource();
resource.setId(annotation.id());
resource.setName(annotation.name());
resource.setDescription(annotation.description());
resource.setMeta(meta);
List<SchemaAttribute> attribs = new ArrayList<SchemaAttribute>();
// paths are, happily alphabetically sorted :)
for (String path : IntrospectUtil.allAttrs.get(clazz)) {
SchemaAttribute schAttr = new SchemaAttribute();
Field f = IntrospectUtil.findFieldFromPath(clazz, path);
Attribute attrAnnot = f.getAnnotation(Attribute.class);
if (attrAnnot != null) {
JsonProperty jsonAnnot = f.getAnnotation(JsonProperty.class);
schAttr.setName(jsonAnnot == null ? f.getName() : jsonAnnot.value());
schAttr.setType(attrAnnot.type().getName());
schAttr.setMultiValued(!attrAnnot.multiValueClass().equals(NullType.class) || IntrospectUtil.isCollection(f.getType()));
schAttr.setDescription(attrAnnot.description());
schAttr.setRequired(attrAnnot.isRequired());
schAttr.setCanonicalValues(attrAnnot.canonicalValues().length == 0 ? null : Arrays.asList(attrAnnot.canonicalValues()));
schAttr.setCaseExact(attrAnnot.isCaseExact());
schAttr.setMutability(attrAnnot.mutability().getName());
schAttr.setReturned(attrAnnot.returned().getName());
schAttr.setUniqueness(attrAnnot.uniqueness().getName());
schAttr.setReferenceTypes(attrAnnot.referenceTypes().length == 0 ? null : Arrays.asList(attrAnnot.referenceTypes()));
if (attrAnnot.type().equals(AttributeDefinition.Type.COMPLEX))
schAttr.setSubAttributes(new ArrayList<SchemaAttribute>());
// root list
List<SchemaAttribute> list = attribs;
String[] parts = path.split("\\.");
for (int i = 0; i < parts.length - 1; i++) {
// skip last part (real attribute name)
int j = list.indexOf(new SchemaAttribute(parts[i]));
list = list.get(j).getSubAttributes();
}
list.add(schAttr);
}
}
resource.setAttributes(attribs);
} else
resource = null;
return resource;
}
use of org.codehaus.jackson.annotate.JsonProperty in project openhab1-addons by openhab.
the class SystemsResponse method getLast_report_at.
/**
* "last_report_at": 1424743838
*/
@JsonProperty("last_report_at")
public Calendar getLast_report_at() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(this.last_report_at * 1000);
return calendar;
}
use of org.codehaus.jackson.annotate.JsonProperty in project openhab1-addons by openhab.
the class SystemsResponse method getSummary_date.
/**
* "summary_date": "2015-02-23"
*/
@JsonProperty("summary_date")
public Calendar getSummary_date() {
final SimpleDateFormat format = new SimpleDateFormat(enphaseDateFormatString);
Calendar calendar = Calendar.getInstance();
try {
Date date = format.parse(this.summary_date);
calendar.setTime(date);
} catch (ParseException e) {
logger.debug("summary_date {} has an unknown format", this.summary_date);
}
return calendar;
}
Aggregations