From ae794482665dd4f14b7faccbcfbd6fcd07eb5ced Mon Sep 17 00:00:00 2001 From: Simon Schneider Date: Mon, 4 Jul 2016 20:50:48 +0200 Subject: [PATCH 1/4] Upgrade to Spring 2.0.5 --- lightadmin-core/pom.xml | 2 +- ...JpaMetamodelMappingContextFactoryBean.java | 5 ++++- ...htAdminRepositoryRestMvcConfiguration.java | 5 +++-- .../LightAdminSecurityConfiguration.java | 7 ++---- .../invoker/DynamicRepositoryInvoker.java | 2 +- .../DynamicRepositoryInvokerFactory.java | 4 ++-- .../DynamicRepositoryInvokerWrapper.java | 22 ++++--------------- .../web/RepositoryFilePropertyController.java | 2 +- ...amicPersistentEntityResourceAssembler.java | 8 ++++++- pom.xml | 2 +- 10 files changed, 26 insertions(+), 33 deletions(-) diff --git a/lightadmin-core/pom.xml b/lightadmin-core/pom.xml index 9aa8a28c..375f6c55 100644 --- a/lightadmin-core/pom.xml +++ b/lightadmin-core/pom.xml @@ -95,7 +95,7 @@ 1.7 1.7 - 1.1.2.RELEASE + 2.0.5.RELEASE 4.0 4.2 diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/config/bootstrap/JpaMetamodelMappingContextFactoryBean.java b/lightadmin-core/src/main/java/org/lightadmin/core/config/bootstrap/JpaMetamodelMappingContextFactoryBean.java index 82365dd7..00f2dbca 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/config/bootstrap/JpaMetamodelMappingContextFactoryBean.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/config/bootstrap/JpaMetamodelMappingContextFactoryBean.java @@ -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; @@ -50,7 +52,8 @@ protected JpaMetamodelMappingContext createInstance() throws Exception { } } - JpaMetamodelMappingContext context = new JpaMetamodelMappingContext(metamodel); + Set metaModelSet = new HashSet<>(Collections.singletonList(metamodel)); + JpaMetamodelMappingContext context = new JpaMetamodelMappingContext(metaModelSet); context.setInitialEntitySet(entitySources); context.initialize(); diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminRepositoryRestMvcConfiguration.java b/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminRepositoryRestMvcConfiguration.java index e643bb56..26afd46f 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminRepositoryRestMvcConfiguration.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminRepositoryRestMvcConfiguration.java @@ -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; @@ -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; @@ -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); diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminSecurityConfiguration.java b/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminSecurityConfiguration.java index 732790a0..af0bb636 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminSecurityConfiguration.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminSecurityConfiguration.java @@ -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; @@ -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.>asList((AccessDecisionVoter) new RoleVoter()))); filter.setSecurityMetadataSource(securityMetadataSource()); filter.afterPropertiesSet(); return filter; diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvoker.java b/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvoker.java index 7747c811..c8ef2b26 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvoker.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvoker.java @@ -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; diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerFactory.java b/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerFactory.java index a58a6faf..2f32d7b3 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerFactory.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerFactory.java @@ -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 { diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerWrapper.java b/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerWrapper.java index 75fe6f09..4d7684ec 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerWrapper.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerWrapper.java @@ -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; @@ -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 multiValueMap, Pageable pageable, Sort sort) { + return repositoryInvoker.invokeQueryMethod(method, multiValueMap, pageable, sort); } } \ No newline at end of file diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/web/RepositoryFilePropertyController.java b/lightadmin-core/src/main/java/org/lightadmin/core/web/RepositoryFilePropertyController.java index 4772104a..dfd4f323 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/web/RepositoryFilePropertyController.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/web/RepositoryFilePropertyController.java @@ -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; diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceAssembler.java b/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceAssembler.java index 827b5158..95942248 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceAssembler.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceAssembler.java @@ -16,6 +16,7 @@ package org.lightadmin.core.web.support; import org.springframework.data.mapping.PersistentEntity; +import org.springframework.data.mapping.context.PersistentEntities; import org.springframework.data.repository.core.EntityInformation; import org.springframework.data.repository.support.Repositories; import org.springframework.data.rest.core.mapping.ResourceMappings; @@ -37,7 +38,7 @@ public class DynamicPersistentEntityResourceAssembler extends PersistentEntityResourceAssembler { public DynamicPersistentEntityResourceAssembler(PersistentEntityResourceAssembler resourceAssembler) { - super(repositories(resourceAssembler), entityLinks(resourceAssembler), projector(resourceAssembler), mappings(resourceAssembler)); + super(entities(resourceAssembler), entityLinks(resourceAssembler), projector(resourceAssembler), mappings(resourceAssembler)); } /** @@ -66,7 +67,12 @@ public Link getSelfLinkFor(Object instance) { return entityLinks(this).linkToSingleResource(entity.getType(), id).withSelfRel(); } + private static PersistentEntities entities(PersistentEntityResourceAssembler persistentEntityResourceAssembler) { + return (PersistentEntities) forDirectFieldAccess(persistentEntityResourceAssembler).getPropertyValue("entities"); + } + private static Repositories repositories(PersistentEntityResourceAssembler persistentEntityResourceAssembler) { + //TODO: Repositories are no longer available! return (Repositories) forDirectFieldAccess(persistentEntityResourceAssembler).getPropertyValue("repositories"); } diff --git a/pom.xml b/pom.xml index 0f43fefa..e5b42235 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 1.7 1.7 - 1.1.2.RELEASE + 2.0.5.RELEASE 1.2 1.0.0.BUILD-SNAPSHOT From b4823b7019a40a273446180cc97d87f0b6fb5884 Mon Sep 17 00:00:00 2001 From: Luis Roca Date: Mon, 12 Sep 2016 13:01:35 -0500 Subject: [PATCH 2/4] Fix Spring Platform 2.0.5 compatibility: All entities should extend org.lightadmin.core.web.support.ManageableEntity in order to work as usual. Light admin nexus repository was removed as it is not active anymore. --- ...nericFieldSetConfigurationUnitBuilder.java | 12 ++- .../DomainTypeToJsonMetadataConverter.java | 12 +-- .../web/json/JsonConfigurationMetadata.java | 40 ++++++--- ...amicPersistentEntityResourceAssembler.java | 13 +-- ...amicPersistentEntityResourceProcessor.java | 90 +++---------------- .../core/web/support/ManageableEntity.java | 68 ++++++++++++++ .../resources/scripts/lightadmin-domain.js | 2 +- .../resources/META-INF/tags/data-table.tag | 4 +- lightadmin-sandbox/pom.xml | 20 ----- pom.xml | 8 +- 10 files changed, 139 insertions(+), 130 deletions(-) create mode 100644 lightadmin-core/src/main/java/org/lightadmin/core/web/support/ManageableEntity.java diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/config/domain/common/GenericFieldSetConfigurationUnitBuilder.java b/lightadmin-core/src/main/java/org/lightadmin/core/config/domain/common/GenericFieldSetConfigurationUnitBuilder.java index d738d30e..8dc890ab 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/config/domain/common/GenericFieldSetConfigurationUnitBuilder.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/config/domain/common/GenericFieldSetConfigurationUnitBuilder.java @@ -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; @@ -28,6 +29,15 @@ public class GenericFieldSetConfigurationUnitBuilder extends AbstractFieldSetCon implements FieldSetConfigurationUnitBuilder { private final FieldSetConfigurationUnit configurationUnit; + private static final TreeSet 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); @@ -64,7 +74,7 @@ public FieldSetConfigurationUnit build() { @Override protected void addCurrentFieldToUnit() { - if (currentFieldMetadata != null) { + if (currentFieldMetadata != null && !internalLAFields.contains(currentFieldMetadata.getName())) { configurationUnit.addField(currentFieldMetadata); } } diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/web/json/DomainTypeToJsonMetadataConverter.java b/lightadmin-core/src/main/java/org/lightadmin/core/web/json/DomainTypeToJsonMetadataConverter.java index e59ec2ae..fecc8167 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/web/json/DomainTypeToJsonMetadataConverter.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/web/json/DomainTypeToJsonMetadataConverter.java @@ -79,15 +79,15 @@ public void doWithAssociation(Association> 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()); } } } @@ -95,12 +95,12 @@ public void doWithAssociation(Association> assoc 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()); } } diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/web/json/JsonConfigurationMetadata.java b/lightadmin-core/src/main/java/org/lightadmin/core/web/json/JsonConfigurationMetadata.java index cad7f63b..b75d95a0 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/web/json/JsonConfigurationMetadata.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/web/json/JsonConfigurationMetadata.java @@ -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; @@ -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; @@ -43,8 +43,17 @@ public class JsonConfigurationMetadata extends Resource lightAdminProperties = new TreeSet(); + + static { + lightAdminProperties.add("stringRepresentation"); + lightAdminProperties.add("managedDomainType"); + lightAdminProperties.add("primaryKey"); + lightAdminProperties.add("domainLink"); + lightAdminProperties.add("dynamicProperties"); + } - private Map> dynamicProperties; + private Map> dynamicProperties; public JsonConfigurationMetadata(String name, boolean managedDomainType) { super(Maps.newLinkedHashMap()); @@ -66,7 +75,7 @@ public boolean isManagedDomainType() { @JsonProperty("dynamic_properties") @JsonInclude(NON_EMPTY) - public Map> getDynamicProperties() { + public Map> getDynamicProperties() { return dynamicProperties; } @@ -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(); @@ -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(); @@ -106,12 +115,14 @@ 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); @@ -119,7 +130,7 @@ public JsonConfigurationMetadata addPersistentProperty(PersistentProperty persis 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(); @@ -129,7 +140,7 @@ 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); @@ -137,7 +148,7 @@ public JsonConfigurationMetadata addDynamicProperty(TransientFieldMetadata trans 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); @@ -145,11 +156,13 @@ public JsonConfigurationMetadata addDynamicProperty(CustomFieldMetadata customFi 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.newLinkedHashMap()); } - dynamicProperties.get(configurationUnitType).put(name, property); + if (!lightAdminProperties.contains(name)) { + dynamicProperties.get(configurationUnitType).put(name, property); + } return this; } @@ -185,6 +198,7 @@ public Link getRestLink() { } static class Property { + private String name; private String title; private String type; @@ -219,4 +233,4 @@ public boolean isPrimaryKey() { return primaryKey; } } -} \ No newline at end of file +} diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceAssembler.java b/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceAssembler.java index 95942248..3e965562 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceAssembler.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceAssembler.java @@ -19,6 +19,7 @@ import org.springframework.data.mapping.context.PersistentEntities; import org.springframework.data.repository.core.EntityInformation; import org.springframework.data.repository.support.Repositories; +import org.springframework.data.rest.core.mapping.RepositoryResourceMappings; import org.springframework.data.rest.core.mapping.ResourceMappings; import org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler; import org.springframework.data.rest.webmvc.support.Projector; @@ -68,16 +69,16 @@ public Link getSelfLinkFor(Object instance) { } private static PersistentEntities entities(PersistentEntityResourceAssembler persistentEntityResourceAssembler) { - return (PersistentEntities) forDirectFieldAccess(persistentEntityResourceAssembler).getPropertyValue("entities"); + return (PersistentEntities) forDirectFieldAccess(persistentEntityResourceAssembler).getPropertyValue("entities"); } - + private static Repositories repositories(PersistentEntityResourceAssembler persistentEntityResourceAssembler) { - //TODO: Repositories are no longer available! - return (Repositories) forDirectFieldAccess(persistentEntityResourceAssembler).getPropertyValue("repositories"); + final RepositoryResourceMappings mappings = (RepositoryResourceMappings) forDirectFieldAccess(persistentEntityResourceAssembler).getPropertyValue("mappings"); + return (Repositories) forDirectFieldAccess(mappings).getPropertyValue("repositories"); } private static EntityLinks entityLinks(PersistentEntityResourceAssembler persistentEntityResourceAssembler) { - return (EntityLinks) forDirectFieldAccess(persistentEntityResourceAssembler).getPropertyValue("entityLinks"); + return DynamicRepositoryEntityLinks.wrap((EntityLinks) forDirectFieldAccess(persistentEntityResourceAssembler).getPropertyValue("entityLinks")); } private static Projector projector(PersistentEntityResourceAssembler persistentEntityResourceAssembler) { @@ -87,4 +88,4 @@ private static Projector projector(PersistentEntityResourceAssembler persistentE private static ResourceMappings mappings(PersistentEntityResourceAssembler persistentEntityResourceAssembler) { return (ResourceMappings) forDirectFieldAccess(persistentEntityResourceAssembler).getPropertyValue("mappings"); } -} \ No newline at end of file +} diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceProcessor.java b/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceProcessor.java index 2ee1616f..65e190e2 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceProcessor.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceProcessor.java @@ -47,7 +47,6 @@ import static org.lightadmin.core.config.domain.field.FieldMetadataUtils.transientFields; import static org.lightadmin.core.config.domain.unit.DomainConfigurationUnitType.*; import static org.lightadmin.core.persistence.metamodel.PersistentPropertyType.FILE; -import static org.lightadmin.core.web.support.DynamicPersistentEntityResourceProcessor.PersistentEntityWrapper.persistentEntity; @SuppressWarnings(value = {"unchecked", "unused"}) public class DynamicPersistentEntityResourceProcessor implements ResourceProcessor { @@ -69,7 +68,7 @@ public DynamicPersistentEntityResourceProcessor(GlobalAdministrationConfiguratio @Override public PersistentEntityResource process(PersistentEntityResource persistentEntityResource) { PersistentEntity persistentEntity = persistentEntityResource.getPersistentEntity(); - Object value = persistentEntityResource.getContent(); + ManageableEntity value = (ManageableEntity) persistentEntityResource.getContent(); Link[] links = persistentEntityResource.getLinks().toArray(new Link[persistentEntityResource.getLinks().size()]); String stringRepresentation = stringRepresentation(value, persistentEntity); @@ -77,12 +76,11 @@ public PersistentEntityResource process(PersistentEntityResource persistentEntit boolean managedDomainType = adminConfiguration.isManagedDomainType(persistentEntity.getType()); String primaryKey = primaryKey(persistentEntity); - Map> dynamicProperties = dynamicPropertiesPerUnit(value, persistentEntity); + Map> dynamicProperties = dynamicPropertiesPerUnit(value, persistentEntity); - PersistentEntityWrapper persistentEntityWrapper = persistentEntity(value, dynamicProperties, stringRepresentation, domainLink, managedDomainType, primaryKey); - - PersistentEntityResource.Builder builder = PersistentEntityResource.build(persistentEntityWrapper, persistentEntity); - for (Link link: links) { + value.setDynamicProperties(dynamicProperties, stringRepresentation, domainLink, managedDomainType, primaryKey); + PersistentEntityResource.Builder builder = PersistentEntityResource.build(value, persistentEntity); + for (Link link : links) { builder = builder.withLink(link); } return builder.build(); @@ -107,7 +105,7 @@ private Link domainLink(PersistentEntityResource persistentEntityResource) { return null; } - private Map> dynamicPropertiesPerUnit(Object value, PersistentEntity persistentEntity) { + private Map> dynamicPropertiesPerUnit(Object value, PersistentEntity persistentEntity) { if (!adminConfiguration.isManagedDomainType(persistentEntity.getType())) { return Collections.emptyMap(); } @@ -119,7 +117,7 @@ private Map> dynamicPropertiesP List persistentProperties = findPersistentFileProperties(persistentEntity); List associations = findLinkableAssociations(persistentEntity); - Map> dynamicPropertiesPerUnit = newHashMap(); + Map> dynamicPropertiesPerUnit = newHashMap(); for (DomainConfigurationUnitType unit : units) { Map dynamicProperties = newLinkedHashMap(); for (PersistentProperty persistentProperty : persistentProperties) { @@ -134,7 +132,7 @@ private Map> dynamicPropertiesP for (FieldMetadata transientField : transientFields(managedDomainTypeConfiguration.fieldsForUnit(unit))) { dynamicProperties.put(transientField.getUuid(), transientField.getValue(value)); } - dynamicPropertiesPerUnit.put(unit, dynamicProperties); + dynamicPropertiesPerUnit.put(unit.getName(), dynamicProperties); } return dynamicPropertiesPerUnit; } @@ -156,7 +154,7 @@ private Object associationPropertyValue(Association association, Object instance return associatedPersistentEntity(persistentProperty, associationValue); } - private List associatedPersistentEntities(Association association, Object instance) { + private List associatedPersistentEntities(Association association, Object instance) { PersistentProperty persistentProperty = association.getInverse(); Object associationValue = beanWrapper(instance).getPropertyValue(persistentProperty.getName()); @@ -164,7 +162,7 @@ private List associatedPersistentEntities(Association a return null; } - List result = newArrayList(); + List result = newArrayList(); if (persistentProperty.isArray()) { for (Object item : (Object[]) associationValue) { @@ -179,7 +177,7 @@ private List associatedPersistentEntities(Association a return result; } - private PersistentEntityWrapper associatedPersistentEntity(PersistentProperty persistentProperty, Object associationValue) { + private ManageableEntity associatedPersistentEntity(PersistentProperty persistentProperty, Object associationValue) { if (associationValue == null) { return null; } @@ -197,7 +195,7 @@ private PersistentEntityWrapper associatedPersistentEntity(PersistentProperty pe domainLink = domainEntityLinks.linkToSingleResource(associationType, primaryKeyValue); } - return PersistentEntityWrapper.associatedPersistentEntity(stringRepresentation, managedDomainType, primaryKey, primaryKeyValue, domainLink); + return ManageableEntity.associatedPersistentEntity(stringRepresentation, managedDomainType, primaryKey, primaryKeyValue, domainLink); } private static DirectFieldAccessFallbackBeanWrapper beanWrapper(Object instance) { @@ -240,66 +238,4 @@ private FilePropertyValue filePropertyValue(PersistentProperty persistentPropert return null; } } - - static class PersistentEntityWrapper { - private String stringRepresentation; - private boolean managedDomainType; - private String primaryKey; - private Link domainLink; - private Object persistentEntity; - private Map> dynamicProperties; - - private PersistentEntityWrapper(Object persistentEntity, Map> dynamicProperties, String stringRepresentation, Link domainLink, boolean managedDomainType, String primaryKey) { - this.stringRepresentation = stringRepresentation; - this.domainLink = domainLink; - this.managedDomainType = managedDomainType; - this.persistentEntity = persistentEntity; - this.dynamicProperties = dynamicProperties; - this.primaryKey = primaryKey; - } - - public static PersistentEntityWrapper associatedPersistentEntity(String stringRepresentation, boolean managedDomainType, String primaryKey, Object primaryKeyValue, Link domainLink) { - Map persistentEntity = newHashMap(); - persistentEntity.put(primaryKey, primaryKeyValue); - - return new PersistentEntityWrapper(persistentEntity, null, stringRepresentation, domainLink, managedDomainType, primaryKey); - } - - public static PersistentEntityWrapper persistentEntity(Object instance, Map> dynamicProperties, String stringRepresentation, Link domainLink, boolean managedDomainType, String primaryKey) { - return new PersistentEntityWrapper(instance, dynamicProperties, stringRepresentation, domainLink, managedDomainType, primaryKey); - } - - @JsonProperty("string_representation") - public String getStringRepresentation() { - return stringRepresentation; - } - - @JsonProperty("primary_key") - public String getPrimaryKey() { - return primaryKey; - } - - @JsonProperty("managed_type") - public boolean isManagedDomainType() { - return managedDomainType; - } - - @JsonProperty("domain_link") - @JsonInclude(NON_NULL) - public Link getDomainLink() { - return domainLink; - } - - @JsonProperty("original_properties") - @JsonInclude(NON_NULL) - public Object getPersistentEntity() { - return persistentEntity; - } - - @JsonProperty("dynamic_properties") - @JsonInclude(NON_EMPTY) - public Map> getDynamicProperties() { - return dynamicProperties; - } - } -} \ No newline at end of file +} diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/web/support/ManageableEntity.java b/lightadmin-core/src/main/java/org/lightadmin/core/web/support/ManageableEntity.java new file mode 100644 index 00000000..7d3f1db0 --- /dev/null +++ b/lightadmin-core/src/main/java/org/lightadmin/core/web/support/ManageableEntity.java @@ -0,0 +1,68 @@ +package org.lightadmin.core.web.support; + +import com.fasterxml.jackson.annotation.JsonInclude; +import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY; +import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; +import com.fasterxml.jackson.annotation.JsonProperty; +import static com.google.common.collect.Maps.newHashMap; +import java.io.Serializable; +import java.util.Map; +import org.springframework.hateoas.Link; + +public class ManageableEntity implements Serializable { + + private String stringRepresentation; + private boolean managedDomainType; + private String primaryKey; + private Link domainLink; + private Map> dynamicProperties; + + public ManageableEntity() { + } + + private ManageableEntity(Map> dynamicProperties, String stringRepresentation, Link domainLink, boolean managedDomainType, String primaryKey) { + } + + public static ManageableEntity associatedPersistentEntity(String stringRepresentation, boolean managedDomainType, String primaryKey, Object primaryKeyValue, Link domainLink) { + Map persistentEntity = newHashMap(); + persistentEntity.put(primaryKey, primaryKeyValue); + ManageableEntity entity = new ManageableEntity(); + entity.setDynamicProperties(null, stringRepresentation, domainLink, managedDomainType, primaryKey); + return entity; + } + + public void setDynamicProperties(Map> dynamicProperties, String stringRepresentation, Link domainLink, boolean managedDomainType, String primaryKey) { + this.stringRepresentation = stringRepresentation; + this.domainLink = domainLink; + this.managedDomainType = managedDomainType; + this.dynamicProperties = dynamicProperties; + this.primaryKey = primaryKey; + } + + @JsonProperty("string_representation") + public String getStringRepresentation() { + return stringRepresentation; + } + + @JsonProperty("primary_key") + public String getPrimaryKey() { + return primaryKey; + } + + @JsonProperty("managed_type") + public boolean isManagedDomainType() { + return managedDomainType; + } + + @JsonProperty("domain_link") + @JsonInclude(NON_NULL) + public Link getDomainLink() { + return domainLink; + } + + @JsonProperty("dynamic_properties") + @JsonInclude(NON_EMPTY) + public Map> getDynamicProperties() { + return dynamicProperties; + } +} diff --git a/lightadmin-core/src/main/resources/META-INF/resources/scripts/lightadmin-domain.js b/lightadmin-core/src/main/resources/META-INF/resources/scripts/lightadmin-domain.js index a317e3f2..b71778c6 100644 --- a/lightadmin-core/src/main/resources/META-INF/resources/scripts/lightadmin-domain.js +++ b/lightadmin-core/src/main/resources/META-INF/resources/scripts/lightadmin-domain.js @@ -19,7 +19,7 @@ function DomainEntity(data) { this.primary_key = data['primary_key']; this.domain_link = this.managed_type ? data['domain_link']['href'] : null; this.links = data['_links']; - this.original_properties = data['original_properties']; + this.original_properties = data; this.dynamic_properties = data['dynamic_properties']; function getDynamicAssociationValue(domainEntity, propertyMetadata, unitType) { diff --git a/lightadmin-core/src/main/resources/META-INF/tags/data-table.tag b/lightadmin-core/src/main/resources/META-INF/tags/data-table.tag index 63289eea..682310ba 100644 --- a/lightadmin-core/src/main/resources/META-INF/tags/data-table.tag +++ b/lightadmin-core/src/main/resources/META-INF/tags/data-table.tag @@ -56,7 +56,7 @@ var dataTable = tableElement.dataTable({ "bJQueryUI": true, "bStateSave": true, - "sAjaxDataProp": '_embedded.persistentEntityWrappers', + "sAjaxDataProp": '_embedded.${domainTypeAdministrationConfiguration.pluralDomainTypeName}', "aoColumnDefs": [ { "bSortable": false, @@ -81,7 +81,7 @@ }, - "mData": '${field.dynamic or light:persistentPropertyTypeOf(field.persistentProperty) eq FILE? 'dynamic_properties.listView.' : 'original_properties.'}${propertyName}', + "mData": '${field.dynamic or light:persistentPropertyTypeOf(field.persistentProperty) eq FILE? 'dynamic_properties.listView.' : ''}${propertyName}', "mRender": function (innerData) { diff --git a/lightadmin-sandbox/pom.xml b/lightadmin-sandbox/pom.xml index 02d28756..a85a548d 100644 --- a/lightadmin-sandbox/pom.xml +++ b/lightadmin-sandbox/pom.xml @@ -168,24 +168,4 @@ - - - - lightadmin-nexus-snapshots - http://lightadmin.org/nexus/content/repositories/snapshots - - true - always - - - - lightadmin-nexus-releases - http://lightadmin.org/nexus/content/repositories/releases - - true - always - - - - diff --git a/pom.xml b/pom.xml index e5b42235..ac8b7b68 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.lightadmin lightadmin-parent - 1.2.0.BUILD-SNAPSHOT + 1.3.0.BUILD-SNAPSHOT pom LightAdmin Dev Kit @@ -13,13 +13,13 @@ UTF-8 UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 2.0.5.RELEASE 1.2 - 1.0.0.BUILD-SNAPSHOT + 1.0.0.RC1 From 76ef0be05286ddfb2d5e12330e65571b0f238f1a Mon Sep 17 00:00:00 2001 From: Luis Roca Date: Wed, 14 Sep 2016 16:26:53 -0500 Subject: [PATCH 3/4] Add "read only" custom control for edit form. --- .../main/java/org/lightadmin/api/config/utils/Editors.java | 4 ++++ .../resources/views/editors/readonly-field-control.jsp | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 lightadmin-core/src/main/resources/META-INF/resources/views/editors/readonly-field-control.jsp diff --git a/lightadmin-core/src/main/java/org/lightadmin/api/config/utils/Editors.java b/lightadmin-core/src/main/java/org/lightadmin/api/config/utils/Editors.java index a0238d90..52dc88fe 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/api/config/utils/Editors.java +++ b/lightadmin-core/src/main/java/org/lightadmin/api/config/utils/Editors.java @@ -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 elements) { return new EnumFieldEditControl(elements); } diff --git a/lightadmin-core/src/main/resources/META-INF/resources/views/editors/readonly-field-control.jsp b/lightadmin-core/src/main/resources/META-INF/resources/views/editors/readonly-field-control.jsp new file mode 100644 index 00000000..bd07207b --- /dev/null +++ b/lightadmin-core/src/main/resources/META-INF/resources/views/editors/readonly-field-control.jsp @@ -0,0 +1,5 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + \ No newline at end of file From 45d40a9ed57aa97ab089d757762b5cf4c7773d2b Mon Sep 17 00:00:00 2001 From: Luis Roca Date: Mon, 19 Sep 2016 14:51:08 -0500 Subject: [PATCH 4/4] Fixed a bug where the related entity was not rightfuly selected from the html control at form view. --- lightadmin-core/pom.xml | 2 +- ...amicPersistentEntityResourceProcessor.java | 2 +- .../core/web/support/ManageableEntity.java | 16 +++++----- .../resources/scripts/lightadmin-domain.js | 29 +++++++++++-------- pom.xml | 2 +- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/lightadmin-core/pom.xml b/lightadmin-core/pom.xml index 375f6c55..bfb0e84d 100644 --- a/lightadmin-core/pom.xml +++ b/lightadmin-core/pom.xml @@ -8,7 +8,7 @@ lightadmin jar - 1.2.0.BUILD-SNAPSHOT + 1.3.1.BUILD-SNAPSHOT LightAdmin Pluggable data management solution for Java web applications developed in a "Rapid" manner diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceProcessor.java b/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceProcessor.java index 65e190e2..4c76d343 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceProcessor.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/web/support/DynamicPersistentEntityResourceProcessor.java @@ -78,7 +78,7 @@ public PersistentEntityResource process(PersistentEntityResource persistentEntit Map> dynamicProperties = dynamicPropertiesPerUnit(value, persistentEntity); - value.setDynamicProperties(dynamicProperties, stringRepresentation, domainLink, managedDomainType, primaryKey); + value.setDynamicProperties(dynamicProperties, stringRepresentation, domainLink, managedDomainType, primaryKey, null); PersistentEntityResource.Builder builder = PersistentEntityResource.build(value, persistentEntity); for (Link link : links) { builder = builder.withLink(link); diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/web/support/ManageableEntity.java b/lightadmin-core/src/main/java/org/lightadmin/core/web/support/ManageableEntity.java index 7d3f1db0..b1fdc813 100644 --- a/lightadmin-core/src/main/java/org/lightadmin/core/web/support/ManageableEntity.java +++ b/lightadmin-core/src/main/java/org/lightadmin/core/web/support/ManageableEntity.java @@ -14,29 +14,26 @@ public class ManageableEntity implements Serializable { private String stringRepresentation; private boolean managedDomainType; private String primaryKey; + private Object primaryKeyValue; private Link domainLink; private Map> dynamicProperties; public ManageableEntity() { } - private ManageableEntity(Map> dynamicProperties, String stringRepresentation, Link domainLink, boolean managedDomainType, String primaryKey) { - } - public static ManageableEntity associatedPersistentEntity(String stringRepresentation, boolean managedDomainType, String primaryKey, Object primaryKeyValue, Link domainLink) { - Map persistentEntity = newHashMap(); - persistentEntity.put(primaryKey, primaryKeyValue); ManageableEntity entity = new ManageableEntity(); - entity.setDynamicProperties(null, stringRepresentation, domainLink, managedDomainType, primaryKey); + entity.setDynamicProperties(null, stringRepresentation, domainLink, managedDomainType, primaryKey, primaryKeyValue); return entity; } - public void setDynamicProperties(Map> dynamicProperties, String stringRepresentation, Link domainLink, boolean managedDomainType, String primaryKey) { + public void setDynamicProperties(Map> dynamicProperties, String stringRepresentation, Link domainLink, boolean managedDomainType, String primaryKey, Object primaryKeyValue) { this.stringRepresentation = stringRepresentation; this.domainLink = domainLink; this.managedDomainType = managedDomainType; this.dynamicProperties = dynamicProperties; this.primaryKey = primaryKey; + this.primaryKeyValue = primaryKeyValue; } @JsonProperty("string_representation") @@ -49,6 +46,11 @@ public String getPrimaryKey() { return primaryKey; } + @JsonProperty("primary_key_value") + public Object getPrimaryKeyValue() { + return primaryKeyValue; + } + @JsonProperty("managed_type") public boolean isManagedDomainType() { return managedDomainType; diff --git a/lightadmin-core/src/main/resources/META-INF/resources/scripts/lightadmin-domain.js b/lightadmin-core/src/main/resources/META-INF/resources/scripts/lightadmin-domain.js index b71778c6..adf5f124 100644 --- a/lightadmin-core/src/main/resources/META-INF/resources/scripts/lightadmin-domain.js +++ b/lightadmin-core/src/main/resources/META-INF/resources/scripts/lightadmin-domain.js @@ -17,6 +17,7 @@ function DomainEntity(data) { this.string_representation = data['string_representation']; this.managed_type = data['managed_type']; this.primary_key = data['primary_key']; + this.primary_key_value = data['primary_key_value']; this.domain_link = this.managed_type ? data['domain_link']['href'] : null; this.links = data['_links']; this.original_properties = data; @@ -37,7 +38,7 @@ function DomainEntity(data) { url: associationLink, dataType: 'json', async: false, - success: function(data) { + success: function (data) { if ($.isEmptyObject(data)) { return null; } else if (propertyType == 'ASSOC_MULTI') { @@ -50,35 +51,39 @@ function DomainEntity(data) { return associationValue; } - this.getAssociationLink = function(propertyMetadata) { + this.getAssociationLink = function (propertyMetadata) { return this.links[propertyMetadata['name']]['href']; }; - this.getSelfRestLink = function() { + this.getSelfRestLink = function () { return this.links['self']['href']; }; - this.getStringRepresentation = function() { + this.getStringRepresentation = function () { return this.string_representation; }; - this.isManagedType = function() { + this.isManagedType = function () { return this.managed_type; }; - this.getDomainLink = function() { + this.getDomainLink = function () { return this.domain_link; }; - this.getPrimaryKey = function() { + this.getPrimaryKey = function () { return this.primary_key; }; - this.getPrimaryKeyValue = function() { - return this.original_properties[this.getPrimaryKey()]; + this.getPrimaryKeyValue = function () { + if (this.primary_key_value !== null) { + return this.primary_key_value; + } else { + return this.original_properties[this.getPrimaryKey()]; + } }; - this.getPropertyValue = function(propertyMetadata, unitType) { + this.getPropertyValue = function (propertyMetadata, unitType) { var isDynamicProperty = !propertyMetadata['persistable']; var propertyName = propertyMetadata['name']; var propertyType = propertyMetadata['type']; @@ -102,11 +107,11 @@ function DateTime(dateTimeValue) { time = dateTimeValue.split('T')[1].substr(0, 8); } - this.getDate = function() { + this.getDate = function () { return date; }; - this.getTime = function() { + this.getTime = function () { return time; }; } \ No newline at end of file diff --git a/pom.xml b/pom.xml index ac8b7b68..732c7d5c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.lightadmin lightadmin-parent - 1.3.0.BUILD-SNAPSHOT + 1.3.1.BUILD-SNAPSHOT pom LightAdmin Dev Kit