remove old code

This commit is contained in:
Efstratios Giannopoulos 2024-02-01 16:58:05 +02:00
parent 46c19f61a1
commit 8524213d14
18 changed files with 26 additions and 143 deletions

View File

@ -1,5 +0,0 @@
package eu.eudat.commons.types.common;
public interface DatabaseDefinition {
}

View File

@ -1,7 +0,0 @@
package eu.eudat.commons.types.common;
import eu.eudat.commons.types.common.DatabaseDefinition;
public interface DatabaseModelDefinition extends DatabaseDefinition {
}

View File

@ -1,7 +0,0 @@
package eu.eudat.commons.types.common;
import eu.eudat.commons.types.common.DatabaseDefinition;
public interface DatabaseViewStyleDefinition extends DatabaseDefinition {
}

View File

@ -1,14 +1,13 @@
package eu.eudat.commons.types.descriptiontemplate;
import eu.eudat.commons.enums.FieldValidationType;
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
import eu.eudat.commons.types.descriptiontemplate.fielddata.*;
import jakarta.xml.bind.annotation.*;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class FieldEntity implements DatabaseViewStyleDefinition {
public class FieldEntity {
@XmlAttribute(name="id")
private String id;
@XmlAttribute(name="ordinal")

View File

@ -1,13 +1,12 @@
package eu.eudat.commons.types.descriptiontemplate;
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
import jakarta.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class FieldSetEntity implements DatabaseViewStyleDefinition {
public class FieldSetEntity {
@XmlAttribute(name="id")
private String id;
@XmlAttribute(name="ordinal")

View File

@ -1,6 +1,5 @@
package eu.eudat.commons.types.descriptiontemplate;
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
import jakarta.xml.bind.annotation.*;
import java.util.ArrayList;
@ -8,7 +7,7 @@ import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class PageEntity implements DatabaseViewStyleDefinition {
public class PageEntity {
@XmlAttribute(name="id")
private String id;
@XmlAttribute(name="ordinal")

View File

@ -1,13 +1,12 @@
package eu.eudat.commons.types.descriptiontemplate;
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
import jakarta.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public class SectionEntity implements DatabaseViewStyleDefinition{
public class SectionEntity{
@XmlAttribute(name="id")
private String id;
@XmlAttribute(name="ordinal")

View File

@ -1,58 +0,0 @@
package eu.eudat.logic.utilities.builders;
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
import eu.eudat.commons.types.common.DatabaseModelDefinition;
import eu.eudat.logic.utilities.interfaces.ModelDefinition;
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
public class ModelBuilder {
private static final Logger logger = LoggerFactory.getLogger(ModelBuilder.class);
public <U extends ModelDefinition<T>, T extends DatabaseModelDefinition> List<T> toModelDefinition(List<U> items, Class<T> clazz) {
List<T> list = new LinkedList<T>();
for (U item : items) {
try {
list.add(item.toDatabaseDefinition(clazz.newInstance()));
} catch (InstantiationException e) {
logger.error(e.getMessage(), e);
} catch (IllegalAccessException e) {
logger.error(e.getMessage(), e);
}
}
return list;
}
public <U extends ViewStyleDefinition<T>, T extends DatabaseViewStyleDefinition> List<T> toViewStyleDefinition(List<U> items, Class<T> clazz) {
List<T> list = new LinkedList<T>();
for (U item : items) {
try {
list.add(item.toDatabaseDefinition(clazz.newInstance()));
} catch (InstantiationException e) {
logger.error(e.getMessage(), e);
} catch (IllegalAccessException e) {
logger.error(e.getMessage(), e);
}
}
return list;
}
public <U extends ViewStyleDefinition<T>, T extends DatabaseViewStyleDefinition> List<U> fromViewStyleDefinition(List<T> items, Class<U> clazz) {
List<U> list = new LinkedList<U>();
for (T item : items) {
try {
U modelItem = clazz.newInstance();
modelItem.fromDatabaseDefinition(item);
list.add(modelItem);
} catch (InstantiationException e) {
logger.error(e.getMessage(), e);
} catch (IllegalAccessException e) {
logger.error(e.getMessage(), e);
}
}
return list;
}
}

View File

@ -1,8 +0,0 @@
package eu.eudat.logic.utilities.helpers;
import eu.eudat.commons.types.common.DatabaseModelDefinition;
public interface ModelSerializer<T, U extends DatabaseModelDefinition> {
void fromDatabaseDefinition(T viewStyle, U model);
}

View File

@ -1,9 +0,0 @@
package eu.eudat.logic.utilities.interfaces;
import eu.eudat.commons.types.common.DatabaseModelDefinition;
public interface ModelDefinition<T extends DatabaseModelDefinition> {
T toDatabaseDefinition(T item);
void fromDatabaseDefinition(T item);
}

View File

@ -1,8 +0,0 @@
package eu.eudat.logic.utilities.interfaces;
import eu.eudat.commons.types.common.DatabaseModelDefinition;
public interface ModelSerializer<T, U extends DatabaseModelDefinition> {
void fromDatabaseDefinition(T viewStyle, U model);
}

View File

@ -1,7 +1,6 @@
package eu.eudat.models.data.admin.components.datasetprofile;
import eu.eudat.commons.enums.FieldValidationType;
import eu.eudat.commons.types.common.DatabaseViewStyleDefinition;
import eu.eudat.model.publicapi.datasetwizard.DefaultValueEntity;
import eu.eudat.model.publicapi.datasetwizard.FieldDescriptionEntity;
import eu.eudat.model.publicapi.datasetwizard.VisibilityEntity;
@ -13,7 +12,7 @@ import org.apache.commons.lang3.RandomStringUtils;
import java.util.List;
import java.util.stream.Collectors;
public class Field implements DatabaseViewStyleDefinition, ViewStyleDefinition<FieldEntity>, Comparable {
public class Field implements ViewStyleDefinition<FieldEntity>, Comparable {
private String id;
private Integer ordinal;

View File

@ -1,9 +1,7 @@
package eu.eudat.models.data.admin.components.datasetprofile;
import eu.eudat.commons.types.descriptiontemplate.MultiplicityEntity;
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
import eu.eudat.logic.utilities.builders.ModelBuilder;
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
import org.apache.commons.lang3.RandomStringUtils;
@ -90,8 +88,8 @@ public class FieldSet implements Comparable, ViewStyleDefinition<FieldSetEntity>
@Override
public FieldSetEntity toDatabaseDefinition(FieldSetEntity item) {
if (this.id == null || this.id.isEmpty()) this.id = "fieldSet_" + RandomStringUtils.random(5, true, true);
List<FieldEntity> viewStyleFieldEntities = new ModelBuilder().toViewStyleDefinition(this.fields, FieldEntity.class);
item.setFields(viewStyleFieldEntities);
// List<FieldEntity> viewStyleFieldEntities = new ModelBuilder().toViewStyleDefinition(this.fields, FieldEntity.class);
// item.setFields(viewStyleFieldEntities);
item.setId(this.id);
item.setDescription(this.description);
item.setTitle(this.title);
@ -106,7 +104,7 @@ public class FieldSet implements Comparable, ViewStyleDefinition<FieldSetEntity>
@Override
public void fromDatabaseDefinition(FieldSetEntity item) {
this.fields = new ModelBuilder().fromViewStyleDefinition(item.getFields(), Field.class);
// this.fields = new ModelBuilder().fromViewStyleDefinition(item.getFields(), Field.class);
this.id = item.getId();
this.ordinal = item.getOrdinal();
this.description = item.getDescription();

View File

@ -1,8 +1,6 @@
package eu.eudat.models.data.admin.components.datasetprofile;
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
import eu.eudat.commons.types.descriptiontemplate.SectionEntity;
import eu.eudat.logic.utilities.builders.ModelBuilder;
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
import org.apache.commons.lang3.RandomStringUtils;
@ -98,12 +96,12 @@ public class Section implements Comparable, ViewStyleDefinition<SectionEntity> {
item.setDefaultVisibility(this.defaultVisibility);
item.setDescription(this.description);
item.setMultiplicity(this.multiplicity);
if (this.fieldSets != null)
item.setFieldSets(new ModelBuilder().toViewStyleDefinition(this.fieldSets, FieldSetEntity.class));
// if (this.fieldSets != null)
// item.setFieldSets(new ModelBuilder().toViewStyleDefinition(this.fieldSets, FieldSetEntity.class));
item.setId(this.id);
item.setOrdinal(this.ordinal);
if (this.sections != null)
item.setSections(new ModelBuilder().toViewStyleDefinition(this.sections, SectionEntity.class));
// if (this.sections != null)
// item.setSections(new ModelBuilder().toViewStyleDefinition(this.sections, SectionEntity.class));
item.setTitle(this.title);
return item;
}
@ -113,10 +111,10 @@ public class Section implements Comparable, ViewStyleDefinition<SectionEntity> {
this.defaultVisibility = item.isDefaultVisibility();
this.description = item.getDescription();
this.fieldSets = new ModelBuilder().fromViewStyleDefinition(item.getFieldSets(), FieldSet.class);
// this.fieldSets = new ModelBuilder().fromViewStyleDefinition(item.getFieldSets(), FieldSet.class);
this.id = item.getId();
this.ordinal = item.getOrdinal();
this.sections = new ModelBuilder().fromViewStyleDefinition(item.getSections(), Section.class);
// this.sections = new ModelBuilder().fromViewStyleDefinition(item.getSections(), Section.class);
this.title = item.getTitle();
this.multiplicity = item.getMultiplicity();
}

View File

@ -1,7 +1,6 @@
package eu.eudat.models.data.admin.composite;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.logic.utilities.builders.ModelBuilder;
import eu.eudat.model.DmpUser;
import eu.eudat.models.data.admin.components.datasetprofile.Page;
import eu.eudat.models.data.admin.components.datasetprofile.Section;
@ -82,7 +81,7 @@ public class DatasetProfile {
public void buildProfile(DefinitionEntity viewStyle) {
// this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
// this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
}
public DatasetProfile toShort() {

View File

@ -1,9 +1,7 @@
package eu.eudat.models.data.user.components.datasetprofile;
import eu.eudat.commons.types.descriptiontemplate.MultiplicityEntity;
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
import eu.eudat.logic.utilities.builders.ModelBuilder;
import eu.eudat.models.data.properties.PropertiesGenerator;
import eu.eudat.models.data.user.composite.PropertiesModelBuilder;
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
@ -129,8 +127,8 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe
@Override
public FieldSetEntity toDatabaseDefinition(FieldSetEntity item) {
List<FieldEntity> viewStylefields = new ModelBuilder().toViewStyleDefinition(this.fields, FieldEntity.class);
item.setFields(viewStylefields);
// List<FieldEntity> viewStylefields = new ModelBuilder().toViewStyleDefinition(this.fields, FieldEntity.class);
// item.setFields(viewStylefields);
item.setId(this.id);
item.setOrdinal(this.ordinal);
item.setHasCommentField(this.hasCommentField);
@ -141,7 +139,7 @@ public class FieldSet implements Comparable, PropertiesModelBuilder, ViewStyleDe
@Override
public void fromDatabaseDefinition(FieldSetEntity item) {
this.fields = new ModelBuilder().fromViewStyleDefinition(item.getFields(), Field.class);
// this.fields = new ModelBuilder().fromViewStyleDefinition(item.getFields(), Field.class);
this.id = item.getId();
this.ordinal = item.getOrdinal();
this.title = item.getTitle();

View File

@ -1,8 +1,6 @@
package eu.eudat.models.data.user.components.datasetprofile;
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
import eu.eudat.commons.types.descriptiontemplate.SectionEntity;
import eu.eudat.logic.utilities.builders.ModelBuilder;
import eu.eudat.models.data.properties.PropertiesGenerator;
import eu.eudat.models.data.user.composite.PropertiesModelBuilder;
import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
@ -109,12 +107,12 @@ public class Section implements Comparable, ViewStyleDefinition<SectionEntity>,
public SectionEntity toDatabaseDefinition(SectionEntity item) {
item.setDefaultVisibility(this.defaultVisibility);
item.setDescription(this.description);
if (this.compositeFields != null)
item.setFieldSets(new ModelBuilder().toViewStyleDefinition(this.compositeFields, FieldSetEntity.class));
// if (this.compositeFields != null)
// item.setFieldSets(new ModelBuilder().toViewStyleDefinition(this.compositeFields, FieldSetEntity.class));
item.setId(this.id);
item.setOrdinal(this.ordinal);
if (this.sections != null)
item.setSections(new ModelBuilder().toViewStyleDefinition(this.sections, SectionEntity.class));
// if (this.sections != null)
// item.setSections(new ModelBuilder().toViewStyleDefinition(this.sections, SectionEntity.class));
item.setTitle(this.title);
item.setMultiplicity(this.multiplicity);
return item;
@ -124,11 +122,11 @@ public class Section implements Comparable, ViewStyleDefinition<SectionEntity>,
public void fromDatabaseDefinition(SectionEntity item) {
this.defaultVisibility = item.isDefaultVisibility();
this.description = item.getDescription();
this.compositeFields = new ModelBuilder().fromViewStyleDefinition(item.getFieldSets(), FieldSet.class);
// this.compositeFields = new ModelBuilder().fromViewStyleDefinition(item.getFieldSets(), FieldSet.class);
this.id = item.getId();
this.ordinal = item.getOrdinal();
this.numbering = item.getNumbering();
this.sections = new ModelBuilder().fromViewStyleDefinition(item.getSections(), Section.class);
// this.sections = new ModelBuilder().fromViewStyleDefinition(item.getSections(), Section.class);
this.title = item.getTitle();
this.multiplicity = item.getMultiplicity();
}

View File

@ -1,7 +1,6 @@
package eu.eudat.models.data.user.composite;
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
import eu.eudat.logic.utilities.builders.ModelBuilder;
import eu.eudat.models.data.admin.components.datasetprofile.Page;
import eu.eudat.models.data.user.components.commons.Rule;
import eu.eudat.models.data.user.components.datasetprofile.Section;
@ -77,8 +76,8 @@ public class DatasetProfile implements PropertiesModelBuilder {
}
public void buildProfile(DefinitionEntity viewStyle) {
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages().stream().map(x-> x.getSections()).flatMap(List::stream).toList(), Section.class);
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
// this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages().stream().map(x-> x.getSections()).flatMap(List::stream).toList(), Section.class);
// this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
this.rules = ModelBuilderCollector.collectRules(viewStyle.getPages().stream().map(x-> x.getSections()).flatMap(List::stream).toList());
}