Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Spring 2.0.5 #256

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lightadmin-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<artifactId>lightadmin</artifactId>
<packaging>jar</packaging>

<version>1.2.0.BUILD-SNAPSHOT</version>
<version>1.3.1.BUILD-SNAPSHOT</version>

<name>LightAdmin</name>
<description>Pluggable data management solution for Java web applications developed in a "Rapid" manner
Expand Down Expand Up @@ -95,7 +95,7 @@
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>

<spring.platform.version>1.1.2.RELEASE</spring.platform.version>
<spring.platform.version>2.0.5.RELEASE</spring.platform.version>

<commons-collections4.version>4.0</commons-collections4.version>
<imgscalr-lib.version>4.2</imgscalr-lib.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public static JspFragmentFieldControl wysiwyg() {
return new JspFragmentFieldControl("/views/editors/wysiwyg-field-edit-control.jsp");
}

public static JspFragmentFieldControl readOnly() {
return new JspFragmentFieldControl("/views/editors/readonly-field-control.jsp");
}

public static JspFragmentFieldControl enumeration(List<EnumElement> elements) {
return new EnumFieldEditControl(elements);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import javax.persistence.EntityManager;
import javax.persistence.metamodel.ManagedType;
import javax.persistence.metamodel.Metamodel;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

Expand Down Expand Up @@ -50,7 +52,8 @@ protected JpaMetamodelMappingContext createInstance() throws Exception {
}
}

JpaMetamodelMappingContext context = new JpaMetamodelMappingContext(metamodel);
Set<Metamodel> metaModelSet = new HashSet<>(Collections.singletonList(metamodel));
JpaMetamodelMappingContext context = new JpaMetamodelMappingContext(metaModelSet);
context.setInitialEntitySet(entitySources);
context.initialize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.repository.support.Repositories;
import org.springframework.data.repository.support.RepositoryInvokerFactory;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.core.event.ValidatingRepositoryEventListener;
import org.springframework.data.rest.core.invoke.RepositoryInvokerFactory;
import org.springframework.data.rest.core.support.DomainObjectMerger;
import org.springframework.data.rest.webmvc.RepositoryRestController;
import org.springframework.data.rest.webmvc.config.PersistentEntityResourceAssemblerArgumentResolver;
Expand All @@ -44,6 +44,7 @@
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;

import java.net.URI;
import java.util.List;

