This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository eugene. See http://git.nuiton.org/eugene.git commit 3b80a38c96502f14be1608cc8168c51617f38aa6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun May 24 12:11:05 2015 +0200 Remove deprecated codes (refs #2252) --- .../java/JavaTemplatesModelPropertiesProvider.java | 43 -- .../org/nuiton/eugene/plugin/GenerateMojo.java | 10 - .../nuiton/eugene/plugin/SmartGenerateMojo.java | 60 --- .../writer/BaseChainedFileWriterToMemoryModel.java | 9 - .../plugin/writer/ModelChainedFileWriter.java | 365 ------------- .../eugene/EugeneModelPropertiesProvider.java | 41 -- .../java/org/nuiton/eugene/EugeneStereoTypes.java | 26 - .../org/nuiton/eugene/ModelPropertiesUtil.java | 415 -------------- .../main/java/org/nuiton/eugene/ModelReader.java | 30 -- .../org/nuiton/eugene/java/JavaGeneratorUtil.java | 43 +- .../eugene/models/object/ObjectModelReader.java | 600 --------------------- .../eugene/models/stereotype/package-info.java | 2 +- .../eugene/models/tagvalue/package-info.java | 2 +- .../writer/ChainedFileWriterConfiguration.java | 16 - .../org/nuiton/eugene/EugeneStereotypesTest.java | 6 +- 15 files changed, 7 insertions(+), 1661 deletions(-) diff --git a/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesModelPropertiesProvider.java b/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesModelPropertiesProvider.java deleted file mode 100644 index e952dea..0000000 --- a/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesModelPropertiesProvider.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.nuiton.eugene.java; - -/* - * #%L - * EUGene :: Java templates - * %% - * Copyright (C) 2012 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import org.nuiton.eugene.ModelPropertiesUtil; - -/** - * The Java templates provider of tag values and stereotypes. - * - * @author Tony Chemit - chemit@codelutin.com - * @plexus.component role="org.nuiton.eugene.metas.ModelPropertiesProvider" role-hint="java" - * @since 2.5.6 - * @deprecated since 2.9, no more used (will be removed in version 3.0). Use now {@link JavaTemplatesStereoTypes} and {@link JavaTemplatesTagValues}. - */ -@Deprecated -public class JavaTemplatesModelPropertiesProvider extends ModelPropertiesUtil.ModelPropertiesProvider { - - @Override - public void init() throws IllegalAccessException { - scanStereotypeClass(JavaTemplatesStereoTypes.class); - scanTagValueClass(JavaTemplatesTagValues.class); - } -} diff --git a/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/GenerateMojo.java b/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/GenerateMojo.java index 25f958a..ff88360 100644 --- a/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/GenerateMojo.java +++ b/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/GenerateMojo.java @@ -712,16 +712,6 @@ public class GenerateMojo extends AbstractPlugin implements ChainedFileWriterCon } @Override - public Map<String, ModelReader<?>> getModelReaders() { - return modelReaders; - } - - @Override - public Map<String, Template<?>> getModelTemplates() { - return modelTemplates; - } - - @Override public ModelHelper getModelHelper() { return modelHelper; } diff --git a/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java b/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java deleted file mode 100644 index dd94c71..0000000 --- a/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/SmartGenerateMojo.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * #%L - * EUGene :: Maven plugin - * %% - * Copyright (C) 2006 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -package org.nuiton.eugene.plugin; - -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.ResolutionScope; - -/** - * Smart file generator. - * <p/> - * Fill inputs and mojo will chained needed writer. - * <p/> - * - * @author Tony Chemit - chemit@codelutin.com - * @deprecated since 2.5, prefer use now the {@code generate} goal. - */ -@Mojo(name = "smart-generate", - requiresProject = true, - requiresDirectInvocation = false, - requiresDependencyResolution = ResolutionScope.COMPILE) -@Deprecated -public class SmartGenerateMojo extends GenerateMojo { - - @Override - protected void init() throws Exception { - - getLog().warn("================================================================================"); - getLog().warn(""); - getLog().warn("Since version 2.5, smart-generate is deprecated (it will be removed in version 3.0)."); - getLog().warn("Prefer use now the generate goal."); - getLog().warn(""); - getLog().warn("See http://doc.nuiton.org/eugene/eugene-maven-plugin/generate-mojo.html"); - getLog().warn("See http://forge.nuiton.org/issues/2251"); - getLog().warn(""); - getLog().warn("================================================================================"); - - super.init(); - } - -} diff --git a/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/writer/BaseChainedFileWriterToMemoryModel.java b/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/writer/BaseChainedFileWriterToMemoryModel.java index 70a8425..f8b8781 100644 --- a/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/writer/BaseChainedFileWriterToMemoryModel.java +++ b/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/writer/BaseChainedFileWriterToMemoryModel.java @@ -22,7 +22,6 @@ package org.nuiton.eugene.plugin.writer; * #L% */ -import org.nuiton.eugene.ModelPropertiesUtil; import org.nuiton.eugene.ModelReader; import org.nuiton.eugene.models.Model; import org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider; @@ -112,14 +111,6 @@ public abstract class BaseChainedFileWriterToMemoryModel extends BaseChainedFile return getProperty(PROP_READER, String.class); } - /** - * @deprecated since 2.9, no more used, use now {@link #getStereotypeDefinitionProvider()} and {@link #getTagValueDefinitionProvider()} - */ - @Deprecated - protected ModelPropertiesUtil.ModelPropertiesProvider getModelPropertiesProvider() { - return getProperty(PROP_MODEL_PROPERTIES_PROVIDER, ModelPropertiesUtil.ModelPropertiesProvider.class); - } - protected TagValueDefinitionProvider getTagValueDefinitionProvider() { return getProperty(PROP_TAG_VALUE_DEFINITION_PROVIDER, TagValueDefinitionProvider.class); } diff --git a/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/writer/ModelChainedFileWriter.java b/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/writer/ModelChainedFileWriter.java deleted file mode 100644 index 99afb8f..0000000 --- a/eugene-maven-plugin/src/main/java/org/nuiton/eugene/plugin/writer/ModelChainedFileWriter.java +++ /dev/null @@ -1,365 +0,0 @@ -/* - * #%L - * EUGene :: Maven plugin - * %% - * Copyright (C) 2006 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -package org.nuiton.eugene.plugin.writer; - -import org.apache.commons.lang3.StringUtils; -import org.nuiton.eugene.DefaultTemplateConfiguration; -import org.nuiton.eugene.ModelPropertiesUtil; -import org.nuiton.eugene.ModelReader; -import org.nuiton.eugene.Template; -import org.nuiton.eugene.TemplateConfiguration; -import org.nuiton.eugene.models.Model; -import org.nuiton.eugene.models.stereotype.StereotypeDefinitionProvider; -import org.nuiton.eugene.models.tagvalue.TagValueDefinitionProvider; -import org.nuiton.eugene.writer.ChainedFileWriterConfiguration; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -/** - * To write model files from zargo files. - * - * @author tchemit - * @since 2.0.0 - * @deprecated since 2.6.3, will be removed in 3.0, use instead {@link XmlModelChainedFileWriter}. - */ -@Deprecated -public class ModelChainedFileWriter extends BaseChainedFileWriter { - - public static final String PROP_GENERATED_PACKAGES = Template.PROP_GENERATED_PACKAGES; - - public static final String PROP_EXCLUDE_TEMPLATES = "excludeTemplates"; - - public static final String PROP_TEMPLATES = "templates"; - - public static final String PROP_TEMPLATES_LIST = "templatesList"; - - public static final String PROP_DEFAULT_PACKAGE = Template.PROP_DEFAULT_PACKAGE; - - public static final String PROP_MODEL_READER = "modelReader"; - - public static final String PROP_TAG_VALUE_DEFINITION_PROVIDER = "tagValueDefinitionProvider"; - - public static final String PROP_STEREOTYPE_DEFINITION_PROVIDER = "stereotypeDefinitionProvider"; - - @Deprecated - public static final String PROP_MODEL_PROPERTIES_PROVIDER = "modelPropertiesProvider"; - - public static final String PROP_READER = "reader"; - - public static final String PROP_TEMPLATE_CONFIGURATION = "templateConfiguration"; - - public ModelChainedFileWriter() { - super( - PROP_TEMPLATES, "templates", - PROP_TEMPLATES_LIST, "templatesList", - PROP_EXCLUDE_TEMPLATES, "excludeTemplates", - PROP_READER, "reader", - PROP_MODEL_READER, "modelReader", - PROP_GENERATED_PACKAGES, "generatedPackages", - PROP_DEFAULT_PACKAGE, "defaultPackage", - PROP_TEMPLATE_CONFIGURATION, "templateConfiguration", - PROP_TAG_VALUE_DEFINITION_PROVIDER, "tagValueDefinitionProvider", - PROP_STEREOTYPE_DEFINITION_PROVIDER, "stereotypeDefinitionProvider", - PROP_MODEL_PROPERTIES_PROVIDER, "modelPropertiesProvider" - ); - } - - @Override - public String getInputProtocol() { - return "model"; - } - - @Override - public String getOutputProtocol(String modelType) { - // nothing after java files - return null; - } - - @Override - public boolean acceptModel(String modelType) { - // accept all models - return acceptObjectModelOrStateModel(modelType); - } - - @Override - public boolean acceptInclude(String include) { - return include.startsWith("model:") || - include.endsWith(".objectmodel") || - include.endsWith(".statemodel"); - } - - @Override - public String getDefaultIncludes() { - return "**/*.*model"; - } - - @Override - public String getDefaultInputDirectory() { - return "src/main/models"; - } - - @Override - public String getDefaultOutputDirectory() { - return "java"; - } - - @Override - public String getDefaultTestInputDirectory() { - return "src/test/models"; - } - - @Override - public String getDefaultTestOutputDirectory() { - return "test-java"; - } - - public String getDefaultPackage() { - return getProperty(PROP_DEFAULT_PACKAGE, String.class); - } - - public String[] getExcludeTemplates() { - return getProperty(PROP_EXCLUDE_TEMPLATES, String[].class); - } - - public String getGeneratedPackages() { - return getProperty(PROP_GENERATED_PACKAGES, String.class); - } - - @SuppressWarnings({"unchecked"}) - public List<Template<Model>> getTemplatesList() { - return getProperty(PROP_TEMPLATES_LIST, List.class); - } - - public String getTemplates() { - return getProperty(PROP_TEMPLATES, String.class); - } - - public TemplateConfiguration getTemplateConfiguration() { - return getProperty(PROP_TEMPLATE_CONFIGURATION, TemplateConfiguration.class); - } - - protected ModelReader<?> getModelReader() { - return getProperty(PROP_MODEL_READER, ModelReader.class); - } - - protected String getReader() { - return getProperty(PROP_READER, String.class); - } - - /** - * @deprecated since 2.9, no more used, use now {@link #getStereotypeDefinitionProvider()} and {@link #getTagValueDefinitionProvider()} - */ - @Deprecated - protected ModelPropertiesUtil.ModelPropertiesProvider getModelPropertiesProvider() { - return getProperty(PROP_MODEL_PROPERTIES_PROVIDER, ModelPropertiesUtil.ModelPropertiesProvider.class); - } - - protected TagValueDefinitionProvider getTagValueDefinitionProvider() { - return getProperty(PROP_TAG_VALUE_DEFINITION_PROVIDER, TagValueDefinitionProvider.class); - } - - protected StereotypeDefinitionProvider getStereotypeDefinitionProvider() { - return getProperty(PROP_STEREOTYPE_DEFINITION_PROVIDER, StereotypeDefinitionProvider.class); - } - - @Override - protected void initWriter(ChainedFileWriterConfiguration configuration) { - super.initWriter(configuration); - - // obtain a reader - ClassLoader classLoader = configuration.getClassLoader(); - ClassLoader loader = classLoader; - if (getModelReader() == null) { - - if (getReader() != null) { - // use a specific reader - String reader = getReader(); - try { - ClassLoader fixedClassLoader = loader; - ModelReader<?> modelReader = (ModelReader<?>) - Class.forName(reader, true, - fixedClassLoader).newInstance(); - //TODO : should check that the reader is compatible with - //TODO : given modelType - properties.put(PROP_MODEL_READER, modelReader); - } catch (Exception eee) { - throw new IllegalStateException("could not obtain reader " - + reader, eee); - } - } else { - String modelType = configuration.getModelType(); - ModelReader<?> modelReader = configuration.getModelHelper().getModelReader(modelType, "xml"); - configuration.getModelHelper().getModelReaders().get(modelType); - if (modelReader == null) { - throw new IllegalStateException( - "could not find a model reader for modelType : " + - modelType + ", availables readers : " + - configuration.getModelHelper().getModelReaders().values() - ); - } - properties.put(PROP_MODEL_READER, modelReader); - } - } - - boolean verbose = configuration.isVerbose(); - - getModelReader().setStereotypeDefinitionProvider(getStereotypeDefinitionProvider()); - getModelReader().setTagValueDefinitionProvider(getTagValueDefinitionProvider()); - -// // gets the provider of safe tag values and stereotypes -// ModelPropertiesProvider propertiesProvider = getModelPropertiesProvider(); -// -// // affect it to the model reader -// getModelReader().setModelPropertiesProvider(propertiesProvider); - - // set the verbose level of the model reader - getModelReader().setVerbose(verbose); - - List<Template<?>> templatesList = initTemplates(configuration); - - properties.put(PROP_TEMPLATES_LIST, templatesList); - } - - protected List<Template<?>> initTemplates(ChainedFileWriterConfiguration configuration) { - - ClassLoader loader = configuration.getClassLoader(); - - boolean verbose = configuration.isVerbose(); - - Properties templateProperties = new Properties(); - - templateProperties.put(Template.PROP_DEFAULT_PACKAGE, getDefaultPackage()); - templateProperties.put(Template.PROP_ENCODING, configuration.getEncoding()); - templateProperties.put(Template.PROP_VERBOSE, verbose); - templateProperties.put(Template.PROP_OVERWRITE, configuration.isOverwrite()); - templateProperties.put(Template.PROP_CLASS_LOADER, loader); - templateProperties.put(Template.PROP_EXCLUDE_TEMPLATES, configuration.getProperties().get(PROP_EXCLUDE_TEMPLATES)); - - String generatedPackages = getGeneratedPackages(); - if (StringUtils.isEmpty(generatedPackages)) { - if (verbose) { - getLog().info("generating all packages"); - } - } else { - templateProperties.put(Template.PROP_GENERATED_PACKAGES, - generatedPackages); - if (verbose) { - getLog().info("generating only for packages " + generatedPackages); - } - } - - // init templates - - List<Template<?>> templatesList = new ArrayList<Template<?>>(); - if (StringUtils.isEmpty(getTemplates())) { - throw new IllegalArgumentException("No template specified, use the templates parameter"); - } - String[] templatesNames = getTemplates().split(","); - for (String templateName : templatesNames) { - // remove trailing spaces - templateName = templateName.trim(); - Template<?> template = - configuration.getModelTemplates().get(templateName); - - if (template == null) { - getLog().warn("template [" + templateName + "] is not " + - "registred via plexus, try to load it directly"); - try { - template = (Template<?>) Class.forName( - templateName, true, loader).newInstance(); - } catch (Exception e) { - throw new IllegalStateException( - "Can't obtain template [" + templateName + - "] for reason " + e.getMessage(), e - ); - } - } - - if (verbose) { - getLog().info("will use the template [" + templateName + "]"); - } - - // will use this template - templatesList.add(template); - - // set the properties of the template - template.setConfiguration( - new DefaultTemplateConfiguration(templateProperties)); - } - return templatesList; - } - - @Override - public void generate(ChainedFileWriterConfiguration configuration, - File outputDir, - Map<File, List<File>> filesByRoot, - Map<File, List<File>> resourcesByFile) throws IOException { - - Set<File> modelFiles = new HashSet<File>(); - for (List<File> files : filesByRoot.values()) { - modelFiles.addAll(files); - } - File[] filesToRead = modelFiles.toArray(new File[modelFiles.size()]); - - if (configuration.isVerbose()) { - getLog().info("Will read " + filesToRead.length + " model(s)."); - } - - - // read memory model from all files models - Model model = getModelReader().read(filesToRead); - - // get the last modified source timestamp from reader - long lastModifiedSource = getModelReader().getLastModifiedSource(); - - // apply all templates to the model - - for (Template<Model> template : getTemplatesList()) { - getLog().info("Apply generator " + template.getClass().getSimpleName()); - - // set the lastModified source property - template.setProperty(Template.PROP_LAST_MODIFIED_SOURCE, lastModifiedSource); - - template.setProperty(Template.PROP_WRITER_REPORT, getWriterReport()); - - if (configuration.isVerbose()) { - getLog().info(" overwrite = " + template.isOverwrite()); - getLog().info(" encoding = " + template.getEncoding()); - getLog().info(" lastModifiedSource = " + template.getLastModifiedSource()); - getLog().info(" exclude = " + template.getExcludeTemplates()); - getLog().info(" output directory = " + outputDir); - } - - // apply template - template.applyTemplate(model, outputDir); - } - } - -} diff --git a/eugene/src/main/java/org/nuiton/eugene/EugeneModelPropertiesProvider.java b/eugene/src/main/java/org/nuiton/eugene/EugeneModelPropertiesProvider.java deleted file mode 100644 index 0123b3f..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/EugeneModelPropertiesProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.nuiton.eugene; - -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2014 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - - -/** - * The Eugene provider of tag values and stereotypes. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.3 - * @deprecated since 2.9, use now {@link EugeneStereoTypes} and {@link EugeneTagValues}. - */ -@Deprecated -public class EugeneModelPropertiesProvider extends ModelPropertiesUtil.ModelPropertiesProvider { - - @Override - public void init() throws IllegalAccessException { - scanStereotypeClass(EugeneStereoTypes.class); - scanTagValueClass(EugeneTagValues.class); - } -} diff --git a/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java b/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java index 2051769..eeee11d 100644 --- a/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java +++ b/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java @@ -41,17 +41,6 @@ import org.nuiton.eugene.models.stereotype.Stereotypes; public class EugeneStereoTypes extends StereotypeDefinitionProvider { /** - * Stéréotype pour les attributs à indexer en base. - * - * @see #hasIndexedStereotype(ObjectModelAttribute) - * @deprecated since 2.8, use {@link #STEREOTYPE_ORDERED} instead, will be removed in version 3.0 - */ - @StereotypeDefinition(target = ObjectModelAttribute.class, - documentation = "To specify that a attribute is indexed") - @Deprecated - public static final String STEREOTYPE_INDEXED = "indexed"; - - /** * Stereotype to mark an attribute with multiplicity as ordered. * <p/> * It means that order of insertion is maintained: in Java, it will lead @@ -88,21 +77,6 @@ public class EugeneStereoTypes extends StereotypeDefinitionProvider { public static final String STEREOTYPE_SKIP = "skip"; /** - * Check if the given attribute has the {@link #STEREOTYPE_INDEXED} stereotype. - * - * @param attribute attribute to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see #STEREOTYPE_INDEXED - * @see #hasIndexedStereotype(ObjectModelAttribute) - * @since 2.3 - * @deprecated {@link #STEREOTYPE_INDEXED} is deprecated - */ - @Deprecated - public static boolean hasIndexedStereotype(ObjectModelAttribute attribute) { - return attribute.hasStereotype(EugeneStereoTypes.STEREOTYPE_INDEXED); - } - - /** * Check if the given attribute has the {@link #STEREOTYPE_ORDERED} stereotype. * * @param attribute attribute to test diff --git a/eugene/src/main/java/org/nuiton/eugene/ModelPropertiesUtil.java b/eugene/src/main/java/org/nuiton/eugene/ModelPropertiesUtil.java deleted file mode 100644 index 9a27e16..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/ModelPropertiesUtil.java +++ /dev/null @@ -1,415 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2010 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ -package org.nuiton.eugene; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.eugene.models.stereotype.StereotypeDefinitionProviders; -import org.nuiton.eugene.models.tagvalue.TagValueDefinitionProviders; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map; -import java.util.ServiceLoader; -import java.util.Set; -import java.util.TreeMap; - -/** - * Util class which introduces all the stuff to make usage of stereotype - * and tag values safe. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.3 - * @deprecated since 2.9, will be removed in version 3.0, use now {@link StereotypeDefinitionProviders} and {@link TagValueDefinitionProviders}. - */ -@Deprecated -public class ModelPropertiesUtil { - - /** Logger. */ - private static final Log log = LogFactory.getLog(ModelPropertiesUtil.class); - - /** - * Obtain a new store of tag values and stereotypes. - * - * @param loader the classloader to use (if none given will use the one of the current thread) - * @param verbose a verbose flag - * @return the aggregate store of all atomic one detected in the class-path - */ - public static ModelPropertiesProvider newStore(ClassLoader loader, - boolean verbose) { - - if (loader == null) { - - // use the current thread loader - loader = Thread.currentThread().getContextClassLoader(); - } - - ModelPropertiesProvider store = new AggregateModelPropertiesProvider(loader); - store.setVerbose(verbose || log.isDebugEnabled()); - try { - store.init(); - } catch (Exception e) { - throw new RuntimeException("Could not init store of tag values and stereotypes", e); - } - return store; - } - - /** - * Obtain a new store of tag values and stereotypes. - * - * @param providers the list of providers to use in the store - * @param verbose a verbose flag - * @return the aggregate store of all atomic one detected in the class-path - */ - public static ModelPropertiesProvider newStore(Iterable<ModelPropertiesProvider> providers, - boolean verbose) { - - ModelPropertiesProvider store = new AggregateModelPropertiesProvider(providers); - store.setVerbose(verbose || log.isDebugEnabled()); - try { - store.init(); - } catch (Exception e) { - throw new RuntimeException("Could not init store of tag values and stereotypes", e); - } - return store; - } - - /** - * The Eugene provider of tag values and stereotypes. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.3 - */ - public static class EugeneModelPropertiesProvider extends ModelPropertiesProvider { - - @Override - public void init() throws IllegalAccessException { - scanStereotypeClass(EugeneStereoTypes.class); - scanTagValueClass(EugeneTagValues.class); - } - } - - /** - * A aggregate provider to box all the ones registred in the class-path via the - * {@link ServiceLoader} api. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.3 - */ - public static class AggregateModelPropertiesProvider extends ModelPropertiesProvider { - - protected ClassLoader loader; - - private Iterable<ModelPropertiesProvider> providers; - - public AggregateModelPropertiesProvider(ClassLoader loader) { - this.loader = loader; - } - - public AggregateModelPropertiesProvider(Iterable<ModelPropertiesProvider> providers) { - this.providers = providers; - } - - @Override - public void init() throws Exception { - - if (providers == null) { - - providers = ServiceLoader.load(ModelPropertiesProvider.class, loader); - } - - for (ModelPropertiesProvider provider : providers) { - if (isVerbose()) { - log.info("Will init model properties provider " + provider); - } - provider.setVerbose(isVerbose()); - provider.init(); - getStereotypeStore().putAll(provider.getStereotypeStore()); - getTagValueStore().putAll(provider.getTagValueStore()); - getDeprecatedStereotypes().addAll(provider.getDeprecatedStereotypes()); - getDeprecatedTagValues().addAll(provider.getDeprecatedTagValues()); - } - } - } - - /** - * To define a stereotype. - * <p/> - * Place this annotation on the constant defining your stereotype. - * <p/> - * <br/> - * Example for stereotype named mystereotype which can be only put on a attribute : - * <pre> - * String STEREOTYPE_MYSTEREOTYPE = "mystereotype"; - * \@StereotypeDefinition(target = ObjectModelAttribute.class) - * </pre - * - * @author Tony Chemit - chemit@codelutin.com - * @see EugeneTagValues - * @since 2.3 - */ - @Target(ElementType.FIELD) - @Retention(RetentionPolicy.RUNTIME) - public @interface StereotypeDefinition { - - /** - * Define the types of object model api which can use this tag value. - * - * @return the array of target object model element which can accept the tag value. - */ - Class<?>[] target(); - - /** - * Obtain the english documentation of the stereotype. - * - * @return the documentation of the stereotype. - * @since 2.3.1 - */ - String documentation(); - } - - /** - * To define a tag value. - * <p/> - * Place this annotation on the constant defining your tag-value. - * <p/> - * Example for tag value named mytagvalut which can be only put on a attribute : - * <pre> - * String TAG_VALUE_MYTAGVALUE = "mytagvalue"; - * \@TagValueDefinition(target = ObjectModelAttribute.class) - * </pre - * - * @author Tony Chemit - chemit@codelutin.com - * @see EugeneTagValues - * @since 2.3 - */ - @Target(ElementType.FIELD) - @Retention(RetentionPolicy.RUNTIME) - public @interface TagValueDefinition { - - /** - * Define the types of object model api which can use this tag value. - * - * @return the array of target object model element which can accept the tag value. - */ - Class<?>[] target(); - - /** - * Obtain the english documentation of the tag value. - * - * @return the documentation of the tag value. - * @since 2.3.1 - */ - String documentation(); - } - - /** - * TODO - * - * @author Tony Chemit - chemit@codelutin.com - * @since 2.3 - */ - public abstract static class ModelPropertiesProvider { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(ModelPropertiesProvider.class); - - protected Map<String, TagValueDefinition> tagValueStore; - - protected Map<String, StereotypeDefinition> stereotypeStore; - - protected Set<String> deprecatedTagValues; - - protected Set<String> deprecatedStereotypes; - - protected boolean verbose; - - protected ModelPropertiesProvider() { - stereotypeStore = new TreeMap<String, StereotypeDefinition>(); - tagValueStore = new TreeMap<String, TagValueDefinition>(); - deprecatedTagValues = new HashSet<String>(); - deprecatedStereotypes = new HashSet<String>(); - } - - public boolean isVerbose() { - return verbose; - } - - public void setVerbose(boolean verbose) { - this.verbose = verbose; - } - - public abstract void init() throws Exception; - - protected void scanStereotypeClass(Class<?> holder) throws IllegalAccessException { - if (isVerbose()) { - log.info("Will scan " + holder.getName() + " to search some stereotype definitions..."); - } - Field[] fields = holder.getDeclaredFields(); - for (Field field : fields) { - - StereotypeDefinition stereotypeDefinition = - field.getAnnotation(StereotypeDefinition.class); - - if (stereotypeDefinition != null) { - String fieldName = field.getName(); - String stereotypeName = (String) field.get(null); - if (isVerbose()) { - log.info("Detected stereotype definition [" + fieldName + ":" + stereotypeName + "] : " + Arrays.toString(stereotypeDefinition.target())); - } - stereotypeStore.put(stereotypeName, stereotypeDefinition); - if (field.isAnnotationPresent(Deprecated.class)) { - deprecatedStereotypes.add((stereotypeName)); - } - } - } - } - - protected void scanTagValueClass(Class<?> holder) throws IllegalAccessException { - if (isVerbose()) { - log.info("Will scan " + holder.getName() + " to search some tag value definitions..."); - } - Field[] fields = holder.getDeclaredFields(); - for (Field field : fields) { - - TagValueDefinition tagValueDefinition = - field.getAnnotation(TagValueDefinition.class); - if (tagValueDefinition != null) { - String fieldName = field.getName(); - String tagValueName = (String) field.get(null); - if (isVerbose()) { - log.info("Detected tag value definition [" + fieldName + ":" + tagValueName + "] : " + Arrays.toString(tagValueDefinition.target())); - } - tagValueStore.put(tagValueName, tagValueDefinition); - if (field.isAnnotationPresent(Deprecated.class)) { - deprecatedTagValues.add((tagValueName)); - } - } - } - } - - public Map<String, StereotypeDefinition> getStereotypeStore() { - return stereotypeStore; - } - - public Map<String, TagValueDefinition> getTagValueStore() { - return tagValueStore; - } - - public Set<String> getDeprecatedTagValues() { - return deprecatedTagValues; - } - - public Set<String> getDeprecatedStereotypes() { - return deprecatedStereotypes; - } - - public Class<?>[] getTagValueTarget(String tagValueName) { - TagValueDefinition definition = tagValueStore.get(tagValueName); - - Class<?>[] result = null; - if (definition != null) { - result = definition.target(); - } - return result; - } - - public Class<?>[] getStereotypeTarget(String tagValueName) { - - StereotypeDefinition definition = stereotypeStore.get(tagValueName); - - Class<?>[] result = null; - if (definition != null) { - result = definition.target(); - } - return result; - } - - public boolean containsTagValue(String tagValueName) { - boolean b = tagValueStore.containsKey(tagValueName); - return b; - } - - public boolean containsStereotype(String stereotypeName) { - boolean b = stereotypeStore.containsKey(stereotypeName); - return b; - } - - public boolean acceptTagValue(String tagValueName, Class<?> type) { - if (!containsTagValue(tagValueName)) { - - // unknown - return false; - } - - Class<?>[] tagValueTarget = getTagValueTarget(tagValueName); - - for (Class<?> target : tagValueTarget) { - if (target.equals(type) || target.isAssignableFrom(type)) { - - // found one accepting target - return true; - } - } - - // no target found - return false; - } - - public boolean acceptStereotype(String stereotypeName, Class<?> type) { - if (!containsStereotype(stereotypeName)) { - - // unknown - return false; - } - - Class<?>[] tagValueTarget = getStereotypeTarget(stereotypeName); - for (Class<?> target : tagValueTarget) { - if (target.equals(type) || target.isAssignableFrom(type)) { - - // found one accepting target - return true; - } - } - - // no target found - return false; - } - - public boolean isDeprecatedTagValue(String tagValueName) { - boolean deprecated = deprecatedTagValues.contains(tagValueName); - return deprecated; - } - - public boolean isDeprecatedStereotype(String stereotypeName) { - boolean deprecated = deprecatedStereotypes.contains(stereotypeName); - return deprecated; - } - } - -} diff --git a/eugene/src/main/java/org/nuiton/eugene/ModelReader.java b/eugene/src/main/java/org/nuiton/eugene/ModelReader.java index 62c79bb..aa506e8 100644 --- a/eugene/src/main/java/org/nuiton/eugene/ModelReader.java +++ b/eugene/src/main/java/org/nuiton/eugene/ModelReader.java @@ -64,13 +64,6 @@ public abstract class ModelReader<M extends Model> { protected boolean strictLoading; /** - * The provider of safe tag values and stereotypes. - * - * @since 2.3 - */ - private ModelPropertiesUtil.ModelPropertiesProvider modelPropertiesProvider; - - /** * Provider of tag values. * * @since 2.9 @@ -145,29 +138,6 @@ public abstract class ModelReader<M extends Model> { */ public abstract M read(File... file) throws IOException; - /** - * @return the provider of controled tagvalues and stereotypes. - * @since 2.3 - * @deprecated since 2.9, no more used. - */ - @Deprecated - public ModelPropertiesUtil.ModelPropertiesProvider getModelPropertiesProvider() { - return modelPropertiesProvider; - } - - /** - * Sets the provider of tag values and stereotypes availables. - * - * @param modelPropertiesProvider the provider to use - * @since 2.3 - * @deprecated since 2.9, no more used - */ - @Deprecated - public void setModelPropertiesProvider(ModelPropertiesUtil.ModelPropertiesProvider modelPropertiesProvider) { - this.modelPropertiesProvider = modelPropertiesProvider; - } - - public TagValueDefinitionProvider getTagValueDefinitionProvider() { return tagValueDefinitionProvider; } diff --git a/eugene/src/main/java/org/nuiton/eugene/java/JavaGeneratorUtil.java b/eugene/src/main/java/org/nuiton/eugene/java/JavaGeneratorUtil.java index f4a38b9..c2015e8 100644 --- a/eugene/src/main/java/org/nuiton/eugene/java/JavaGeneratorUtil.java +++ b/eugene/src/main/java/org/nuiton/eugene/java/JavaGeneratorUtil.java @@ -23,17 +23,13 @@ package org.nuiton.eugene.java; import org.apache.commons.lang3.StringUtils; import org.nuiton.eugene.EugeneStereoTypes; -import org.nuiton.eugene.EugeneTagValues; import org.nuiton.eugene.GeneratorUtil; -import org.nuiton.eugene.models.object.ObjectModel; import org.nuiton.eugene.models.object.ObjectModelAttribute; import org.nuiton.eugene.models.object.ObjectModelClass; import org.nuiton.eugene.models.object.ObjectModelClassifier; -import org.nuiton.eugene.models.object.ObjectModelElement; import org.nuiton.eugene.models.object.ObjectModelJavaModifier; import org.nuiton.eugene.models.object.ObjectModelModifier; import org.nuiton.eugene.models.object.ObjectModelOperation; -import org.nuiton.eugene.models.object.ObjectModelPackage; import org.nuiton.eugene.models.object.ObjectModelParameter; import org.nuiton.util.StringUtil; @@ -127,38 +123,6 @@ public class JavaGeneratorUtil extends GeneratorUtil { } /** - * Check if the given classifier has the - * {@link EugeneStereoTypes#STEREOTYPE_SKIP} stereotype. - * - * @param classifier classifier to test - * @return {@code true} if stereotype was found, {@code false otherwise} - * @see EugeneStereoTypes#STEREOTYPE_SKIP - * @since 2.5 - * @deprecated since 2.9, use now {@link EugeneStereoTypes#hasSkipStereotype(ObjectModelClassifier, ObjectModelPackage)} - */ - @Deprecated - public static boolean hasSkipStereotype(ObjectModelClassifier classifier, ObjectModelPackage aPackage) { - return EugeneStereoTypes.hasSkipStereotype(classifier, aPackage); - } - - /** - * Cherche et renvoie le prefixe i18n à utiliser sur cet element, sinon sur - * le model. - * - * @param element l'élément à tester - * @param model le modele utilisé - * @return le prefix i18n ou <code>null</code> si non spécifié - * @since 2.3 - * @deprecated since 2.9, use now {@link EugeneTagValues#getI18nPrefixTagValue(ObjectModelElement, ObjectModelPackage, ObjectModel)} - */ - @Deprecated - public static String getI18nPrefixTagValue(ObjectModelElement element, - ObjectModelPackage aPackage, - ObjectModel model) { - return EUGENE_TAG_VALUES.getI18nPrefixTagValue(element, aPackage, model); - } - - /** * Convertit une propriété javaBean son suffix utilisé pour écrire les * getter/setter correspondant. * @@ -387,7 +351,7 @@ public class JavaGeneratorUtil extends GeneratorUtil { } public static boolean isOrdered(ObjectModelAttribute attr) { - return attr.isOrdered() || EugeneStereoTypes.hasOrderedStereotype(attr) || EugeneStereoTypes.hasIndexedStereotype(attr); + return attr.isOrdered() || EugeneStereoTypes.hasOrderedStereotype(attr); } public static Class<?> getCollectionType(ObjectModelAttribute attr) { @@ -468,10 +432,7 @@ public class JavaGeneratorUtil extends GeneratorUtil { @Override public String toString(ObjectModelParameter param) { - return new StringBuilder(getAttributeInterfaceType(param)). - append(' '). - append(param.getName()). - toString(); + return getAttributeInterfaceType(param) + ' ' + param.getName(); } }; diff --git a/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelReader.java b/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelReader.java deleted file mode 100644 index 1df8428..0000000 --- a/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelReader.java +++ /dev/null @@ -1,600 +0,0 @@ -/* - * #%L - * EUGene :: EUGene - * %% - * Copyright (C) 2004 - 2012 CodeLutin, Chatellier Eric - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -package org.nuiton.eugene.models.object; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.digester3.Digester; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.eugene.EugeneTagValues; -import org.nuiton.eugene.ModelHelper; -import org.nuiton.eugene.ModelReader; -import org.nuiton.eugene.models.object.reader.XmlObjectModelReader; -import org.nuiton.eugene.models.object.xml.DigesterObjectModelRuleSet; -import org.nuiton.eugene.models.object.xml.ObjectModelAssociationClassImpl; -import org.nuiton.eugene.models.object.xml.ObjectModelClassifierImpl; -import org.nuiton.eugene.models.object.xml.ObjectModelElementImpl; -import org.nuiton.eugene.models.object.xml.ObjectModelImpl; -import org.nuiton.eugene.models.object.xml.ObjectModelImplRef; -import org.nuiton.eugene.models.stereotype.MismatchStereotypeTargetException; -import org.nuiton.eugene.models.stereotype.StereotypeDefinitionProviders; -import org.nuiton.eugene.models.stereotype.StereotypeNotFoundException; -import org.nuiton.eugene.models.tagvalue.MismatchTagValueTargetException; -import org.nuiton.eugene.models.tagvalue.TagValueDefinitionProviders; -import org.nuiton.eugene.models.tagvalue.TagValueNotFoundException; -import org.nuiton.util.FileUtil; -import org.nuiton.util.RecursiveProperties; -import org.nuiton.util.StringUtil; -import org.xml.sax.SAXException; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * To read object model files into an memory object model. - * <p/> - * Created: 26 oct. 2009 - * - * @author fdesbois <fdesbois@codelutin.com> - * @version $Id$ - * @deprecated since 2.6.3, is replaced by {@link XmlObjectModelReader}. - */ -@Deprecated -public class ObjectModelReader extends ModelReader<ObjectModel> { - - private static final Log log = LogFactory.getLog(ObjectModelReader.class); - - public static final String TAGVALUE = "tagvalue"; - - public static final String STEREOTYPE = "stereotype"; - - public static final String OPERATION = "operation"; - - public static final String ATTRIBUTE = "attribute"; - - public static final String CLASS = "class"; - - /** - * Pattern to define tag values authorized at classifier level in the model - * properties file. - * <p/> - * L'expression réguliere match les chaines de type - * <package.ClassName>.<class|attribute|operation>.[name].<stereotype|tagvalue>.[tag] - * fr.isisfish.entities.Population.class.stereotype=entity - * fr.isisfish.entities.Population.class.tagvalue.persistenceType=flatfile - * fr.isisfish.entities.Population.attribute.name.stereotype=... - * fr.isisfish.entities.Population.attribute.name.tagvalue.pk=topiaId - * fr.isisfish.entities.Population.operation.getRegion.stereotype=... - * fr.isisfish.entities.Population.operation.getRegion.tagvalue.pk=... - */ - protected Pattern propertiesPattern = Pattern - .compile("^((?:[_a-zA-Z0-9]+\\.)+(?:_?[A-Z][_a-zA-Z0-9]*\\.)+)(?:(class|attribute|operation))\\.(?:([_a-zA-Z0-9]+)\\.)?(?:(tagvalue|tagValue)?)\\.([_a-z0-9][_a-zA-Z0-9]*)?$"); - - protected Pattern stereotypePattern = Pattern - .compile("^((?:[_a-zA-Z0-9]+\\.)+(?:_?[A-Z][_a-zA-Z0-9]*\\.)+)(?:(class|attribute|operation))\\.(?:([_a-zA-Z0-9]+)\\.)?(?:(stereotype)?)$"); - - /** - * Pattern to define tag values authorized at model level in the model - * properties file. - * - * @since 2.3 - */ - protected Pattern modelTagValuePattern = Pattern.compile( - "^model\\.(?:(tagvalue|tagValue)?)\\.((?:.+))$"); - - public static final String MODEL = "model"; - - @Override - public String getModelType() { - return ModelHelper.ModelType.OBJECT.getAlias(); - } - - @Override - public String getInputType() { - return ModelHelper.ModelInputType.XML.getAlias(); - } - - /** - * @param files les noms des fichiers existant contenant du XML représentant - * des ObjectModel. Il est automatiquement recherche un fichier de - * propriété associé a ce fichier pour pouvoir ajouter des - * stereotype ou des tag value sur les class, attribute ou operation - */ - @Override - public ObjectModel read(File... files) throws IOException { - setLastModifiedSource(files); - if (log.isDebugEnabled()) { - log.debug("LastModifiedSource = " + getLastModifiedSource() + - " for files " + Arrays.toString(files)); - } - - if (tagValueDefinitionProvider == null) { - if (log.isDebugEnabled()) { - log.debug("No tag value provider filled, will instanciate a new default one"); - } - setTagValueDefinitionProvider(TagValueDefinitionProviders.newProvider(getClass().getClassLoader(), false)); - } - if (stereotypeDefinitionProvider == null) { - if (log.isDebugEnabled()) { - log.debug("No stereotype provider filled, will instanciate a new default one"); - } - setStereotypeDefinitionProvider(StereotypeDefinitionProviders.newProvider(getClass().getClassLoader(), false)); - } -// if (modelPropertiesProvider == null) { -// if (log.isWarnEnabled()) { -// log.warn("No properties provider filled, will instanciate a new default one"); -// } -// setModelPropertiesProvider(ModelPropertiesUtil.newStore(getClass().getClassLoader(), false)); -// } - - ObjectModel model = new ObjectModelImpl(); - - // Digester parser configuration - Digester digester = new Digester(); - digester.addRuleSet(new DigesterObjectModelRuleSet()); - - for (File file : files) { - try { - digester.push(model); - model = digester.parse(file); - } catch (SAXException e) { - throw new IOException("Unable to parse ObjectModel input file : " + file, e); -// if (log.isWarnEnabled()) { -// log.warn("Unable to parse ObjectModel input file : " + file, e); -// } - } - - // recherche est charge le fichier propriete associe au modele - File dir = file.getParentFile(); - String ext = FileUtil.extension(file); - String name = FileUtil.basename(file, "." + ext); - File propFile = new File(dir, name + ".properties"); - if (!propFile.exists()) { - if (isVerbose()) { - log.info("Pas de fichier de propriete " + propFile - + " associé au model"); - } - } else { - if (isVerbose()) { - log.info("Lecture du fichier de propriete " + propFile - + " associé au model"); - } - loadModelProperties(propFile, model); - } - } - if (log.isDebugEnabled()) { - for (ObjectModelClass m : model.getClasses()) { - log.debug("loaded class in objectmodel : " + m.getName()); - } - } - return model; - } - - /** - * Retrieve an attribute from a {@code clazz} with its {@code name}. - * This method manage the association class case to explore participants - * attributes if needed. - * - * @param clazz where the attribute need to be find - * @param name attribute name to find - * @return the attribute found or null - */ - protected ObjectModelAttribute getAttribute(ObjectModelClass clazz, - String name) { - ObjectModelAttribute result = clazz.getAttribute(name); - - // Ano #619 : FD-2010-05-17 : Specific case for Association class : - // check on participant attributes - if (result == null && clazz instanceof ObjectModelAssociationClassImpl) { - if (log.isDebugEnabled()) { - log.debug("Attribute " + name + " not found from " + - clazz.getQualifiedName() + " association class. " + - "Will check participants..."); - } - ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) clazz; - for (ObjectModelAttribute participant : assoc.getParticipantsAttributes()) { - if (participant.getName().equals(name)) { - result = participant; - break; - } - } - } - return result; - } - - public Properties loadModelProperties(File propFile, - ObjectModel model) throws IOException { - - Properties prop = new RecursiveProperties(); -// try { - FileInputStream inStream = new FileInputStream(propFile); - try { - prop.load(inStream); - } finally { - inStream.close(); - } - - // number of sucessfull imported tag values into model - int numberImportedTagValues = 0; - - // get all the tagvalues keys and sort them - List<String> keys = new ArrayList<String>(); - CollectionUtils.addAll(keys, prop.keys()); - Collections.sort(keys); - - // for each tag value try to import in in model - for (String key : keys) { - String value = prop.getProperty(key); - - if (log.isDebugEnabled()) { - log.debug("Propriete: '" + key + "' = " + value); - } - - if (key.startsWith(MODEL)) { - - // model tag value - - boolean loaded = loadModelTagValue(model, key, value); - - if (loaded) { - - numberImportedTagValues++; - } - continue; - } - - // element tag value or stereotype - - if (key.contains(STEREOTYPE)) { - - // stereotype property - - boolean loaded = loadStereotype(model, key, value); - - if (loaded) { - numberImportedTagValues++; - } - - continue; - - } - - // tag value property - - boolean loaded = loadTagValue(model, key, value); - - if (loaded) { - numberImportedTagValues++; - } - } - if (log.isInfoEnabled()) { - log.info(numberImportedTagValues + " tag values were succesfull imported from " + propFile); - } - int nbFailed = prop.size() - numberImportedTagValues; - if (nbFailed > 0 && isVerbose()) { - log.info(nbFailed + " tag values failed to be imported from " + propFile); - } - return prop; - } - - public boolean loadModelTagValue(ObjectModel model, String key, String value) { - Matcher matcher = modelTagValuePattern.matcher(key); - - if (!matcher.find()) { - if (log.isWarnEnabled()) { - log.warn("Invalid model tag value [" + key + "] : only tagvalue or tagValue is allowed on model in properties"); - } - return false; - } - String tag = matcher.group(2); - - boolean safe = false; - - try { - tagValueDefinitionProvider.validate(tag, ObjectModel.class); - safe = true; - } catch (TagValueNotFoundException e) { - if (log.isWarnEnabled()) { - log.warn("Invalid model tag value [" + key + "] : the tagvalue '" + tag + "' is unknown."); - } - } catch (MismatchTagValueTargetException e) { - if (log.isWarnEnabled()) { - log.warn("Invalid model tag value [" + key + "] : this tagvalue '" + tag + "' can not be apply on the model."); - } - } - - if (!safe && isStrictLoading()) { - - // in strict loading do not accept unsafe tags - return false; - } - - ObjectModelImpl modelImpl = (ObjectModelImpl) model; - if (tag.equals(EugeneTagValues.TAG_VERSION)) { - - // push directly the version in the model version - // property - modelImpl.setVersion(value); - } - if (isVerbose()) { - log.info("model tag value imported " + key + " --> " + tag + " = " + value); - } - modelImpl.addTagValue(tag, value); - return true; - } - - public boolean loadStereotype(ObjectModel model, String key, String value) { - Matcher matcher = stereotypePattern.matcher(key); - - if (!matcher.find()) { - - if (log.isWarnEnabled()) { - log.warn("Invalid stereotype [" + key + "] : syntax is not correct."); - } - return false; - } - - String fqn = matcher.group(1); - fqn = StringUtil.substring(fqn, 0, -1); // remove ended . - // target is class, attribute or operation - String target = matcher.group(2); - String targetName = matcher.group(3); - // type is stereotype - String type = matcher.group(4).toLowerCase(); - // target real type - Class<?> targetType = getTargetType(target); - - boolean safe = false; - - try { - stereotypeDefinitionProvider.validate(value, targetType); - safe = true; - } catch (StereotypeNotFoundException e) { - if (log.isWarnEnabled()) { - log.warn("Invalid model stereotype [" + key + "] : the stereotype '" + value + "' is unknown."); - } - } catch (MismatchStereotypeTargetException e) { - if (log.isWarnEnabled()) { - log.warn("Invalid model stereotype [" + key + "] : this stereotype '" + value + "' can not be apply on '" + targetType + "'."); - } - } - - if (!safe && isStrictLoading()) { - - // in strict loading do not accept unsafe stereotypes - return false; - } - - if (log.isDebugEnabled()) { - log.debug("Propriete: '" + key + "' => " - + "fqn:" + fqn + " target:" + target - + " targetName:" + targetName - + " type:" + type); - } - - ObjectModelClassifier omc = getClassifier(model, STEREOTYPE, key, fqn); - if (omc == null) { - - // classifier not found - return false; - } - - List<ObjectModelElement> elems = getObjectElements(omc, STEREOTYPE, key, fqn, target, targetName); - - if (elems == null) { - - // no element to apply - return false; - } - - for (ObjectModelElement elem1 : elems) { - //TODO tchemit 2010-11-29 uncomment this if there is some proble, but I don't see why there would be... -// if (elem1 == null) { -// if (log.isWarnEnabled()) { -// log.warn("Invalid stereotype [" + key + "] : Element '" + targetName + "' of type '" + target + "' on classifier '" + fqn + "' is null."); -// } -// continue; -// } - ObjectModelElementImpl elem = (ObjectModelElementImpl) elem1; - - // pour les stereotypes - ObjectModelImplRef stereotype = new ObjectModelImplRef(); - stereotype.setName(value); - elem.addStereotype(stereotype); - } - - if (isVerbose()) { - log.info("stereotype imported " + key + " --> " + fqn + ":" + target + ":" + targetName + ":" + type + " = " + value); - } - - return true; - } - - private boolean loadTagValue(ObjectModel model, String key, String value) { - Matcher matcher = propertiesPattern.matcher(key); - - if (!matcher.find()) { - - if (log.isWarnEnabled()) { - log.warn("Invalid tag value [" + key + "] : syntax is not correct."); - } - return false; - } - - String fqn = matcher.group(1); - fqn = StringUtil.substring(fqn, 0, -1); // remove ended - // . - // target is class, attribute or operation - String target = matcher.group(2); - // name of the target (can be null on class) - String targetName = matcher.group(3); - // type is tagvalue - String type = matcher.group(4).toLowerCase(); - // name of the tag value - String tag = matcher.group(5); - // target real type - Class<?> targetType = getTargetType(target); - - if (log.isDebugEnabled()) { - log.debug("Propriete: '" + key + "' => " - + "fqn:" + fqn + " target:" + target - + " targetName:" + targetName - + " type:" + type + " tag:" + tag); - } - - boolean safe = false; - - try { - tagValueDefinitionProvider.validate(tag, targetType); - safe = true; - } catch (TagValueNotFoundException e) { - if (log.isWarnEnabled()) { - log.warn("Invalid tag value [" + key + "] : this tagvalue '" + tag + "' is unknown."); - } - } catch (MismatchTagValueTargetException e) { - if (log.isWarnEnabled()) { - log.warn("Invalid tag value [" + key + "] : this tagvalue '" + tag + "' can not be apply on the given type '" + target + "'."); - } - } - - if (!safe && isStrictLoading()) { - - // in strict loading do not accept unsafe tags - return false; - } - - ObjectModelClassifier omc = getClassifier(model, TAGVALUE, key, fqn); - if (omc == null) { - - // classifier not found - return false; - } - - List<ObjectModelElement> elements = - getObjectElements(omc, TAGVALUE, key, fqn, target, targetName); - - if (elements == null) { - - // no elements to apply - return false; - } - - for (ObjectModelElement element : elements) { - - if (log.isDebugEnabled()) { - log.debug("add tagValue " + tag - + ", value:" + value - + " to element:" + element); - } - element.addTagValue(tag, value); - - } - if (isVerbose()) { - log.info("tag value imported " + key + " --> " + fqn + ":" + target + ":" + targetName + ":" + type + ":" + tag + " = " + value); - } - return true; - } - - protected Class<?> getTargetType(String target) { - Class<?> result = null; - if (ATTRIBUTE.equals(target)) { - return ObjectModelAttribute.class; - } - if (OPERATION.equals(target)) { - return ObjectModelOperation.class; - } - if (CLASS.equals(target)) { - return ObjectModelClassifier.class; - } - - return result; - } - - protected ObjectModelClassifier getClassifier(ObjectModel model, String type, String key, String fqn) { - ObjectModelClassifier omc = model.getClassifier(fqn); - if (omc == null) { - if (log.isWarnEnabled()) { - log.warn("Invalid " + type + " [" + key + - "] : Could not find classifier for " + fqn); - } - return null; - } - - //todo tchemit 2010-11-25 : what does it mean ? every thing extends ObjectModelClassifierImpl - if (!(omc instanceof ObjectModelClassifierImpl)) { - // TODO il faudra avoir des methodes d'acces en Set sur l'interface pour eviter ce message - if (log.isWarnEnabled()) { - log.warn("Can't add properties to model, " + - "it's not an " + - "ObjectModelClassifierImpl : " + - omc.getQualifiedName()); - } - return null; - } - return omc; - } - - protected List<ObjectModelElement> getObjectElements(ObjectModelClassifier omc, String type, String key, String fqn, String target, String targetName) { - List<ObjectModelElement> elems = new ArrayList<ObjectModelElement>(); - if (CLASS.equals(target)) { - elems.add(omc); - } else if (ATTRIBUTE.equals(target)) { - - ObjectModelAttribute attr = - getAttribute((ObjectModelClass) omc, targetName); - elems.add(attr); - - } else if (OPERATION.equals(target)) { - elems.addAll(omc.getOperations(targetName)); - } - - if (elems.isEmpty()) { - if (log.isWarnEnabled()) { - log.warn("Invalid " + type + " [" + key + "] : Could not find any element '" + targetName + "' of type '" + target + "' on classifier '" + fqn + "'."); - } - return null; - } - - Iterator<ObjectModelElement> itr = elems.iterator(); - while (itr.hasNext()) { - ObjectModelElement element = itr.next(); - if (element == null) { - if (log.isWarnEnabled()) { - log.warn("Invalid " + type + " [" + key + "] : Element '" + targetName + "' of type '" + target + "' on classifier '" + fqn + "' is null."); - } - itr.remove(); - } - } - - return elems; - } -} diff --git a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/package-info.java b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/package-info.java index b70f596..88f6c0a 100644 --- a/eugene/src/main/java/org/nuiton/eugene/models/stereotype/package-info.java +++ b/eugene/src/main/java/org/nuiton/eugene/models/stereotype/package-info.java @@ -23,7 +23,7 @@ /** * This package contains stereotype API. * - * <strong>Note:</strong> Replace the deprecated class {@link org.nuiton.eugene.ModelPropertiesUtil}. + * <strong>Note:</strong> Replace the deprecated class {@code org.nuiton.eugene.ModelPropertiesUtil}. * * @since 2.9 */ diff --git a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/package-info.java b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/package-info.java index 3aedf75..99b209f 100644 --- a/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/package-info.java +++ b/eugene/src/main/java/org/nuiton/eugene/models/tagvalue/package-info.java @@ -23,7 +23,7 @@ /** * This package contains tag value API. * - * <strong>Note:</strong> Replace the deprecated class {@link org.nuiton.eugene.ModelPropertiesUtil}. + * <strong>Note:</strong> Replace the deprecated class {@code org.nuiton.eugene.ModelPropertiesUtil}. * * @since 2.9 */ diff --git a/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterConfiguration.java b/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterConfiguration.java index 3170d21..301be8f 100644 --- a/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterConfiguration.java +++ b/eugene/src/main/java/org/nuiton/eugene/writer/ChainedFileWriterConfiguration.java @@ -23,8 +23,6 @@ package org.nuiton.eugene.writer; import org.nuiton.eugene.ModelHelper; -import org.nuiton.eugene.ModelReader; -import org.nuiton.eugene.Template; import java.io.File; import java.util.Map; @@ -83,20 +81,6 @@ public interface ChainedFileWriterConfiguration { */ ModelHelper getModelHelper(); - /** - * @return the universe of available model readers - * @deprecated since 2.6.3 (no more used, replaced by {@link ModelHelper#getModelReaders()}. - */ - @Deprecated - Map<String, ModelReader<?>> getModelReaders(); - - /** - * @return the universe of available model templates - * @deprecated since 2.6.3, no more used, won't be replaced - */ - @Deprecated - Map<String, Template<?>> getModelTemplates(); - /** @return properties to pass to writers */ Map<String, Object> getProperties(); diff --git a/eugene/src/test/java/org/nuiton/eugene/EugeneStereotypesTest.java b/eugene/src/test/java/org/nuiton/eugene/EugeneStereotypesTest.java index 4471669..086c9b1 100644 --- a/eugene/src/test/java/org/nuiton/eugene/EugeneStereotypesTest.java +++ b/eugene/src/test/java/org/nuiton/eugene/EugeneStereotypesTest.java @@ -48,12 +48,12 @@ public class EugeneStereotypesTest { @Test public void validate() throws Exception { - validate(EugeneStereoTypes.STEREOTYPE_INDEXED, true, ObjectModelAttribute.class); + validate(EugeneStereoTypes.STEREOTYPE_ORDERED, true, ObjectModelAttribute.class); - validate(EugeneStereoTypes.STEREOTYPE_INDEXED, false, ObjectModel.class, ObjectModelOperation.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class, ObjectModelInterface.class); + validate(EugeneStereoTypes.STEREOTYPE_ORDERED, false, ObjectModel.class, ObjectModelOperation.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class, ObjectModelInterface.class); long l = System.nanoTime(); - validate(EugeneStereoTypes.STEREOTYPE_INDEXED + l, false, ObjectModel.class, ObjectModelOperation.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class, ObjectModelInterface.class); + validate(EugeneStereoTypes.STEREOTYPE_ORDERED + l, false, ObjectModel.class, ObjectModelOperation.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class, ObjectModelInterface.class); } -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.