1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.fit.core.reference;
20
21 import java.util.List;
22 import org.apache.commons.lang3.tuple.Pair;
23 import org.apache.syncope.common.lib.to.Item;
24 import org.apache.syncope.common.lib.types.AttrSchemaType;
25 import org.apache.syncope.core.persistence.api.entity.Any;
26 import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
27 import org.apache.syncope.core.provisioning.api.data.ItemTransformer;
28 import org.apache.syncope.core.spring.implementation.InstanceScope;
29 import org.apache.syncope.core.spring.implementation.SyncopeImplementation;
30
31 @SyncopeImplementation(scope = InstanceScope.PER_CONTEXT)
32 public class DateToLongItemTransformer implements ItemTransformer {
33
34 @Override
35 public Pair<AttrSchemaType, List<PlainAttrValue>> beforePropagation(
36 final Item item,
37 final Any<?> any,
38 final AttrSchemaType schemaType,
39 final List<PlainAttrValue> values) {
40
41 if (values == null || values.isEmpty() || values.get(0).getDateValue() == null) {
42 return ItemTransformer.super.beforePropagation(item, any, schemaType, values);
43 }
44
45 values.get(0).setLongValue(values.get(0).getDateValue().toInstant().toEpochMilli());
46 values.get(0).setBinaryValue(null);
47 values.get(0).setBooleanValue(null);
48 values.get(0).setDateValue(null);
49 values.get(0).setDoubleValue(null);
50 values.get(0).setStringValue(null);
51
52 return Pair.of(AttrSchemaType.Long, values);
53 }
54 }