diff --git a/gtfs-realtime-validator-lib/pom.xml b/gtfs-realtime-validator-lib/pom.xml index d5225257..b5441c46 100644 --- a/gtfs-realtime-validator-lib/pom.xml +++ b/gtfs-realtime-validator-lib/pom.xml @@ -106,6 +106,24 @@ + + + + + org.codehaus.mojo + templating-maven-plugin + 1.0.0 + + + generate-version-class + + filter-sources + + + + + + org.apache.maven.plugins @@ -192,6 +210,34 @@ + + + + org.codehaus.mojo + templating-maven-plugin + 1.0.0 + + + + + org.codehaus.mojo + buildnumber-maven-plugin + 1.4 + + + validate + + create + + + + + false + false + UNKNOWN + true + + \ No newline at end of file diff --git a/gtfs-realtime-validator-lib/src/main/java-templates/edu/usf/cutr/gtfsrtvalidator/VersionUtil.java b/gtfs-realtime-validator-lib/src/main/java-templates/edu/usf/cutr/gtfsrtvalidator/VersionUtil.java new file mode 100644 index 00000000..eca890a5 --- /dev/null +++ b/gtfs-realtime-validator-lib/src/main/java-templates/edu/usf/cutr/gtfsrtvalidator/VersionUtil.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2018 University of South Florida (sjbarbeau@gmail.com) + * + * Licensed under the Apache License, VersionModel 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 edu.usf.cutr.gtfsrtvalidator; + +import edu.usf.cutr.gtfsrtvalidator.lib.model.VersionModel; + +/** + * Class used with the templating-maven-plugin to get Maven version numbers at runtime. See https://stackoverflow.com/a/36628755/937715 + */ +public class VersionUtil { + + private static final String VERSION = "${project.version}"; + private static final String GROUPID = "${project.groupId}"; + private static final String ARTIFACTID = "${project.artifactId}"; + private static final String REVISION = "${buildNumber}"; + + public static VersionModel getVersion() { + return new VersionModel(VERSION, GROUPID, ARTIFACTID, REVISION); + } +} \ No newline at end of file diff --git a/gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/VersionModel.java b/gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/VersionModel.java new file mode 100644 index 00000000..9876044f --- /dev/null +++ b/gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/VersionModel.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2018 University of South Florida (sjbarbeau@gmail.com) + * + * 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 edu.usf.cutr.gtfsrtvalidator.lib.model; + +/** + * A model class to hold the information generated at build time in VersionUtil. See https://stackoverflow.com/a/36628755/937715 + */ +public class VersionModel { + + private String mVersion; + private String mGroupId; + private String mArtifactId; + private String mRevision; + + public VersionModel() { + + } + + public VersionModel(String version, String groupId, String artifactId, String revision) { + mVersion = version; + mGroupId = groupId; + mArtifactId = artifactId; + mRevision = revision; + } + + public String getVersion() { + return mVersion; + } + + public String getGroupId() { + return mGroupId; + } + + public String getArtifactId() { + return mArtifactId; + } + + public String getRevision() { + return mRevision; + } + + public void setVersion(String version) { + this.mVersion = version; + } + + public void setGroupId(String groupId) { + this.mGroupId = mGroupId; + } + + public void setArtifactId(String artifactId) { + this.mArtifactId = mArtifactId; + } + + public void setRevision(String revision) { + this.mRevision = revision; + } + + @Override + public String toString() { + return "VersionModel{" + + "version='" + mVersion + '\'' + + ", groupId='" + mGroupId + '\'' + + ", artifactId='" + mArtifactId + '\'' + + ", revision='" + mRevision + '\'' + + '}'; + } +} diff --git a/gtfs-realtime-validator-webapp/src/main/java/edu/usf/cutr/gtfsrtvalidator/api/resource/VersionApi.java b/gtfs-realtime-validator-webapp/src/main/java/edu/usf/cutr/gtfsrtvalidator/api/resource/VersionApi.java new file mode 100644 index 00000000..113e3b66 --- /dev/null +++ b/gtfs-realtime-validator-webapp/src/main/java/edu/usf/cutr/gtfsrtvalidator/api/resource/VersionApi.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011 Nipuna Gunathilake. + * All rights reserved. + * + * 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 edu.usf.cutr.gtfsrtvalidator.api.resource; + +import com.fasterxml.jackson.core.JsonProcessingException; +import edu.usf.cutr.gtfsrtvalidator.VersionUtil; +import edu.usf.cutr.gtfsrtvalidator.lib.model.VersionModel; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Path("/version") +public class VersionApi { + + private static final org.slf4j.Logger _log = LoggerFactory.getLogger(VersionApi.class); + + // A call to `/api/version` returns the Maven version information for this project + @GET + @Produces(MediaType.APPLICATION_JSON) + public VersionModel getVersion() throws JsonProcessingException { + _log.info(VersionUtil.getVersion().toString()); + //return mObjectMapper.writeValueAsString(VersionUtil.getVersion()); + return VersionUtil.getVersion(); + } +} diff --git a/gtfs-realtime-validator-webapp/src/main/resources/webroot/custom-js/index.js b/gtfs-realtime-validator-webapp/src/main/resources/webroot/custom-js/index.js index 385f8899..6011a2ec 100644 --- a/gtfs-realtime-validator-webapp/src/main/resources/webroot/custom-js/index.js +++ b/gtfs-realtime-validator-webapp/src/main/resources/webroot/custom-js/index.js @@ -23,6 +23,11 @@ var enableShapes; var server = window.location.protocol + "//" + window.location.host; + +function about() { + +} + function addInput(){ if (counter == limit) { alert("You have reached the limit of adding " + counter + " inputs"); diff --git a/gtfs-realtime-validator-webapp/src/main/resources/webroot/index.html b/gtfs-realtime-validator-webapp/src/main/resources/webroot/index.html index aa3e5d2d..0b0faafc 100644 --- a/gtfs-realtime-validator-webapp/src/main/resources/webroot/index.html +++ b/gtfs-realtime-validator-webapp/src/main/resources/webroot/index.html @@ -24,7 +24,7 @@