@@ -7,15 +7,7 @@ import com.github.nscala_time.time.Imports._
77import DateTimeConverters ._
88import DurationConverter ._
99import GeoPointConverters ._
10- import eu .ochp ._1 .{
11- ConnectorType => GenConnectorType ,
12- EvseImageUrlType => GenEvseImageUrlType ,
13- CdrStatusType => GenCdrStatusType ,
14- ConnectorFormat => GenConnectorFormat ,
15- ConnectorStandard => GenConnectorStandard ,
16- CdrPeriodType => GenCdrPeriodType ,
17- BillingItemType => GenBillingItemType ,
18- EvseStatusType => GetEvseStatusType , _ }
10+ import eu .ochp .{_1 => Gen }
1911import org .slf4j .LoggerFactory
2012import scala .util .{Try , Success , Failure }
2113import scala .language .{implicitConversions , postfixOps }
@@ -53,7 +45,7 @@ object Converters extends Common {
5345
5446 private val logger = LoggerFactory .getLogger(Converters .getClass)
5547
56- implicit def roamingAuthorisationInfoToToken (rai : RoamingAuthorisationInfo ): ChargeToken = {
48+ implicit def roamingAuthorisationInfoToToken (rai : Gen . RoamingAuthorisationInfo ): ChargeToken = {
5749 ChargeToken (
5850 contractId = rai.getContractId,
5951 emtId = EmtIdConverter .fromOchp(rai.getEmtId),
@@ -62,16 +54,16 @@ object Converters extends Common {
6254 )
6355 }
6456
65- implicit def tokenToRoamingAuthorisationInfo (token : ChargeToken ): RoamingAuthorisationInfo = {
66- val rai = new RoamingAuthorisationInfo ()
57+ implicit def tokenToRoamingAuthorisationInfo (token : ChargeToken ): Gen . RoamingAuthorisationInfo = {
58+ val rai = new Gen . RoamingAuthorisationInfo
6759 rai.setContractId(token.contractId)
6860 rai.setEmtId(EmtIdConverter .toOchp(token.emtId))
6961 token.printedNumber.foreach(pn => rai.setPrintedNumber(pn.toString))
7062 rai.setExpiryDate(Utc .toOchp(token.expiryDate))
7163 rai
7264 }
7365
74- private def toRegularHours (rh : RegularHoursType ): Option [RegularHours ] = {
66+ private def toRegularHours (rh : Gen . RegularHoursType ): Option [RegularHours ] = {
7567
7668 val normalize : PartialFunction [String , String ] = {
7769 case " 24:00" => " 23:59"
@@ -90,14 +82,14 @@ object Converters extends Common {
9082 } yield RegularHours (rh.getWeekday, beg, end)
9183 }
9284
93- private def toChargePointStatusOption (value : ChargePointStatusType ): Option [ChargePointStatus ] =
85+ private def toChargePointStatusOption (value : Gen . ChargePointStatusType ): Option [ChargePointStatus ] =
9486 Option (value).flatMap(v => Try (ChargePointStatus .withName(v.getChargePointStatusType)) match {
9587 case Success (x) => Some (x)
9688 case Failure (e) => logger.error(" Charge point status parsing failure" , e); None
9789 })
9890
99- private [ochp] def regularOpeningsAreDefined (value : HoursType ) = {
100- def prettyPrint (ht : HoursType ) =
91+ private [ochp] def regularOpeningsAreDefined (value : Gen . HoursType ) = {
92+ def prettyPrint (ht : Gen . HoursType ) =
10193 s """ HoursType(
10294 |regularHours = ${ht.getRegularHours},
10395 | twentyfourseven = ${ht.isTwentyfourseven},
@@ -120,43 +112,43 @@ object Converters extends Common {
120112 else Success (value)
121113 }
122114
123- private [ochp] def toHoursOption (value : HoursType ): Try [Option [Hours ]] = {
124- def toPeriod (ept : ExceptionalPeriodType ) =
115+ private [ochp] def toHoursOption (value : Gen . HoursType ): Try [Option [Hours ]] = {
116+ def toPeriod (ept : Gen . ExceptionalPeriodType ) =
125117 ExceptionalPeriod (
126118 Utc .fromOchp(ept.getPeriodBegin),
127119 Utc .fromOchp(ept.getPeriodEnd))
128120
129- def fromJava (v : HoursType ) =
121+ def fromJava (v : Gen . HoursType ) =
130122 Hours (
131123 regularHoursOrTwentyFourSeven = regularHours(v),
132124 exceptionalOpenings =
133125 v.getExceptionalOpenings.asScala.toList.map(toPeriod),
134126 exceptionalClosings =
135127 v.getExceptionalClosings.asScala.toList.map(toPeriod))
136128
137- def regularHours (v : HoursType ): Either [List [RegularHours ], Boolean ] =
129+ def regularHours (v : Gen . HoursType ): Either [List [RegularHours ], Boolean ] =
138130 Option (v.isTwentyfourseven)
139131 .map(tfs => Right (tfs == true ))
140132 .getOrElse(Left (v.getRegularHours.asScala.toList.flatMap(toRegularHours)))
141133
142134 safeReadWith(value)(regularOpeningsAreDefined(_).map(fromJava))
143135 }
144136
145- implicit def cdrToCdrInfo (cdr : CDR ): CDRInfo = {
137+ implicit def cdrToCdrInfo (cdr : CDR ): Gen . CDRInfo = {
146138 def ifNonEmptyThen (opt : Option [String ])(f : String => Unit ) =
147139 opt.filter(_.nonEmpty).foreach(f)
148140
149141 import cdr ._
150- val cdrInfo = new CDRInfo
142+ val cdrInfo = new Gen . CDRInfo
151143 ifNonEmptyThen(cdr.address)(cdrInfo.setAddress)
152144 cdrInfo.setCdrId(cdr.cdrId)
153145 cdrInfo.setChargePointType(cdr.chargePointType)
154146
155- val cType = new GenConnectorType ()
156- val cFormat = new GenConnectorFormat ()
147+ val cType = new Gen . ConnectorType
148+ val cFormat = new Gen . ConnectorFormat
157149 cFormat.setConnectorFormat(cdr.connectorType.connectorFormat.toString)
158150 cType.setConnectorFormat(cFormat)
159- val cStandard = new GenConnectorStandard ()
151+ val cStandard = new Gen . ConnectorStandard
160152 cStandard.setConnectorStandard(cdr.connectorType.connectorStandard.toString)
161153 cType.setConnectorStandard(cStandard)
162154 cdrInfo.setConnectorType(cType)
@@ -176,19 +168,19 @@ object Converters extends Common {
176168 ifNonEmptyThen(cdr.meterId)(cdrInfo.setMeterId)
177169 ifNonEmptyThen(cdr.productType)(cdrInfo.setProductType)
178170
179- val cdrStatus = new GenCdrStatusType ()
171+ val cdrStatus = new Gen . CdrStatusType
180172 cdrStatus.setCdrStatusType(cdr.status.toString)
181173 cdrInfo.setStatus(cdrStatus)
182174 cdrInfo.getChargingPeriods.addAll(
183175 cdr.chargingPeriods.map {chargePeriodToGenCp} asJavaCollection)
184176 cdrInfo
185177 }
186178
187- private def chargePeriodToGenCp (gcp : CdrPeriod ): GenCdrPeriodType = {
188- val period1 = new GenCdrPeriodType ()
179+ private def chargePeriodToGenCp (gcp : CdrPeriod ): Gen . CdrPeriodType = {
180+ val period1 = new Gen . CdrPeriodType
189181 period1.setStartDateTime(WithOffset .toOchp(gcp.startDateTime))
190182 period1.setEndDateTime(WithOffset .toOchp(gcp.endDateTime))
191- val billingItem = new GenBillingItemType ()
183+ val billingItem = new Gen . BillingItemType
192184 billingItem.setBillingItemType(gcp.billingItem.toString)
193185 period1.setBillingItem(billingItem)
194186 period1.setBillingValue(gcp.billingValue)
@@ -201,7 +193,7 @@ object Converters extends Common {
201193 private def toDateTimeZone (tz : String ): Try [Option [DateTimeZone ]] =
202194 safeRead(tz)(DateTimeZone .forID)
203195
204- implicit def cpInfoToChargePoint (genCp : ChargePointInfo ): Option [ChargePoint ] = {
196+ implicit def cpInfoToChargePoint (genCp : Gen . ChargePointInfo ): Option [ChargePoint ] = {
205197 val cp = for {
206198 openingHours <- toHoursOption(genCp.getOperatingTimes)
207199 accessHours <- toHoursOption(genCp.getAccessTimes)
@@ -265,8 +257,8 @@ object Converters extends Common {
265257 }
266258 }
267259
268- private def imagesToGenImages (image : EvseImageUrl ): GenEvseImageUrlType = {
269- val iut = new GenEvseImageUrlType ()
260+ private def imagesToGenImages (image : EvseImageUrl ): Gen . EvseImageUrlType = {
261+ val iut = new Gen . EvseImageUrlType
270262 iut.setClazz(image.clazz.toString)
271263 image.height foreach iut.setHeight
272264 image.width foreach iut.setWidth
@@ -276,24 +268,24 @@ object Converters extends Common {
276268 iut
277269 }
278270
279- private [ochp] def hoursOptionToHoursType (maybeHours : Option [Hours ]): HoursType = {
280- def regHoursToRegHoursType (regHours : RegularHours ): RegularHoursType = {
281- val regularHoursType = new RegularHoursType ()
271+ private [ochp] def hoursOptionToHoursType (maybeHours : Option [Hours ]): Gen . HoursType = {
272+ def regHoursToRegHoursType (regHours : RegularHours ): Gen . RegularHoursType = {
273+ val regularHoursType = new Gen . RegularHoursType
282274 regularHoursType.setWeekday(regHours.weekday)
283275 regularHoursType.setPeriodBegin(regHours.periodBegin.toString)
284276 regularHoursType.setPeriodEnd(regHours.periodEnd.toString)
285277 regularHoursType
286278 }
287279
288- def excPeriodToExcPeriodType (ep : ExceptionalPeriod ): ExceptionalPeriodType = {
289- val ept = new ExceptionalPeriodType ()
280+ def excPeriodToExcPeriodType (ep : ExceptionalPeriod ): Gen . ExceptionalPeriodType = {
281+ val ept = new Gen . ExceptionalPeriodType
290282 ept.setPeriodBegin(Utc .toOchp(ep.periodBegin))
291283 ept.setPeriodEnd(Utc .toOchp(ep.periodEnd))
292284 ept
293285 }
294286
295287 maybeHours.map { hours =>
296- val hoursType = new HoursType ()
288+ val hoursType = new Gen . HoursType
297289
298290 hours.regularHoursOrTwentyFourSeven.fold(
299291 regHours =>
@@ -310,31 +302,31 @@ object Converters extends Common {
310302 }.getOrElse(null )
311303 }
312304
313- private def parkRestrToGenParkRestr (pRestr : ParkingRestriction .Value ): ParkingRestrictionType = {
314- val prt = new ParkingRestrictionType ()
305+ private def parkRestrToGenParkRestr (pRestr : ParkingRestriction .Value ): Gen . ParkingRestrictionType = {
306+ val prt = new Gen . ParkingRestrictionType
315307 prt.setParkingRestrictionType(pRestr.toString)
316308 prt
317309 }
318310
319- private def authMethodToGenAuthMethod (authMethod : AuthMethod .Value ): AuthMethodType = {
320- val amt = new AuthMethodType ()
311+ private def authMethodToGenAuthMethod (authMethod : AuthMethod .Value ): Gen . AuthMethodType = {
312+ val amt = new Gen . AuthMethodType
321313 amt.setAuthMethodType(authMethod.toString)
322314 amt
323315 }
324316
325- private def connToGenConn (connector : Connector ): GenConnectorType = {
326- val ct = new GenConnectorType ()
327- val cs = new GenConnectorStandard ()
328- val cf = new GenConnectorFormat ()
317+ private def connToGenConn (connector : Connector ): Gen . ConnectorType = {
318+ val ct = new Gen . ConnectorType
319+ val cs = new Gen . ConnectorStandard
320+ val cf = new Gen . ConnectorFormat
329321 cs.setConnectorStandard(connector.connectorStandard.toString)
330322 ct.setConnectorStandard(cs)
331323 cf.setConnectorFormat(connector.connectorFormat.toString)
332324 ct.setConnectorFormat(cf)
333325 ct
334326 }
335327
336- implicit def chargePointToCpInfo (cp : ChargePoint ): ChargePointInfo = {
337- val cpi = new ChargePointInfo ()
328+ implicit def chargePointToCpInfo (cp : ChargePoint ): Gen . ChargePointInfo = {
329+ val cpi = new Gen . ChargePointInfo
338330 cpi.setEvseId(cp.evseId.value)
339331 cpi.setLocationId(cp.locationId)
340332 cp.timestamp foreach {t =>
@@ -357,13 +349,13 @@ object Converters extends Common {
357349 cpi.setOperatingTimes(hoursOptionToHoursType(cp.operatingTimes))
358350 cpi.setAccessTimes(hoursOptionToHoursType(cp.accessTimes))
359351 cp.status.foreach { st =>
360- val status = new ChargePointStatusType ()
352+ val status = new Gen . ChargePointStatusType
361353 status.setChargePointStatusType(st.toString)
362354 cpi.setStatus(status)
363355 }
364356 cpi.getStatusSchedule.addAll(cp.statusSchedule.map(ChargePointScheduleConverter .toOchp).asJavaCollection)
365357 cp.telephoneNumber foreach cpi.setTelephoneNumber
366- cpi.setLocation(new GeneralLocationType {
358+ cpi.setLocation(new Gen . GeneralLocationType {
367359 setGeneralLocationType(cp.location.toString)
368360 })
369361 cp.floorLevel foreach cpi.setFloorLevel
@@ -376,7 +368,7 @@ object Converters extends Common {
376368 cpi
377369 }
378370
379- implicit def toEvseStatus (s : GetEvseStatusType ): Option [EvseStatus ] = Try {
371+ implicit def toEvseStatus (s : Gen . EvseStatusType ): Option [EvseStatus ] = Try {
380372 EvseStatus (
381373 evseId = EvseId (s.getEvseId),
382374 majorStatus = EvseStatusMajor .findByName(s.getMajor).getOrElse(EvseStatusMajor .unknown),
0 commit comments