Skip to content

Commit

Permalink
Merge pull request #89 from aml-org/update-release-4.7.5
Browse files Browse the repository at this point in the history
revert non-inclusive changes to fix compilation
  • Loading branch information
arielmirra authored Jul 1, 2021
2 parents 7ec0ec5 + 7437d87 commit 14c9422
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ class CanonicalWebAPISpecDialectExporter(logger: Logger = ConsoleLogger) {
(Namespace.Shapes + "AnyShape").iri(),
)
} else {
// we drop the first one (this schema) and then get the first not blocklisted.
// we drop the first one (this schema) and then get the first not blacklisted.
// we relay in the list of super types being defined by more important to less specific type
types.drop(1).find(!blocklistedSupertypes.contains(_)).map(Seq(_)).getOrElse(Nil)
types.drop(1).find(!blacklistedSupertypes.contains(_)).map(Seq(_)).getOrElse(Nil)
}

val nodeMapping = ExtendedDialectNodeMapping(id = id,
Expand Down Expand Up @@ -192,15 +192,15 @@ class CanonicalWebAPISpecDialectExporter(logger: Logger = ConsoleLogger) {
collected.distinct
}

val blocklistedProperties: Set[String] = Set(
val blacklistedProperties: Set[String] = Set(
(Namespace.Document + "link-target").iri(),
(Namespace.Document + "link-label").iri(),
(Namespace.Document + "recursive").iri(),
(Namespace.Document + "extends").iri(),
DomainElementModel.CustomDomainProperties.value.iri()
)

val blocklistedSupertypes: Set[String] = Set(
val blacklistedSupertypes: Set[String] = Set(
(Namespace.Document + "DomainElement").iri(),
(Namespace.Document + "RootDomainElement").iri(),
(Namespace.Shacl + "Shape").iri(),
Expand All @@ -209,10 +209,10 @@ class CanonicalWebAPISpecDialectExporter(logger: Logger = ConsoleLogger) {
(Namespace.Rdf + "Seq").iri()
)

val blocklistedRanges: Set[String] = Set()
val blacklistedRanges: Set[String] = Set()

// Base classes that should not appear in the dialect
val blocklistedMappings: Set[String] = Set(
val blacklistedMappings: Set[String] = Set(
"LinkableElement",
"DomainElement",
"SourceMap"
Expand Down Expand Up @@ -557,7 +557,7 @@ class CanonicalWebAPISpecDialectExporter(logger: Logger = ConsoleLogger) {
orderedNodeMappings.foreach { nodeMappingId =>
nodeMappings.get(nodeMappingId) match {
case Some(dialectNodeMapping: ExtendedDialectNodeMapping) =>
if (!blocklistedMappings.contains(dialectNodeMapping.name)) {
if (!blacklistedMappings.contains(dialectNodeMapping.name)) {
stringBuilder.append(s" ${dialectNodeMapping.name}:\n")
var (compacted, prefix, base) = compact(dialectNodeMapping.classTerm)
aggregateExternals(externals, prefix, base)
Expand All @@ -566,8 +566,8 @@ class CanonicalWebAPISpecDialectExporter(logger: Logger = ConsoleLogger) {
// Lets find the effective property mappings for this node mapping
var nodeMappingWithProperties = dialectNodeMapping.propertyMappings.filter { propertyMapping =>
// dynamic and linking information only relevant for design will not be dumped in the dialect
!blocklistedProperties.contains(propertyMapping.propertyTerm) &&
!blocklistedRanges.contains(propertyMapping.range)
!blacklistedProperties.contains(propertyMapping.propertyTerm) &&
!blacklistedRanges.contains(propertyMapping.range)
}

// extends relationship for macros
Expand Down
22 changes: 11 additions & 11 deletions exporters/src/main/scala/amf/exporters/VocabularyExporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ object VocabularyExporter {
(Namespace.ApiContract + "DomainExtension").iri()
)

val blocklist: Map[ModelVocabulary, Seq[ModelVocabulary]] = Map()
val blacklist: Map[ModelVocabulary, Seq[ModelVocabulary]] = Map()

val reflectionsExtensions = new Reflections(
"amf.core.metamodel.domain.extensions",
Expand Down Expand Up @@ -163,17 +163,17 @@ object VocabularyExporter {
}

val emitProperties = false
def notBlocklisted(klasses: Seq[String],
def notBlacklisted(klasses: Seq[String],
vocabulary: ModelVocabulary): Seq[String] = {
val vocabBlocklist: Seq[ModelVocabulary] =
blocklist.getOrElse(vocabulary, Seq())
val vocabBlacklist: Seq[ModelVocabulary] =
blacklist.getOrElse(vocabulary, Seq())
val res = klasses.filter { klassName =>
val notConflictive = !conflictive.contains(klassName)
val notInBlocklist = !vocabBlocklist.exists { v: ModelVocabulary =>
val notInBlackList = !vocabBlacklist.exists { v: ModelVocabulary =>
//println(s"Checking ${klassName} vs ${v.base} => ${klassName.startsWith(v.base)}")
klassName.startsWith(v.base)
}
notConflictive && notInBlocklist
notConflictive && notInBlackList
}

res
Expand All @@ -182,7 +182,7 @@ object VocabularyExporter {
val ShaclShape: String = (Namespace.Shacl + "Shape").iri()
val ShapesShape: String = (Namespace.Shapes + "Shape").iri()
val AnyShape: String = (Namespace.Shapes + "AnyShape").iri()
def blocklistedSuperClass(klass: String, superClass: String): Boolean = {
def blacklistedSuperClass(klass: String, superClass: String): Boolean = {
(klass, superClass) match {
case (ShapesShape, ShaclShape) => false
case (AnyShape, ShapesShape) => false
Expand Down Expand Up @@ -264,9 +264,9 @@ object VocabularyExporter {
externalDescription(classTerm.id))
}
val superClasses =
notBlocklisted(classTerm.superClasses,
notBlacklisted(classTerm.superClasses,
vocabulary).filter(sk =>
!blocklistedSuperClass(classTerm.id, sk))
!blacklistedSuperClass(classTerm.id, sk))
if (superClasses.nonEmpty) {
if (superClasses.length == 1) {
b.entry("extends",
Expand Down Expand Up @@ -324,7 +324,7 @@ object VocabularyExporter {
externalDescription(propertyTerm.id))
}
val superProperties =
notBlocklisted(propertyTerm.superClasses,
notBlacklisted(propertyTerm.superClasses,
vocabulary)
if (superProperties.nonEmpty) {
if (propertyTerm.superClasses.length == 1) {
Expand All @@ -349,7 +349,7 @@ object VocabularyExporter {
propertyTerm.scalarRange.get)
}
if (propertyTerm.objectRange.nonEmpty) {
if (notBlocklisted(
if (notBlacklisted(
Seq(propertyTerm.objectRange.get),
vocabulary).nonEmpty) {
b.entry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private[amf] object CanonicalWebAPISpecTransformer extends PlatformSecrets with

private def parseRdfToInstance(model: RdfModel, baseUnitId: String): BaseUnit = {
val plugins = PluginContext(
blockedPlugins = Seq(CorePlugin, APIDomainPlugin, DataShapesDomainPlugin, AMFGraphPlugin, Raml10Plugin))
blacklist = Seq(CorePlugin, APIDomainPlugin, DataShapesDomainPlugin, AMFGraphPlugin, Raml10Plugin))

RdfModelParser(errorHandler = UnhandledParserErrorHandler, plugins = plugins)
.parse(model, baseUnitId)
Expand Down

0 comments on commit 14c9422

Please sign in to comment.