Skip to content

Commit

Permalink
Updaded Axiom model & Prism model based on discussion
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
  • Loading branch information
tonydamage committed May 27, 2020
1 parent 752f231 commit a3aa1c1
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 13 deletions.
@@ -0,0 +1,35 @@
package com.evolveum.axiom.api.meta;

import com.evolveum.axiom.api.AxiomIdentifier;
import com.evolveum.axiom.lang.api.AxiomItemDefinition;

public interface Inheritance {

Inheritance INHERIT = Inheritance::inheritNamespace;
Inheritance NO_CHANGE = Inheritance::noChange;
Inheritance NO_NAMESPACE = Inheritance::noNamespace;
Inheritance CURRENT = NO_CHANGE;


static AxiomIdentifier adapt(AxiomIdentifier parent, AxiomIdentifier child) {
return CURRENT.apply(parent, child);
}

static AxiomIdentifier adapt(AxiomIdentifier parent, AxiomItemDefinition child) {
return child.inherited() ? adapt(parent, child.name()) : child.name();
}

AxiomIdentifier apply(AxiomIdentifier parent, AxiomIdentifier child);

static AxiomIdentifier inheritNamespace(AxiomIdentifier parent, AxiomIdentifier name) {
return parent.localName(name.localName());
}

static AxiomIdentifier noNamespace(AxiomIdentifier parent, AxiomIdentifier name) {
return name.defaultNamespace();
}

static AxiomIdentifier noChange(AxiomIdentifier parent, AxiomIdentifier name) {
return name;
}
}
Expand Up @@ -81,11 +81,9 @@ public void axiomTestLanguageExtension() throws IOException, AxiomSyntaxExceptio
AxiomTypeDefinition typeDef = schemaContext.getType(Type.TYPE_DEFINITION.name()).get();
assertNotNull(typeDef.itemDefinition(STORAGE).get());


ModelReactorContext extendedLanguage = ModelReactorContext.reactor(schemaContext);
extendedLanguage.loadModelFromSource(source(LANG_EXT));
extendedLanguage.loadModelFromSource(source(LANG_EXT_USE));

schemaContext = extendedLanguage.computeSchemaContext();

AxiomTypeDefinition langExtDef = schemaContext.getType(Type.EXTENSION_DEFINITION.name()).get();
Expand All @@ -95,8 +93,8 @@ public void axiomTestLanguageExtension() throws IOException, AxiomSyntaxExceptio
assertTrue(personDef.isPresent());

AxiomItem<Object> extension = personDef.get().item(STORAGE).get();
assertFalse(extension.values().isEmpty(), "Extension statements should be available.");

assertFalse(extension.values().isEmpty(), "Extension statements should be available.");
assertEquals(2, personDef.get().itemDefinitions().entrySet().size());
}

Expand Down
14 changes: 7 additions & 7 deletions infra/axiom/src/test/resources/prism/common-core.axiom
Expand Up @@ -885,15 +885,15 @@ model common-core {

// Example of short version of container definition.
prism:container {
name Assignment;
itemName assignment;
name Assignment;
itemName assignment;

// item description; // TODO make this work
// item documentation; // TODO make this work
// item extension; // TODO make this work
// item description; // TODO make this work
// item documentation; // TODO make this work
// item extension; // TODO make this work

// ...
}
// ...
}

prism:container {
name Extension;
Expand Down
4 changes: 2 additions & 2 deletions infra/axiom/src/test/resources/prism/common-core.prism
Expand Up @@ -10,7 +10,7 @@ prism:model common-core {

namespace "http://midpoint.evolveum.com/xml/ns/public/common/common-3";
version "3.0.0";

import prism {
namespace "http://midpoint.evolveum.com/xml/ns/public/common/prism";
}
Expand Down Expand Up @@ -861,7 +861,7 @@ prism:model common-core {
}
}

mixin Documentation {
mixin Documentation {
item documentation {
type string;
documentation """
Expand Down
5 changes: 4 additions & 1 deletion infra/axiom/src/test/resources/prism/prism.axiom
Expand Up @@ -12,7 +12,7 @@ model prism {

extension PrismModelExtension {
target axiom:AxiomModel;

item object {
type PrismObjectDefinition;
}
Expand All @@ -28,6 +28,9 @@ model prism {

type PrismModel {
extends axiom:AxiomModel;
item type { // {}:type
type PrismTypeDefinition;
}
}

extension PrismTypeDefinitionAnnotation {
Expand Down

0 comments on commit a3aa1c1

Please sign in to comment.