Skip to content

Commit

Permalink
add id
Browse files Browse the repository at this point in the history
  • Loading branch information
kropp committed Jul 24, 2015
1 parent 57ec03a commit 5603606
Show file tree
Hide file tree
Showing 628 changed files with 5,037 additions and 1,883 deletions.
19 changes: 16 additions & 3 deletions generator/src/main/kotlin/generator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ private val BANNER = """/*
* This is auto-generated file. Do not edit.
*/"""

private val ID_TYPE = "http://schema.org/@id"

class GeneratorSink : TripleSink {
private var uri: String = "http://schema.org/"

Expand All @@ -81,7 +83,15 @@ class GeneratorSink : TripleSink {
type.isField = false
type.dataTypes.forEach { types.get(it)!!.interfaces.add(type.name!!.capitalize()) }
}
if (type.name == "Thing") {
type.subTypes.add(ID_TYPE)
}
}
val idType = Type()
idType.name = "Id"
idType.isField = true
idType.dataTypes.add("http://schema.org/Text")
types.put(ID_TYPE, idType)
}

override fun setBaseUri(baseUri: String) {
Expand Down Expand Up @@ -179,9 +189,9 @@ class GeneratorSink : TripleSink {
if (field.dataTypes.size() < 2)
return listOf(getFieldType(field) ?: "")

val iface = field.dataTypes.firstOrNull { types.get(it)!!.isInterface }
if (iface != null)
return listOf(types.get(iface)!!.name!!)
val interfaceName = field.dataTypes.firstOrNull { types.get(it)!!.isInterface }
if (interfaceName != null)
return listOf(types.get(interfaceName)!!.name!!)

return field.dataTypes.map { getBasicTypeName(types.get(it)?.name) }.filterNotNull().toHashSet().sort()
}
Expand Down Expand Up @@ -331,6 +341,9 @@ class GeneratorSink : TripleSink {
if (fieldType == "java.util.Date") {
appendln(" @com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = \"yyyy-MM-dd'T'HH:mm:ss'Z'\")")
}
if (name == "Id") {
appendln(" @com.fasterxml.jackson.annotation.JsonProperty(\"@id\")");
}
appendln(" public $fieldType get$name() {")
appendln(" return my$name;")
appendln(" }")
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/org/schema/APIReference.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static final class Builder {
* Creates new {@link APIReference} instance.
*/
public APIReference build() {
return new APIReference(executableLibraryName, assemblyVersion, programmingModel, targetPlatform, dependencies, proficiencyLevel, articleBody, articleSection, wordCount, pageEnd, pageStart, pagination, schemaVersion, about, accessibilityAPI, accessibilityControl, accessibilityFeature, accessibilityHazard, accountablePerson, aggregateRating, alternativeHeadline, associatedMedia, audience, audio, author, award, citation, comment, contentLocation, contentRating, contributor, copyrightHolder, copyrightYear, creator, dateCreated, dateModified, datePublished, discussionUrl, editor, educationalAlignment, educationalUse, encoding, genre, headline, inLanguage, interactivityType, isBasedOnUrl, isFamilyFriendly, keywords, license, learningResourceType, mainEntity, mentions, offers, producer, publication, publisher, publishingPrinciples, recordedAt, review, sourceOrganization, text, thumbnailUrl, timeRequired, typicalAgeRange, version, video, provider, commentCount, hasPart, workExample, exampleOfWork, character, translator, releasedEvent, additionalType, alternateName, description, mainEntityOfPage, name, sameAs, url, potentialAction);
return new APIReference(executableLibraryName, assemblyVersion, programmingModel, targetPlatform, dependencies, proficiencyLevel, articleBody, articleSection, wordCount, pageEnd, pageStart, pagination, schemaVersion, about, accessibilityAPI, accessibilityControl, accessibilityFeature, accessibilityHazard, accountablePerson, aggregateRating, alternativeHeadline, associatedMedia, audience, audio, author, award, citation, comment, contentLocation, contentRating, contributor, copyrightHolder, copyrightYear, creator, dateCreated, dateModified, datePublished, discussionUrl, editor, educationalAlignment, educationalUse, encoding, genre, headline, inLanguage, interactivityType, isBasedOnUrl, isFamilyFriendly, keywords, license, learningResourceType, mainEntity, mentions, offers, producer, publication, publisher, publishingPrinciples, recordedAt, review, sourceOrganization, text, thumbnailUrl, timeRequired, typicalAgeRange, version, video, provider, commentCount, hasPart, workExample, exampleOfWork, character, translator, releasedEvent, additionalType, alternateName, description, mainEntityOfPage, name, sameAs, url, potentialAction, id);
}
/**
* Library file name e.g., mscorlib.dll, system.web.dll.
Expand Down Expand Up @@ -808,6 +808,10 @@ public Builder potentialAction(Action action) {
this.potentialAction = action;
return this;
}
public Builder id(String id) {
this.id = id;
return this;
}
private String executableLibraryName;
private String assemblyVersion;
private String programmingModel;
Expand Down Expand Up @@ -891,10 +895,11 @@ public Builder potentialAction(Action action) {
private String sameAs;
private String url;
private Action potentialAction;
private String id;
}

protected APIReference(String executableLibraryName, String assemblyVersion, String programmingModel, String targetPlatform, String dependencies, String proficiencyLevel, String articleBody, String articleSection, Integer wordCount, IntegerOrString pageEnd, IntegerOrString pageStart, String pagination, String schemaVersion, Thing about, String accessibilityAPI, String accessibilityControl, String accessibilityFeature, String accessibilityHazard, Person accountablePerson, AggregateRating aggregateRating, String alternativeHeadline, MediaObject associatedMedia, Audience audience, AudioObject audio, OrganizationOrPerson author, String award, CreativeWorkOrString citation, Comment comment, Place contentLocation, String contentRating, OrganizationOrPerson contributor, OrganizationOrPerson copyrightHolder, Number copyrightYear, OrganizationOrPerson creator, java.util.Date dateCreated, java.util.Date dateModified, java.util.Date datePublished, String discussionUrl, Person editor, AlignmentObject educationalAlignment, String educationalUse, MediaObject encoding, String genre, String headline, LanguageOrString inLanguage, String interactivityType, String isBasedOnUrl, Boolean isFamilyFriendly, String keywords, CreativeWorkOrString license, String learningResourceType, Thing mainEntity, Thing mentions, Offer offers, OrganizationOrPerson producer, PublicationEvent publication, Organization publisher, String publishingPrinciples, Event recordedAt, Review review, Organization sourceOrganization, String text, String thumbnailUrl, Duration timeRequired, String typicalAgeRange, Number version, VideoObject video, OrganizationOrPerson provider, Integer commentCount, HasPart hasPart, CreativeWork workExample, CreativeWork exampleOfWork, Person character, OrganizationOrPerson translator, PublicationEvent releasedEvent, String additionalType, String alternateName, String description, CreativeWorkOrString mainEntityOfPage, String name, String sameAs, String url, Action potentialAction) {
super(dependencies, proficiencyLevel, articleBody, articleSection, wordCount, pageEnd, pageStart, pagination, schemaVersion, about, accessibilityAPI, accessibilityControl, accessibilityFeature, accessibilityHazard, accountablePerson, aggregateRating, alternativeHeadline, associatedMedia, audience, audio, author, award, citation, comment, contentLocation, contentRating, contributor, copyrightHolder, copyrightYear, creator, dateCreated, dateModified, datePublished, discussionUrl, editor, educationalAlignment, educationalUse, encoding, genre, headline, inLanguage, interactivityType, isBasedOnUrl, isFamilyFriendly, keywords, license, learningResourceType, mainEntity, mentions, offers, producer, publication, publisher, publishingPrinciples, recordedAt, review, sourceOrganization, text, thumbnailUrl, timeRequired, typicalAgeRange, version, video, provider, commentCount, hasPart, workExample, exampleOfWork, character, translator, releasedEvent, additionalType, alternateName, description, mainEntityOfPage, name, sameAs, url, potentialAction);
protected APIReference(String executableLibraryName, String assemblyVersion, String programmingModel, String targetPlatform, String dependencies, String proficiencyLevel, String articleBody, String articleSection, Integer wordCount, IntegerOrString pageEnd, IntegerOrString pageStart, String pagination, String schemaVersion, Thing about, String accessibilityAPI, String accessibilityControl, String accessibilityFeature, String accessibilityHazard, Person accountablePerson, AggregateRating aggregateRating, String alternativeHeadline, MediaObject associatedMedia, Audience audience, AudioObject audio, OrganizationOrPerson author, String award, CreativeWorkOrString citation, Comment comment, Place contentLocation, String contentRating, OrganizationOrPerson contributor, OrganizationOrPerson copyrightHolder, Number copyrightYear, OrganizationOrPerson creator, java.util.Date dateCreated, java.util.Date dateModified, java.util.Date datePublished, String discussionUrl, Person editor, AlignmentObject educationalAlignment, String educationalUse, MediaObject encoding, String genre, String headline, LanguageOrString inLanguage, String interactivityType, String isBasedOnUrl, Boolean isFamilyFriendly, String keywords, CreativeWorkOrString license, String learningResourceType, Thing mainEntity, Thing mentions, Offer offers, OrganizationOrPerson producer, PublicationEvent publication, Organization publisher, String publishingPrinciples, Event recordedAt, Review review, Organization sourceOrganization, String text, String thumbnailUrl, Duration timeRequired, String typicalAgeRange, Number version, VideoObject video, OrganizationOrPerson provider, Integer commentCount, HasPart hasPart, CreativeWork workExample, CreativeWork exampleOfWork, Person character, OrganizationOrPerson translator, PublicationEvent releasedEvent, String additionalType, String alternateName, String description, CreativeWorkOrString mainEntityOfPage, String name, String sameAs, String url, Action potentialAction, String id) {
super(dependencies, proficiencyLevel, articleBody, articleSection, wordCount, pageEnd, pageStart, pagination, schemaVersion, about, accessibilityAPI, accessibilityControl, accessibilityFeature, accessibilityHazard, accountablePerson, aggregateRating, alternativeHeadline, associatedMedia, audience, audio, author, award, citation, comment, contentLocation, contentRating, contributor, copyrightHolder, copyrightYear, creator, dateCreated, dateModified, datePublished, discussionUrl, editor, educationalAlignment, educationalUse, encoding, genre, headline, inLanguage, interactivityType, isBasedOnUrl, isFamilyFriendly, keywords, license, learningResourceType, mainEntity, mentions, offers, producer, publication, publisher, publishingPrinciples, recordedAt, review, sourceOrganization, text, thumbnailUrl, timeRequired, typicalAgeRange, version, video, provider, commentCount, hasPart, workExample, exampleOfWork, character, translator, releasedEvent, additionalType, alternateName, description, mainEntityOfPage, name, sameAs, url, potentialAction, id);
myExecutableLibraryName = executableLibraryName;
myAssemblyVersion = assemblyVersion;
myProgrammingModel = programmingModel;
Expand Down
Loading

0 comments on commit 5603606

Please sign in to comment.