import static com.google.common.collect.Lists.newLinkedList;
Expand Down Expand Up @@ -113,7 +114,7 @@ public FileManipulationRepositoryEventListener domainRepositoryEventListener(Glo
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
config.setDefaultPageSize(10);
config.setBaseUri(lightAdminConfiguration().getApplicationRestBaseUrl());
config.setBasePath(lightAdminConfiguration().getApplicationRestBaseUrl().toString());
config.exposeIdsFor(globalAdministrationConfiguration().getAllDomainTypesAsArray());
config.setReturnBodyOnCreate(true);
config.setReturnBodyOnUpdate(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@

import javax.servlet.Filter;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Properties;
import java.util.*;

import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Maps.newLinkedHashMap;
Expand Down Expand Up @@ -109,7 +106,7 @@ public FilterChainProxy springSecurityFilterChain(Filter filterSecurityIntercept
public Filter filterSecurityInterceptor(AuthenticationManager authenticationManager) throws Exception {
FilterSecurityInterceptor filter = new FilterSecurityInterceptor();
filter.setAuthenticationManager(authenticationManager);
filter.setAccessDecisionManager(new AffirmativeBased(asList((AccessDecisionVoter) new RoleVoter())));
filter.setAccessDecisionManager(new AffirmativeBased(Arrays.<AccessDecisionVoter<? extends Object>>asList((AccessDecisionVoter<Object>) new RoleVoter())));
filter.setSecurityMetadataSource(securityMetadataSource());
filter.afterPropertiesSet();
return filter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.lightadmin.core.config.domain.common;

import java.util.TreeSet;
import org.lightadmin.api.config.builder.FieldSetConfigurationUnitBuilder;
import org.lightadmin.api.config.unit.FieldSetConfigurationUnit;
import org.lightadmin.api.config.utils.FieldValueRenderer;
Expand All @@ -28,6 +29,15 @@ public class GenericFieldSetConfigurationUnitBuilder extends AbstractFieldSetCon
implements FieldSetConfigurationUnitBuilder {

private final FieldSetConfigurationUnit configurationUnit;
private static final TreeSet<String> internalLAFields = new TreeSet();

static {
internalLAFields.add("StringRepresentation");
internalLAFields.add("ManagedDomainType");
internalLAFields.add("PrimaryKey");
internalLAFields.add("DomainLink");
internalLAFields.add("DynamicProperties");
}

public GenericFieldSetConfigurationUnitBuilder(Class<?> domainType, DomainConfigurationUnitType configurationUnitType) {
super(domainType);
Expand Down Expand Up @@ -64,7 +74,7 @@ public FieldSetConfigurationUnit build() {

@Override
protected void addCurrentFieldToUnit() {
if (currentFieldMetadata != null) {
if (currentFieldMetadata != null && !internalLAFields.contains(currentFieldMetadata.getName())) {
configurationUnit.addField(currentFieldMetadata);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.rest.core.invoke.RepositoryInvoker;
import org.springframework.data.repository.support.RepositoryInvoker;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import org.lightadmin.core.persistence.repository.DynamicJpaRepository;
import org.springframework.data.repository.support.Repositories;
import org.springframework.data.rest.core.invoke.RepositoryInvoker;
import org.springframework.data.rest.core.invoke.RepositoryInvokerFactory;
import org.springframework.data.repository.support.RepositoryInvoker;
import org.springframework.data.repository.support.RepositoryInvokerFactory;

public class DynamicRepositoryInvokerFactory implements RepositoryInvokerFactory {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.rest.core.invoke.RepositoryInvoker;
import org.springframework.data.repository.support.RepositoryInvoker;
import org.springframework.util.MultiValueMap;

import java.io.Serializable;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -93,38 +94,23 @@ public boolean hasSaveMethod() {
return repositoryInvoker.hasSaveMethod();
}

@Override
public boolean exposesSave() {
return repositoryInvoker.exposesSave();
}

@Override
public boolean hasDeleteMethod() {
return repositoryInvoker.hasDeleteMethod();
}

@Override
public boolean exposesDelete() {
return repositoryInvoker.exposesDelete();
}

@Override
public boolean hasFindOneMethod() {
return repositoryInvoker.hasFindOneMethod();
}

@Override
public boolean exposesFindOne() {
return repositoryInvoker.exposesFindOne();
}

@Override
public boolean hasFindAllMethod() {
return repositoryInvoker.hasFindAllMethod();
}

@Override
public boolean exposesFindAll() {
return repositoryInvoker.exposesFindAll();
public Object invokeQueryMethod(Method method, MultiValueMap<String, ? extends Object> multiValueMap, Pageable pageable, Sort sort) {
return repositoryInvoker.invokeQueryMethod(method, multiValueMap, pageable, sort);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.mapping.PersistentProperty;
import org.springframework.data.rest.core.invoke.RepositoryInvoker;
import org.springframework.data.repository.support.RepositoryInvoker;
import org.springframework.data.rest.webmvc.RepositoryRestController;
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
import org.springframework.data.rest.webmvc.RootResourceInformation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,28 @@ public void doWithAssociation(Association<? extends PersistentProperty<?>> assoc

for (FieldMetadata field : fieldForUnit) {
if (persistentFieldMetadataPredicate().apply(field)) {
addPersistentProperty((PersistentFieldMetadata) field, unitType, jsonConfigurationMetadata);
addPersistentProperty((PersistentFieldMetadata) field, unitType.toString(), jsonConfigurationMetadata);
}

if (customFieldMetadataPredicate().apply(field)) {
jsonConfigurationMetadata.addDynamicProperty((CustomFieldMetadata) field, unitType);
jsonConfigurationMetadata.addDynamicProperty((CustomFieldMetadata) field, unitType.toString());
}

if (transientFieldMetadataPredicate().apply(field)) {
jsonConfigurationMetadata.addDynamicProperty((TransientFieldMetadata) field, unitType);
jsonConfigurationMetadata.addDynamicProperty((TransientFieldMetadata) field, unitType.toString());
}
}
}

return jsonConfigurationMetadata;
}

private void addPersistentProperty(PersistentFieldMetadata field, DomainConfigurationUnitType unitType, JsonConfigurationMetadata jsonConfigurationMetadata) {
private void addPersistentProperty(PersistentFieldMetadata field, String unitType, JsonConfigurationMetadata jsonConfigurationMetadata) {
PersistentProperty persistentProperty = field.getPersistentProperty();
if (persistentProperty.isAssociation()) {
jsonConfigurationMetadata.addAssociationProperty(field, associationRestLinkTemplate(persistentProperty), unitType);
jsonConfigurationMetadata.addAssociationProperty(field, associationRestLinkTemplate(persistentProperty), unitType.toString());
} else {
jsonConfigurationMetadata.addPersistentProperty(field, unitType);
jsonConfigurationMetadata.addPersistentProperty(field, unitType.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.lightadmin.core.config.domain.field.CustomFieldMetadata;
import org.lightadmin.core.config.domain.field.PersistentFieldMetadata;
import org.lightadmin.core.config.domain.field.TransientFieldMetadata;
import org.lightadmin.core.config.domain.unit.DomainConfigurationUnitType;
import org.lightadmin.core.persistence.metamodel.PersistentPropertyType;
import org.springframework.data.mapping.Association;
import org.springframework.data.mapping.PersistentProperty;
Expand All @@ -34,6 +33,7 @@
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY;
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
import static com.google.common.collect.Maps.newLinkedHashMap;
import java.util.TreeSet;
import static org.lightadmin.core.persistence.metamodel.PersistentPropertyType.STRING;
import static org.lightadmin.core.persistence.metamodel.PersistentPropertyType.UNKNOWN;

Expand All @@ -43,8 +43,17 @@ public class JsonConfigurationMetadata extends Resource<Map<String, JsonConfigur

private String name;
private boolean managedDomainType;
private static final TreeSet<String> lightAdminProperties = new TreeSet();

static {
lightAdminProperties.add("stringRepresentation");
lightAdminProperties.add("managedDomainType");
lightAdminProperties.add("primaryKey");
lightAdminProperties.add("domainLink");
lightAdminProperties.add("dynamicProperties");
}

private Map<DomainConfigurationUnitType, Map<String, Property>> dynamicProperties;
private Map<String, Map<String, Property>> dynamicProperties;

public JsonConfigurationMetadata(String name, boolean managedDomainType) {
super(Maps.<String, JsonConfigurationMetadata.Property>newLinkedHashMap());
Expand All @@ -66,7 +75,7 @@ public boolean isManagedDomainType() {

@JsonProperty("dynamic_properties")
@JsonInclude(NON_EMPTY)
public Map<DomainConfigurationUnitType, Map<String, Property>> getDynamicProperties() {
public Map<String, Map<String, Property>> getDynamicProperties() {
return dynamicProperties;
}

Expand All @@ -84,7 +93,7 @@ public JsonConfigurationMetadata addAssociationProperty(Association association,
return this;
}

public JsonConfigurationMetadata addAssociationProperty(Association association, Link restTemplateLink, DomainConfigurationUnitType unitType) {
public JsonConfigurationMetadata addAssociationProperty(Association association, Link restTemplateLink, String unitType) {
PersistentProperty persistentProperty = association.getInverse();
String persistentPropertyName = persistentProperty.getName();

Expand All @@ -93,7 +102,7 @@ public JsonConfigurationMetadata addAssociationProperty(Association association,
return this;
}

public JsonConfigurationMetadata addAssociationProperty(PersistentFieldMetadata persistentFieldMetadata, Link restTemplateLink, DomainConfigurationUnitType unitType) {
public JsonConfigurationMetadata addAssociationProperty(PersistentFieldMetadata persistentFieldMetadata, Link restTemplateLink, String unitType) {
PersistentProperty persistentProperty = persistentFieldMetadata.getPersistentProperty().getAssociation().getInverse();
String persistentPropertyName = persistentProperty.getName();
String persistentPropertyTitle = persistentFieldMetadata.getName();
Expand All @@ -106,20 +115,22 @@ public JsonConfigurationMetadata addAssociationProperty(PersistentFieldMetadata
public JsonConfigurationMetadata addPersistentProperty(PersistentProperty persistentProperty) {
String persistentPropertyName = persistentProperty.getName();

addProperty(persistentPropertyName, newProperty(persistentProperty, persistentPropertyName));
if (!lightAdminProperties.contains(persistentPropertyName)) {
addProperty(persistentPropertyName, newProperty(persistentProperty, persistentPropertyName));
}

return this;
}

public JsonConfigurationMetadata addPersistentProperty(PersistentProperty persistentProperty, DomainConfigurationUnitType unitType) {
public JsonConfigurationMetadata addPersistentProperty(PersistentProperty persistentProperty, String unitType) {
String persistentPropertyName = persistentProperty.getName();

addDynamicProperty(persistentPropertyName, newProperty(persistentProperty, persistentPropertyName), unitType);

return this;
}

public JsonConfigurationMetadata addPersistentProperty(PersistentFieldMetadata persistentField, DomainConfigurationUnitType unitType) {
public JsonConfigurationMetadata addPersistentProperty(PersistentFieldMetadata persistentField, String unitType) {
PersistentProperty persistentProperty = persistentField.getPersistentProperty();
String persistentPropertyName = persistentProperty.getName();
String persistentPropertyTitle = persistentField.getName();
Expand All @@ -129,27 +140,29 @@ public JsonConfigurationMetadata addPersistentProperty(PersistentFieldMetadata p
return this;
}

public JsonConfigurationMetadata addDynamicProperty(TransientFieldMetadata transientField, DomainConfigurationUnitType unitType) {
public JsonConfigurationMetadata addDynamicProperty(TransientFieldMetadata transientField, String unitType) {
Property property = new Property(transientField.getUuid(), transientField.getName(), UNKNOWN, false, false);

addDynamicProperty(transientField.getUuid(), property, unitType);

return this;
}

public JsonConfigurationMetadata addDynamicProperty(CustomFieldMetadata customField, DomainConfigurationUnitType unitType) {
public JsonConfigurationMetadata addDynamicProperty(CustomFieldMetadata customField, String unitType) {
Property property = new Property(customField.getUuid(), customField.getName(), STRING, false, false);

addDynamicProperty(customField.getUuid(), property, unitType);

return this;
}

private JsonConfigurationMetadata addDynamicProperty(String name, Property property, DomainConfigurationUnitType configurationUnitType) {
private JsonConfigurationMetadata addDynamicProperty(String name, Property property, String configurationUnitType) {
if (!dynamicProperties.containsKey(configurationUnitType)) {
dynamicProperties.put(configurationUnitType, Maps.<String, Property>newLinkedHashMap());
}
dynamicProperties.get(configurationUnitType).put(name, property);
if (!lightAdminProperties.contains(name)) {
dynamicProperties.get(configurationUnitType).put(name, property);
}
return this;
}

Expand Down Expand Up @@ -185,6 +198,7 @@ public Link getRestLink() {
}

static class Property {

private String name;
private String title;
private String type;
Expand Down Expand Up @@ -219,4 +233,4 @@ public boolean isPrimaryKey() {
return primaryKey;
}
}
}
}
Loading