Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1016 - working annotation processor, default schema, update message …
…types to include domain fields
- Loading branch information
Showing
17 changed files
with
230 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Domain-metadata-version:default | ||
org.powertac.common.Order:broker,timeslot,MWh,limitPrice | ||
org.powertac.common.DistributionTransaction:postedTimeslot,NSmall,NLarge,KWh,charge | ||
org.powertac.common.RegulationRate:tariffId,response,upRegulationPayment,downRegulationPayment | ||
org.powertac.common.msg.EconomicControlEvent:tariffId,curtailmentRatio,timeslotIndex | ||
org.powertac.common.msg.VariableRateUpdate:broker,tariffId,payload,rateId | ||
org.powertac.common.msg.TariffExpire:broker,tariffId,newExpiration | ||
org.powertac.common.msg.DistributionReport:timeslot,totalConsumption,totalProduction | ||
org.powertac.common.Rate:tariffId,weeklyBegin,weeklyEnd,dailyBegin,dailyEnd,tierThreshold,fixed,minValue,maxValue,noticeInterval,expectedMean,maxCurtailment | ||
org.powertac.common.msg.BalancingOrder:exerciseRatio,price,tariffId,broker | ||
org.powertac.common.msg.OrderStatus:broker,orderId,status | ||
org.powertac.common.msg.TariffStatus:broker,tariffId,updateId,status | ||
org.powertac.common.HourlyCharge:rateId,value,atTime | ||
org.powertac.common.msg.TariffRevoke:broker,tariffId | ||
org.powertac.common.BalancingTransaction:postedTimeslot,kWh,charge | ||
org.powertac.common.TariffSpecification:broker,powerType,minDuration,signupPayment,earlyWithdrawPayment,periodicPayment,supersedes | ||
org.powertac.common.MarketPosition:broker,timeslot,balance | ||
org.powertac.common.WeatherForecastPrediction:forecastTime,temperature,windSpeed,windDirection,cloudCover | ||
org.powertac.common.MarketTransaction:postedTimeslot,timeslot,MWh,price | ||
org.powertac.common.CapacityTransaction:postedTimeslot,peakTimeslot,threshold,KWh,charge | ||
org.powertac.common.msg.BalanceReport:timeslotIndex,newImbalance | ||
org.powertac.common.OrderbookOrder:mWh,limitPrice | ||
org.powertac.common.ClearedTrade:timeslot,executionMWh,executionPrice,dateExecuted | ||
org.powertac.common.CashPosition:postedTimeslot,balance | ||
org.powertac.common.BankTransaction:postedTimeslot,amount | ||
org.powertac.common.Orderbook:timeslot,clearingPrice,dateExecuted | ||
org.powertac.common.WeatherReport:timeslot,temperature,windSpeed,windDirection,cloudCover | ||
org.powertac.common.msg.BalancingControlEvent:tariffId,kwh,payment,timeslotIndex | ||
org.powertac.common.TariffTransaction:postedTimeslot,txType,customerInfo,customerCount,KWh,charge,regulation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Domain-schema-version:default | ||
org.powertac.common.Order:broker,timeslot,MWh,limitPrice | ||
org.powertac.common.DistributionTransaction:postedTimeslot,NSmall,NLarge,KWh,charge | ||
org.powertac.common.RegulationRate:tariffId,response,upRegulationPayment,downRegulationPayment | ||
org.powertac.common.msg.EconomicControlEvent:tariffId,curtailmentRatio,timeslotIndex | ||
org.powertac.common.msg.VariableRateUpdate:broker,tariffId,payload,rateId | ||
org.powertac.common.msg.TariffExpire:broker,tariffId,newExpiration | ||
org.powertac.common.msg.DistributionReport:timeslot,totalConsumption,totalProduction | ||
org.powertac.common.Rate:tariffId,weeklyBegin,weeklyEnd,dailyBegin,dailyEnd,tierThreshold,fixed,minValue,maxValue,noticeInterval,expectedMean,maxCurtailment | ||
org.powertac.common.msg.BalancingOrder:exerciseRatio,price,tariffId,broker | ||
org.powertac.common.msg.OrderStatus:broker,orderId,status | ||
org.powertac.common.msg.TariffStatus:broker,tariffId,updateId,status | ||
org.powertac.common.HourlyCharge:rateId,value,atTime | ||
org.powertac.common.msg.TariffRevoke:broker,tariffId | ||
org.powertac.common.BalancingTransaction:postedTimeslot,kWh,charge | ||
org.powertac.common.TariffSpecification:broker,powerType,minDuration,signupPayment,earlyWithdrawPayment,periodicPayment,supersedes | ||
org.powertac.common.MarketPosition:broker,timeslot,balance | ||
org.powertac.common.WeatherForecastPrediction:forecastTime,temperature,windSpeed,windDirection,cloudCover | ||
org.powertac.common.MarketTransaction:postedTimeslot,timeslot,MWh,price | ||
org.powertac.common.CapacityTransaction:postedTimeslot,peakTimeslot,threshold,KWh,charge | ||
org.powertac.common.msg.BalanceReport:timeslotIndex,newImbalance | ||
org.powertac.common.OrderbookOrder:mWh,limitPrice | ||
org.powertac.common.ClearedTrade:timeslot,executionMWh,executionPrice,dateExecuted | ||
org.powertac.common.CashPosition:postedTimeslot,balance | ||
org.powertac.common.BankTransaction:postedTimeslot,amount | ||
org.powertac.common.Orderbook:timeslot,clearingPrice,dateExecuted | ||
org.powertac.common.WeatherReport:timeslot,temperature,windSpeed,windDirection,cloudCover | ||
org.powertac.common.msg.BalancingControlEvent:tariffId,kwh,payment,timeslotIndex | ||
org.powertac.common.TariffTransaction:postedTimeslot,txType,customerInfo,customerCount,KWh,charge,regulation | ||
schema.end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
powertac-metadata/src/main/java/org/powertac/metadata/DomainProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* Copyright (c) 2019 by John Collins | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.powertac.metadata; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import javax.annotation.processing.AbstractProcessor; | ||
import javax.annotation.processing.FilerException; | ||
import javax.annotation.processing.ProcessingEnvironment; | ||
import javax.annotation.processing.RoundEnvironment; | ||
import javax.annotation.processing.SupportedAnnotationTypes; | ||
import javax.annotation.processing.SupportedSourceVersion; | ||
import javax.lang.model.element.AnnotationMirror; | ||
import javax.lang.model.element.Element; | ||
import javax.lang.model.element.TypeElement; | ||
import javax.lang.model.type.TypeKind; | ||
import javax.lang.model.type.TypeMirror; | ||
import javax.lang.model.SourceVersion; | ||
import javax.tools.Diagnostic; | ||
import javax.tools.FileObject; | ||
import javax.tools.StandardLocation; | ||
|
||
import org.powertac.common.state.Domain; | ||
|
||
//import org.powertac.common.state.Domain; | ||
|
||
/** | ||
* @author John Collins | ||
* | ||
*/ | ||
@SupportedAnnotationTypes("org.powertac.common.state.Domain") | ||
@SupportedSourceVersion(SourceVersion.RELEASE_8) | ||
public class DomainProcessor extends AbstractProcessor | ||
{ | ||
|
||
public DomainProcessor () | ||
{ | ||
super(); | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see javax.annotation.processing.AbstractProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment) | ||
*/ | ||
@Override | ||
public boolean process (Set<? extends TypeElement> annotations, | ||
RoundEnvironment roundEnv) | ||
{ | ||
// start by opening a file for metadata recording | ||
PrintWriter out; | ||
try { | ||
FileObject f = | ||
processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, | ||
"", | ||
"metadata/domain.schema"); | ||
out = new PrintWriter(f.openWriter(), true); | ||
} | ||
catch (FilerException e) { | ||
// happens in normal processing | ||
return true; | ||
} | ||
catch (IOException e) { | ||
e.printStackTrace(); | ||
return true; | ||
} | ||
|
||
Map<String, String> opts = processingEnv.getOptions(); | ||
//System.out.println("Env options: " + opts.size()); | ||
//for (String key : opts.keySet()) | ||
// System.out.println("Key " + key); | ||
String artifactVersion = opts.get("core.versionId"); | ||
out.format("Domain-schema-version:%s\n", artifactVersion); | ||
if (annotations.size() != 1) { | ||
System.out.println("Should be only one annotation, saw " + annotations.size()); | ||
} | ||
for (TypeElement annotation : annotations) { | ||
//System.out.println("annotation name: " + annotation.getQualifiedName()); | ||
for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) { | ||
TypeMirror tm = element.asType(); | ||
if (tm.getKind() == TypeKind.DECLARED) { | ||
Domain domain = element.getAnnotation(Domain.class); | ||
if (domain.fields().length > 0) { | ||
out.format("%s:", tm.toString()); | ||
String delim = ""; | ||
for (String field: domain.fields()) { | ||
out.format("%s%s", delim, field); | ||
delim = ","; | ||
} | ||
out.format("\n"); | ||
} | ||
} | ||
} | ||
} | ||
out.format("schema.end\n"); | ||
out.close(); | ||
return true; | ||
} | ||
|
||
} |
2 changes: 2 additions & 0 deletions
2
powertac-metadata/src/main/resources/META-INF/services/javax.annotation.processing.Processor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# annotation processing services | ||
org.powertac.metadata.DomainProcessor |