Skip to content

Commit

Permalink
Version 0.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
lcbarcellos committed Nov 21, 2020
2 parents 7e067d5 + 5a60e24 commit 68daeff
Show file tree
Hide file tree
Showing 41 changed files with 144 additions and 61 deletions.
1 change: 1 addition & 0 deletions nbactions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<properties>
<jpda.listen>true</jpda.listen>
<vm.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}</vm.args>
<skipTests>true</skipTests>
</properties>
<activatedProfiles>
<activatedProfile>run-on-protege</activatedProfile>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>br.ufes.inf.nemo</groupId>
<artifactId>ufo-protege-plugin</artifactId>
<version>0.0.6</version>
<version>0.0.7</version>
<packaging>bundle</packaging>

<name>UFO Protégé Plugin</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public class InstantiateExtrinsicModeCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type four names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<sortal: ExtrinsicMode> <instance> <bearer: ConcreteIndividual> <dependence: Endurant>\"."
+ System.lineSeparator()
+ "Example: \"Love John'sLoveForMary John Mary\".")
.trim();
String[] names = input.split(" ");
IRI sortal = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class InstantiateIntrinsicModeCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type three names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<sortal: IntrinsicMode> <instance> <bearer: ConcreteIndividual>\"." + System.lineSeparator()
+ "Example: \"Hapiness Susan'sHapiness Susan\".")
.trim();
String[] names = input.split(" ");
IRI sortal = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class InstantiateNoReifiedQualityCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type three names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<qualityType: DataProperty> <value: String> <bearer: ConcreteIndividual>\"." + System.lineSeparator()
+ "Example: \"hasMass 30-tons LittlePrincePlanet\".")
.trim();
String[] names = input.split(" ");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class InstantiateObjectCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<sortal: ObjectClass> <instance>\"." + System.lineSeparator()
+ "Example: \"Dog Jack\".")
.trim();
String[] names = input.split(" ");
IRI sortal = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public class InstantiateQualityCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type four names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<sortal: Quality> <instance> <value: String> <bearer: ConcreteIndividual>\"."
+ System.lineSeparator()
+ "Example: \"Age AgeOfJohn 35-years John\".")
.trim();
String[] names = input.split(" ");
IRI sortal = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public class InstantiateRelatorCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type four names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<sortal: Relator> <instance> <mediated: Endurant> <mediated: Endurant>\"."
+ System.lineSeparator()
+ "Example: \"Marriage FirstMarriage Adam Eve\".")
.trim();
String[] names = input.split(" ");
IRI sortal = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class ComparativeRelationshipTypeCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type three names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<derivation: Quality> <RelationshipType> <domainAndRange: ConcreteIndividualClass>\"." + System.lineSeparator()
+ "Example: \"Weight heavierThan PhysicalObject\".")
.trim();
String[] names = input.split(" ");
IRI isDerivedFrom = IRI.create(GufoIris.GUFO, "isDerivedFrom");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class ComponentOfCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<component: Object> <FunctionalComplex>\"." + System.lineSeparator()
+ "Example: \"Heart Person\".")
.trim();
String[] names = input.split(" ");
IRI component = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public class MaterialRelationshipTypeCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type four names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<derivation: Relator> <RelationshipType> <domain: EndurantClass> <range: EndurantClass>\"."
+ System.lineSeparator()
+ "Example: \"Marriage wifeOf Woman Man\".")
.trim();
String[] names = input.split(" ");
IRI isDerivedFrom = IRI.create(GufoIris.GUFO, "isDerivedFrom");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class MemberOfCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<member: Object> <Collection>\"." + System.lineSeparator()
+ "Example: \"JonForeman Switchfoot\".")
.trim();
String[] names = input.split(" ");
IRI member = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class SubCollectionOfCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<subCollection: Collection> <Collection>\"." + System.lineSeparator()
+ "Example: \"SpadeCards Deck\".")
.trim();
String[] names = input.split(" ");
IRI subcollection = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class SubQuantityOfCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<subQuantity: Quantity> <Quantity>\"." + System.lineSeparator()
+ "Example: \"AlcoholInCupOfWine CupOfWine\".")
.trim();
String[] names = input.split(" ");
IRI subquantity = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class AddRoleToRoleMixinCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<RoleMixin> <Role>\". " + System.lineSeparator()
+ "Example: \"Customer CorporateCustomer\".")
.trim();
String[] names = input.split(" ");
IRI rolemixin = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public class AddToCategoryCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<Category> <RigidType>\". " + System.lineSeparator()
+ "Example: \"Animal Dog\".")
.trim();
String[] names = input.split(" ");
IRI category = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public class AddToMixinCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<Mixin> <EndurantType>\". " + System.lineSeparator()
+ "Example: \"Sitable Chair\".")
.trim();
String[] names = input.split(" ");
IRI mixin = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class CategoryCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<EndurantClass> <Category>\". " + System.lineSeparator()
+ "Example: \"FunctionalComplex Animal\".")
.trim();
String[] names = input.split(" ");
IRI endurantClass = IRI.create(GufoIris.GUFO, names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class KindCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<EndurantClass> <Kind>\". " + System.lineSeparator()
+ "Example: \"Quality Age\".")
.trim();
String[] names = input.split(" ");
IRI endurantClass = IRI.create(GufoIris.GUFO, names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class MixinCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<EndurantClass> <Mixin>\". " + System.lineSeparator()
+ "Example: \"FunctionalComplex Sitable\".")
.trim();
String[] names = input.split(" ");
IRI endurantClass = IRI.create(GufoIris.GUFO, names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public class NoReifiedQualityCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two name: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<domain: ConcreteIndividualClass> <qualityType: DataProperty>\". "
+ System.lineSeparator()
+ "Example: \"Planet hasMass\".")
.trim();
String[] names = input.split(" ");
IRI domain = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class PhaseCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<Sortal> <Phase>\". " + System.lineSeparator()
+ "Example: \"Person Child\".")
.trim();
String[] names = input.split(" ");
IRI sortal = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class PhaseMixinCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<NonSortal> <PhaseMixin>\". " + System.lineSeparator()
+ "Example: \"Animal Alive\".")
.trim();
String[] names = input.split(" ");
IRI nonsortal = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class RoleCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<Sortal> <Role>\". " + System.lineSeparator()
+ "Example: \"Woman Wife\".")
.trim();
String[] names = input.split(" ");
IRI sortal = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class RoleMixinCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<EndurantClass> <RoleMixin>\". " + System.lineSeparator()
+ "Example: \"FunctionalComplex Provider\".")
.trim();
String[] names = input.split(" ");
IRI endurantClass = IRI.create(GufoIris.GUFO, names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class RoleMixinOfCategoryCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<Category> <RoleMixin>\". " + System.lineSeparator()
+ "Example: \"LegalAgent Customer\".")
.trim();
String[] names = input.split(" ");
IRI category = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class RoleMixinOfRoleMixinCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"superClass: <RoleMixin> <subClass: RoleMixin>\". " + System.lineSeparator()
+ "Example: \"Provider ServiceProvider\".")
.trim();
String[] names = input.split(" ");
IRI parent = IRI.create(getOntologyPrefix(), names[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,22 @@ public class SubKindCommand extends PatternCommand {
@Override
public void actionPerformed(ActionEvent ae) {
String input =
JOptionPane.showInputDialog(getOWLWorkspace(), "Type two names: ")
JOptionPane.showInputDialog(getOWLWorkspace(),
"Input: \"<RigidSortal> <SubKind>\". " + System.lineSeparator()
+ "Example: \"Person Man\".")
.trim();
String[] names = input.split(" ");
IRI parent = IRI.create(getOntologyPrefix(), names[0]);
IRI child = IRI.create(getOntologyPrefix(), names[1]);
IRI rigidSortal = IRI.create(getOntologyPrefix(), names[0]);
IRI subkind = IRI.create(getOntologyPrefix(), names[1]);

try {
PatternApplier applier = new PatternApplier(getOWLModelManager());
if (applier.isInstanceOf(GufoIris.Kind, parent) ||
applier.isInstanceOf(GufoIris.SubKind, parent)) {
applier.createNamedIndividual(child);
applier.makeInstanceOf(GufoIris.SubKind, child);
applier.createClass(child);
applier.addSubClassTo(parent, child);
if (applier.isInstanceOf(GufoIris.Kind, rigidSortal) ||
applier.isInstanceOf(GufoIris.SubKind, rigidSortal)) {
applier.createNamedIndividual(subkind);
applier.makeInstanceOf(GufoIris.SubKind, subkind);
applier.createClass(subkind);
applier.addSubClassTo(rigidSortal, subkind);
} else {
showMessage("There are only subkinds of kinds or other subkinds!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ public String getLabel() {
}
}

public String getDescription() {
RuleInfo annotation = getClass().getAnnotation(RuleInfo.class);
if (annotation != null) {
return annotation.description();
} else {
return "";
}
}

public <T> T get(Class<T> helperClass) {
return validation.get(helperClass);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,13 @@
import java.util.Collection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.helpers.MessageFormatter;

/**
* Helper class to deal with of loading rule classes.
* <p>
* This class is instantiated only once during initialization of a
* {@link Validator} object. Its method {@link loadRules(List) loadRules}
* loads class names from 'rules.list' text file resource and creates an
* instance for each one of the classes.
* <p>
* The 'rules.list' resource is automatically generated during build time by
* maven-antrun-plugin. It makes a scan over the source code folder of
* package br.ufes.inf.nemo.ufo.protege.validation
* This class holds the boilerplate code involved in loading {@link Rule }
* subclasses and instantiating them, while generating sensible log messages.
*
* @author luciano
*/
Expand All @@ -50,7 +45,8 @@ final class RuleLoader {
}

private void logError(String message, Throwable ex) {
log.error(String.format(message, ruleClassName), ex);
message = MessageFormatter.format(message, ruleClassName).getMessage();
log.error(message, ex);
}

private void quit(String message, Object... args) {
Expand Down Expand Up @@ -105,7 +101,7 @@ private void processClassName(String ruleClassName) {
if (quitException != ex) {
logError("Unexpected error on loading rule class '%s'", ex);
}
log.error("Not adding rule class '%s' due to previous errors.", ruleClassName);
log.error("Not adding rule class '{}' due to previous errors.", ruleClassName);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ private static Predicate<ObjectGraphNode> is(OWLObject owlObject) {
return node -> node.owlObject.equals(objectOrIRI);
}

@SuppressWarnings("unchecked")
private static Predicate<ObjectGraphNode> isIn(Set<IRI> iris) {
return node -> iris.contains((IRI)node.owlObject);
return node -> iris.contains(node.getIRI());
}

private Set<ObjectGraphNode> getSet(int index) {
Expand Down
Loading

0 comments on commit 68daeff

Please sign in to comment.