Author: tchemit Date: 2012-08-16 18:18:14 +0200 (Thu, 16 Aug 2012) New Revision: 2620 Url: http://nuiton.org/repositories/revision/topia/2620 Log: refs #2260: Add a metadata package in persistence Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/AssociationMeta.java branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/ColumnMeta.java branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/MetaFilenameAware.java branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TopiaEntityEnumProvider.java branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/package-info.java Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/AssociationMeta.java =================================================================== --- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/AssociationMeta.java (rev 0) +++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/AssociationMeta.java 2012-08-16 16:18:14 UTC (rev 2620) @@ -0,0 +1,146 @@ +package org.nuiton.topia.persistence.metadata; +/* + * #%L + * ToPIA :: Persistence + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 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 com.google.common.base.Charsets; +import org.nuiton.topia.TopiaRuntimeException; +import org.nuiton.topia.persistence.TopiaEntity; +import org.nuiton.topia.persistence.TopiaEntityEnum; +import org.nuiton.topia.persistence.util.EntityOperator; +import org.nuiton.topia.persistence.util.EntityOperatorStore; +import org.nuiton.util.ObjectUtil; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.OutputStreamWriter; +import java.io.Serializable; +import java.io.Writer; +import java.util.Collection; + +/** + * Define the meta data of a entity association field. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.6.12 + */ +public class AssociationMeta<T extends TopiaEntityEnum> implements Serializable, MetaFilenameAware<T> { + + private static final long serialVersionUID = 1L; + + /** Association source entity type. */ + protected final T source; + + /** Association target entity type. */ + protected final T target; + + /** Name fo the association. */ + protected final String name; + + /** Operator of the source entity used to get / set associations. */ + protected transient EntityOperator<TopiaEntity> operator; + + protected static <T extends TopiaEntityEnum> AssociationMeta<T> newMeta(T source, + T target, + String name) { + return new AssociationMeta<T>(source, target, name); + } + + public AssociationMeta(T source, + T target, + String name) { + this.source = source; + this.target = target; + this.name = name; + } + + @Override + public T getSource() { + return source; + } + + @Override + public String getName() { + return name; + } + + @Override + public String getFilename() { + return source.name() + "_" + name + CSV_EXTENSION; + } + + @Override + public File newFile(File container) { + return new File(container, getFilename()); + } + + @Override + public Writer newWriter(File container) { + File file = newFile(container); + try { + return new OutputStreamWriter(new FileOutputStream(file), + Charsets.UTF_8); + } catch (FileNotFoundException e) { + throw new TopiaRuntimeException("Could not find file " + file); + } + } + + public T getTarget() { + return target; + } + + public TopiaEntity newEntity() { + return ObjectUtil.newInstance(source.getImplementation()); + } + + public Object newAssociation() { + return ObjectUtil.newInstance(target.getImplementation()); + } + + public Collection<TopiaEntity> getChilds(TopiaEntity entity) { + Object o = getOperator().get(name, entity); + return (Collection<TopiaEntity>) o; + } + + public void setChilds(TopiaEntity entity, Collection<TopiaEntity> childs) { + getOperator().addAllChild(name, entity, childs); + } + + public boolean isChildEmpty(TopiaEntity entity) { + boolean result = getOperator().isChildEmpty(name, entity); + return result; + } + + public EntityOperator<TopiaEntity> getOperator() { + if (operator == null) { + operator = EntityOperatorStore.getOperator(source); + } + return operator; + } + + @Override + public String toString() { + return "<" + source + ":" + name + " " + target + ">"; + } +} Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/AssociationMeta.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/ColumnMeta.java =================================================================== --- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/ColumnMeta.java (rev 0) +++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/ColumnMeta.java 2012-08-16 16:18:14 UTC (rev 2620) @@ -0,0 +1,94 @@ +package org.nuiton.topia.persistence.metadata; +/* + * #%L + * ToPIA :: Persistence + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 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.topia.persistence.TopiaEntity; + +import java.io.Serializable; +import java.util.Date; + +/** + * Define the meta data of a entity field. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.6.12 + */ +public class ColumnMeta implements Serializable { + + protected static ColumnMeta newMeta(String name, Class<?> type) { + return new ColumnMeta(name, type); + } + + private static final long serialVersionUID = 1L; + + /** Name of the column. */ + protected String name; + + /** Type of the column. */ + protected Class<?> type; + + public String getName() { + return name; + } + + public Class<?> getType() { + return type; + } + + public String getTypeSimpleName() { + return type.getSimpleName(); + } + + public String getColumnType() { + String result = "string"; + if (boolean.class.equals(type)) { + result = "boolean"; + } else if (Date.class.equals(type)) { + result = "date"; + } + return result; + } + + public boolean isFK() { + return TopiaEntity.class.isAssignableFrom(type); + } + + public boolean isDate() { + return Date.class.isAssignableFrom(type); + } + + public boolean isBoolean() { + return boolean.class.equals(type); + } + + public boolean isNumber() { + return !isBoolean() && (type.isPrimitive() || Number.class.isAssignableFrom(type)); + } + + protected ColumnMeta(String name, Class<?> type) { + this.name = name; + this.type = type; + } + +} Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/ColumnMeta.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java =================================================================== --- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java (rev 0) +++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java 2012-08-16 16:18:14 UTC (rev 2620) @@ -0,0 +1,97 @@ +package org.nuiton.topia.persistence.metadata; +/* + * #%L + * ToPIA :: Persistence + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 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 com.google.common.base.Preconditions; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import org.nuiton.topia.persistence.TopiaEntityEnum; + +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +/** + * Define metas about a db. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.6.12 + */ +public class DbMeta<T extends TopiaEntityEnum> implements Iterable<TableMeta<T>> { + + /** All metas of the db. */ + protected final List<TableMeta<T>> tables; + + /** All types non editables. */ + protected final Set<T> nonEditableTypes; + + public static <T extends TopiaEntityEnum> DbMeta<T> newDbMeta(T[] universe, + T[] nonEditables, + TopiaEntityEnumProvider<T> typeProvider) { + return new DbMeta<T>(universe, nonEditables, typeProvider); + } + + public List<String> getTableNames() { + List<String> result = Lists.newArrayList(); + for (TableMeta tableMeta : getTables()) { + result.add(tableMeta.getName()); + } + return result; + } + + public List<TableMeta<T>> getTables() { + return tables; + } + + public TableMeta<T> getTable(T entityType) { + Preconditions.checkNotNull(entityType); + TableMeta<T> result = null; + for (TableMeta<T> tableMeta : getTables()) { + if (entityType.equals(tableMeta.getSource())) { + result = tableMeta; + break; + } + } + return result; + } + + @Override + public Iterator<TableMeta<T>> iterator() { + return getTables().iterator(); + } + + protected DbMeta(T[] entityTypes, T[] nonEditableTypes, TopiaEntityEnumProvider<T> typeProvider) { + this.nonEditableTypes = Sets.newHashSet(nonEditableTypes); + tables = Lists.newArrayList(); + for (T entityEnum : entityTypes) { + TableMeta<T> tableMeta = TableMeta.newMeta(entityEnum, typeProvider); + tables.add(tableMeta); + } + } + + public boolean isEditable(TableMeta<T> meta) { + return !nonEditableTypes.contains(meta.getSource()); + } +} Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/DbMeta.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/MetaFilenameAware.java =================================================================== --- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/MetaFilenameAware.java (rev 0) +++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/MetaFilenameAware.java 2012-08-16 16:18:14 UTC (rev 2620) @@ -0,0 +1,52 @@ +/* + * #%L + * EchoBase :: Entities + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, 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.topia.persistence.metadata; + +import org.nuiton.topia.persistence.TopiaEntityEnum; + +import java.io.File; +import java.io.Writer; + +/** + * Contract to import or export some metas. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.6.12 + */ +public interface MetaFilenameAware<T extends TopiaEntityEnum> { + + String CSV_EXTENSION = ".csv"; + + T getSource(); + + String getName(); + + String getFilename(); + + File newFile(File container); + + Writer newWriter(File container); + +} Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/MetaFilenameAware.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java =================================================================== --- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java (rev 0) +++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java 2012-08-16 16:18:14 UTC (rev 2620) @@ -0,0 +1,74 @@ +package org.nuiton.topia.persistence.metadata; +/* + * #%L + * ToPIA :: Persistence + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 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 com.google.common.base.Function; +import com.google.common.collect.Multimap; +import com.google.common.collect.Multimaps; +import org.nuiton.topia.persistence.TopiaEntityEnum; + +import java.util.List; + +/** + * USeful methods around metadatas. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.6.12 + */ +public class Metadatas { + + public static <T extends TopiaEntityEnum> void addEntries(DbMeta<T> dbMeta, + List<MetaFilenameAware<T>> entities, + List<MetaFilenameAware<T>> associations, + T... types) { + for (T type : types) { + + TableMeta<T> tableMeta = dbMeta.getTable(type); + if (entities != null) { + entities.add(tableMeta); + } + if (associations != null) { + associations.addAll(tableMeta.getAssociations()); + } + } + } + + public static <T extends TopiaEntityEnum> Multimap<T, MetaFilenameAware<T>> split(List<MetaFilenameAware<T>> metas) { + Function<MetaFilenameAware<T>, T> function = newMetaBySourcefunction(); + Multimap<T, MetaFilenameAware<T>> associationsBySource = Multimaps.index(metas, function); + return associationsBySource; + + } + + protected static <T extends TopiaEntityEnum> Function<MetaFilenameAware<T>, T> newMetaBySourcefunction() { + return new Function<MetaFilenameAware<T>, T>() { + + @Override + public T apply(MetaFilenameAware<T> input) { + return input.getSource(); + } + }; + } + +} Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/Metadatas.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java =================================================================== --- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java (rev 0) +++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java 2012-08-16 16:18:14 UTC (rev 2620) @@ -0,0 +1,256 @@ +package org.nuiton.topia.persistence.metadata; +/* + * #%L + * ToPIA :: Persistence + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 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 com.google.common.base.Charsets; +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import org.nuiton.topia.TopiaRuntimeException; +import org.nuiton.topia.persistence.TopiaEntity; +import org.nuiton.topia.persistence.TopiaEntityEnum; +import org.nuiton.topia.persistence.util.EntityOperator; +import org.nuiton.topia.persistence.util.EntityOperatorStore; +import org.nuiton.util.ObjectUtil; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderModelBuilder; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.OutputStreamWriter; +import java.io.Serializable; +import java.io.Writer; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Define metas of a given db table. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.6.12 + */ +public class TableMeta<T extends TopiaEntityEnum> implements Serializable, Iterable<ColumnMeta>, MetaFilenameAware<T> { + + private static final long serialVersionUID = 1L; + + public static <T extends TopiaEntityEnum> TableMeta newMeta(T entityEnum, + TopiaEntityEnumProvider<T> typeProvider) { + return new TableMeta<T>(entityEnum, typeProvider); + } + + /** Type of the entity. */ + protected final T source; + + /** List of columns of the entity. */ + protected List<ColumnMeta> columns; + + /** List of dependencies (says all property with a topiaentity type) */ + protected final Set<T> dependencies; + + /** List of associations of the entity. */ + protected List<AssociationMeta<T>> associations; + + /** Binder used to copy entities (lazy loaded). */ + protected Binder<TopiaEntity, TopiaEntity> binder; + + /** Entity operator used in generic algorithms. */ + protected transient EntityOperator<TopiaEntity> operator; + + protected boolean useNaturalIdsOrNotNulls; + + @Override + public T getSource() { + return source; + } + + @Override + public String getName() { + return source.name(); + } + + @Override + public String getFilename() { + return source.name() + ".csv"; + } + + @Override + public File newFile(File container) { + return new File(container, getFilename()); + } + + @Override + public Writer newWriter(File container) { + File file = newFile(container); + try { + return new OutputStreamWriter(new FileOutputStream(file), + Charsets.UTF_8); + } catch (FileNotFoundException e) { + throw new TopiaRuntimeException("Could not find file " + file); + } + } + + @Override + public String toString() { + return "<" + source + ">"; + } + + public Class<? extends TopiaEntity> getEntityType() { + return source.getContract(); + } + + public ColumnMeta getColumns(String columnName) { + Preconditions.checkNotNull(columnName); + ColumnMeta result = null; + for (ColumnMeta columnMeta : getColumns()) { + if (columnName.equals(columnMeta.getName())) { + result = columnMeta; + break; + } + } + return result; + } + + public String[] getColumnNamesAsArray() { + List<String> columnNames = getColumnNames(); + return columnNames.toArray(new String[columnNames.size()]); + } + + public List<String> getColumnNames() { + List<String> result = Lists.newLinkedList(); + for (ColumnMeta columnMeta : getColumns()) { + result.add(columnMeta.getName()); + } + return result; + } + + public List<ColumnMeta> getColumns() { + return columns; + } + + public List<AssociationMeta<T>> getAssociations() { + return associations; + } + + public Set<T> getDependencies() { + return dependencies; + } + + public AssociationMeta<T> getAssociations(String name) { + AssociationMeta<T> result = null; + for (AssociationMeta<T> meta : getAssociations()) { + if (name.equals(meta.getName())) { + result = meta; + break; + } + } + return result; + } + + public void copy(TopiaEntity source, TopiaEntity target) { + getBinder().copy(source, target); + } + + public Map<String, Object> prepareCreate(TopiaEntity bean, + String topiaId) { + Map<String, Object> result = getOperator().getNaturalIsdAndNotNulls(bean); + if (topiaId != null) { + result.put(TopiaEntity.TOPIA_ID, topiaId); + } + return result; + } + + @Override + public Iterator<ColumnMeta> iterator() { + return getColumns().iterator(); + } + + public TopiaEntity newEntity() { + return ObjectUtil.newInstance(source.getImplementation()); + } + + protected Binder<TopiaEntity, TopiaEntity> getBinder() { + if (binder == null) { + BinderModelBuilder<TopiaEntity, TopiaEntity> binderModelBuilder = + (BinderModelBuilder<TopiaEntity, TopiaEntity>) BinderModelBuilder.newEmptyBuilder(getEntityType()); + for (ColumnMeta columnMeta : this) { + binderModelBuilder.addSimpleProperties(columnMeta.getName()); + } + binder = binderModelBuilder.toBinder(); + } + return binder; + } + + protected TableMeta(T source, TopiaEntityEnumProvider<T> typeProvider) { + Preconditions.checkNotNull(source); + this.source = source; + + associations = Lists.newArrayList(); + columns = Lists.newLinkedList(); + Set<T> deps = Sets.newHashSet(); + + // fill associations + List<String> associationProperties = getOperator().getAssociationProperties(); + for (String property : associationProperties) { + Class<?> propertyType = getOperator().getAssociationPropertyType(property); + if (TopiaEntity.class.isAssignableFrom(propertyType)) { + + // only use it for entity + T targetEnum = typeProvider.getEntityEnum(propertyType); + + AssociationMeta<T> meta = AssociationMeta.newMeta(source, + targetEnum, + property + ); + associations.add(meta); + } + } + + // fill properties (remove all asociations) + List<String> properties = Lists.newArrayList(getOperator().getProperties()); + properties.removeAll(associationProperties); + for (String property : properties) { + Class<?> propertyType = getOperator().getPropertyType(property); + ColumnMeta meta = ColumnMeta.newMeta(property, propertyType); + columns.add(meta); + if (meta.isFK()) { + T dependency = typeProvider.getEntityEnum(propertyType); + deps.add(dependency); + } + } + dependencies = deps; + + useNaturalIdsOrNotNulls = source.isUseNotNulls() || + source.isUseNaturalIds(); + } + + public EntityOperator<TopiaEntity> getOperator() { + if (operator == null) { + operator = EntityOperatorStore.getOperator(source); + } + return operator; + } +} Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TableMeta.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TopiaEntityEnumProvider.java =================================================================== --- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TopiaEntityEnumProvider.java (rev 0) +++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TopiaEntityEnumProvider.java 2012-08-16 16:18:14 UTC (rev 2620) @@ -0,0 +1,38 @@ +package org.nuiton.topia.persistence.metadata; +/* + * #%L + * ToPIA :: Persistence + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 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.topia.persistence.TopiaEntityEnum; + +/** + * Provider of {@link TopiaEntityEnum}. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.6.12 + */ +public interface TopiaEntityEnumProvider<T extends TopiaEntityEnum> { + + <E> T getEntityEnum(Class<E> type); + +} Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/TopiaEntityEnumProvider.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/package-info.java =================================================================== --- branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/package-info.java (rev 0) +++ branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/package-info.java 2012-08-16 16:18:14 UTC (rev 2620) @@ -0,0 +1,7 @@ +/** + * Package to define metadatas over {@link TopiaEntity}. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.6.12 + */ +package org.nuiton.topia.persistence.metadata; \ No newline at end of file Property changes on: branches/topia-2.6.x/topia-persistence/src/main/java/org/nuiton/topia/persistence/metadata/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native