@Override
public void postProcessModel(final Model model, final ErrorHandler errorHandler) {
JPackage mainPackage = null;
CClassInfo classLink = null;
CEnumLeafInfo altitudeModeKML = null;
CEnumLeafInfo altitudeModeGX = null;
for (final CClassInfo classInfo : model.beans().values()) {
if (classInfo.shortName.equals("Kml")) {
LOG.info("Found KML package: " + classInfo.getOwnerPackage().name());
mainPackage = classInfo.getOwnerPackage();
break;
}
}
for (final CClassInfo classInfo : model.beans().values()) {
if (classInfo.shortName.equals("Link") && classInfo.getOwnerPackage().name().equals(mainPackage.name())) {
classLink = classInfo;
// for (iterable_type iterable_element : classLink.getProperties()) {
//
// }
Util.logInfo("Found Link class, prepare creation of Icon class");
break;
}
}
for (final CClassInfo classInfo : model.beans().values()) {
if (classInfo.fullName().equals(PACKAGE_GX + ".TourPrimitive") && !classInfo.isAbstract()) {
classInfo.setAbstract();
LOG.info(XJCJavaForKmlApiPlugin.PLUGINNAME + " Found gxTourPrimtive class, set abstract!");
break;
}
}
// for (final CClassInfo classInfo : model.beans().values()) {
// LOG.info("++++++ " + classInfo.fullName());
// for (CPropertyInfo p : classInfo.getProperties()) {
// String fullName = p.baseType.fullName();
// LOG.info("++++++ " + fullName);
// }
// }
//
// for (CClassInfo classInfo : model.beans().values()) {
// if (classInfo.fullName().equals(PACKAGE_GX + ".Playlist")) {
// LOG.info(XJCJavaForKmlApiPlugin.PLUGINNAME + " Found Playlist class!");
// List<CPropertyInfo> properties = classInfo.getProperties();
// for (CPropertyInfo cPropertyInfo : properties) {
// LOG.info(XJCJavaForKmlApiPlugin.PLUGINNAME + " > " + cPropertyInfo.kind(). + " " + cPropertyInfo.getName(true));
// }
// break;
// }
// }
for (final CEnumLeafInfo classInfo : model.enums().values()) {
if (classInfo.fullName().equals(PACKAGE_KML + ".AltitudeMode")) {
altitudeModeKML = classInfo;
LOG.info(XJCJavaForKmlApiPlugin.PLUGINNAME + " Found AltitudeMode in KML package");
continue;
}
if (classInfo.fullName().equals(PACKAGE_GX + ".AltitudeMode")) {
altitudeModeGX = classInfo;
LOG.info(XJCJavaForKmlApiPlugin.PLUGINNAME + " Found AltitudeMode in GX package");
continue;
}
}
assert mainPackage != null;
assert classLink != null;
assert altitudeModeKML != null;
assert altitudeModeGX != null;
final CBuiltinLeafInfo doubleValue = CBuiltinLeafInfo.DOUBLE;
final XSSchema schema = model.schemaComponent.getSchema("http://www.opengis.net/kml/2.2");
LOG.info(XJCJavaForKmlApiPlugin.PLUGINNAME + " -------Icon properties ------------------");
final CClassInfoParent cClassInfoParentLink = classLink.parent();
final CClassInfo iconClass = new CClassInfo(model, cClassInfoParentLink, "Icon", null, new QName("Icon"), null, schema, new CCustomizations());
iconClass.setBaseClass(classLink.getBaseClass());
//fill icon class with the properties defined in link class
final List<CPropertyInfo> properties = classLink.getProperties();
for (final CPropertyInfo c : properties) {
iconClass.addProperty(c);
}
final Collection<CEnumConstant> constants = altitudeModeGX.getConstants();
for (final CEnumConstant cEnumConstant : constants) {
altitudeModeKML.members.add( new CEnumConstant(cEnumConstant.getName(), null, cEnumConstant.getLexicalValue(), null, null, null));
}
//model.enums().remove(altitudeModeGX.fullName());