From 5b2746ed1efbe762af2ee91825758c4283167d31 Mon Sep 17 00:00:00 2001 From: Daniel Cortes Pichardo Date: Mon, 15 May 2017 13:23:19 -0500 Subject: [PATCH] updating essence factory updating essence factory --- .../exception/EssenceCoreException.java | 96 +++++++++++++++++++ .../dads/essence/repository/KernelEnum.java | 35 +++++++ .../dads/essence/util/EssenceFactory.java | 76 +++++++++++++++ .../repository/PracticeRepositoryTest.java | 2 +- 4 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 src/main/java/mx/infotec/dads/essence/exception/EssenceCoreException.java create mode 100644 src/main/java/mx/infotec/dads/essence/repository/KernelEnum.java create mode 100644 src/main/java/mx/infotec/dads/essence/util/EssenceFactory.java diff --git a/src/main/java/mx/infotec/dads/essence/exception/EssenceCoreException.java b/src/main/java/mx/infotec/dads/essence/exception/EssenceCoreException.java new file mode 100644 index 0000000..1e5d0e9 --- /dev/null +++ b/src/main/java/mx/infotec/dads/essence/exception/EssenceCoreException.java @@ -0,0 +1,96 @@ +/* + * + * The MIT License (MIT) + * Copyright (c) 2016 Daniel Cortes Pichardo + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package mx.infotec.dads.essence.exception; + +/** + * Runtime Exception for the Essence Meta-Model + * + * @author Daniel Cortes Pichardo + * + */ +public class EssenceCoreException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + /** + * Constructs a new LanguageElementException runtime exception with + * {@code null} as its detail message. The cause is not initialized, and may + * subsequently be initialized by a call to {@link #initCause}. + */ + public EssenceCoreException() { + super(); + } + + /** + * Constructs a new LanguageElementException runtime exception with the + * specified detail message. The cause is not initialized, and may + * subsequently be initialized by a call to {@link #initCause}. + * + * @param message + * the detail message. The detail message is saved for later + * retrieval by the {@link #getMessage()} method. + */ + public EssenceCoreException(String message) { + super(message); + } + + /** + * Constructs a new LanguageElementException runtime exception with the + * specified detail message and cause. + * + * @param message + * the detail message (which is saved for later retrieval by the + * {@link #getMessage()} method). + * @param cause + * the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * + */ + public EssenceCoreException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new LanguageElementException runtime exception with the + * specified cause and a detail message of + * (cause==null ? null : cause.toString()) (which typically + * contains the class and detail message of cause). This + * constructor is useful for runtime exceptions that are little more than + * wrappers for other throwables. + * + * @param cause + * the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + * + */ + public EssenceCoreException(Throwable cause) { + super(cause); + } + +} diff --git a/src/main/java/mx/infotec/dads/essence/repository/KernelEnum.java b/src/main/java/mx/infotec/dads/essence/repository/KernelEnum.java new file mode 100644 index 0000000..ec455ea --- /dev/null +++ b/src/main/java/mx/infotec/dads/essence/repository/KernelEnum.java @@ -0,0 +1,35 @@ +/* + * + * The MIT License (MIT) + * Copyright (c) 2016 Daniel Cortes Pichardo + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package mx.infotec.dads.essence.repository; + +/** + * Kernel Enum, for the Essence Core + * + * @author Daniel Cortes Pichardo + * @since essence 1.1 + * @version 1.1 + */ +public enum KernelEnum { + KERNEL, METHOD, PRACTICE, ALPHA, COMPETENCY, COMPETENCYLEVEL, ACTION, ACTIVITY, ACTIVITYASSOCIATION, ACTIVITYSPACE, COMPLETIONCRITERION, ENTRYCRITERION, ALPHAASSOCIATION, ALPHACONTAINMENT, LEVELOFDETAIL, STATE, WORKPRODUCT, WORKPRODUCTMANIFEST, CHECKPOINT, ENDEAVORPROPERTY, EXTENSIONELEMENT, LIBRARY, MERGERESOLUTION, PATTERN, PATTERNASSOCIATION, PRACTICEASSET, RESOURCE, TAG, TYPEDPATTERN, TYPEDRESOURCE, TYPEDTAG, USERDEFINEDTYPE, FEATURESELECTION, VIEWSELECTION +} diff --git a/src/main/java/mx/infotec/dads/essence/util/EssenceFactory.java b/src/main/java/mx/infotec/dads/essence/util/EssenceFactory.java new file mode 100644 index 0000000..77b29c4 --- /dev/null +++ b/src/main/java/mx/infotec/dads/essence/util/EssenceFactory.java @@ -0,0 +1,76 @@ +/* + * + * The MIT License (MIT) + * Copyright (c) 2016 Daniel Cortes Pichardo + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package mx.infotec.dads.essence.util; + +import java.util.ArrayList; + +import mx.infotec.dads.essence.model.foundation.SEPractice; + +/** + * + * @author Daniel Cortes Pichardo + * @since essence 1.1 + * @version 1.1 + */ +public class EssenceFactory { + + private EssenceFactory() { + + } + + /** + * Create a DefaultPractice + * + * @return SEPractice + */ + public static SEPractice createDefaultPractice() { + SEPractice practice = new SEPractice(); + // Practice + practice.setConsistencyRules(""); + practice.setEntry(new ArrayList<>()); + practice.setMeasures(new ArrayList<>()); + practice.setObjective(""); + practice.setResult(new ArrayList<>()); + // ElementGroup + practice.setBriefDescription(""); + practice.setDescription(""); + practice.setIcon(null); + practice.setMergeResolution(null); + practice.setName(""); + practice.setOwnedElements(new ArrayList<>()); + practice.setReferredElements(new ArrayList<>()); + // Inheritance + practice.setExtension(new ArrayList<>()); + practice.setFeatureSelection(new ArrayList<>()); + practice.setOwner(null); + practice.setPatternAssociation(new ArrayList<>()); + practice.setProperties(new ArrayList<>()); + practice.setReferrer(new ArrayList<>()); + practice.setResource(new ArrayList<>()); + practice.setSuppressable(false); + practice.setTag(new ArrayList<>()); + practice.setViewSelection(new ArrayList<>()); + return practice; + } +} diff --git a/src/test/java/mx/infotec/dads/essence/repository/PracticeRepositoryTest.java b/src/test/java/mx/infotec/dads/essence/repository/PracticeRepositoryTest.java index c8b3541..04760a2 100644 --- a/src/test/java/mx/infotec/dads/essence/repository/PracticeRepositoryTest.java +++ b/src/test/java/mx/infotec/dads/essence/repository/PracticeRepositoryTest.java @@ -65,7 +65,7 @@ public void insertPractice() throws Exception { SEPractice practice = new SEPractice(); // Practice practice.setConsistencyRules("Consistency Rules"); - practice.setEntry(Arrays.asList("Requeriments:Alpha", "Software:Architecture")); + practice.setEntry(Arrays.asList("Requeriments:State", "Software:Architecture")); practice.setMeasures(Arrays.asList("Timing", "five minutes pear meeting")); practice.setObjective("The Objetive of the practice"); practice.setResult(Arrays.asList("Requeriments:Alpha", "Software:Architecture"));