use of org.springframework.beans.PropertyAccessor in project spring-boot by spring-projects.
the class DeviceDelegatingViewResolverAutoConfigurationTests method overrideTabletPrefix.
@Test
public void overrideTabletPrefix() throws Exception {
PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor("spring.mobile.devicedelegatingviewresolver.enabled:true", "spring.mobile.devicedelegatingviewresolver.tabletPrefix:tab/");
assertThat(accessor.getPropertyValue("tabletPrefix")).isEqualTo("tab/");
}
use of org.springframework.beans.PropertyAccessor in project spring-boot by spring-projects.
the class DeviceDelegatingViewResolverAutoConfigurationTests method overrideNormalSuffix.
@Test
public void overrideNormalSuffix() throws Exception {
PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor("spring.mobile.devicedelegatingviewresolver.enabled:true", "spring.mobile.devicedelegatingviewresolver.normalSuffix:.nor");
assertThat(accessor.getPropertyValue("normalSuffix")).isEqualTo(".nor");
}
use of org.springframework.beans.PropertyAccessor in project spring-boot by spring-projects.
the class DeviceDelegatingViewResolverAutoConfigurationTests method overrideMobilePrefix.
@Test
public void overrideMobilePrefix() throws Exception {
PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor("spring.mobile.devicedelegatingviewresolver.enabled:true", "spring.mobile.devicedelegatingviewresolver.mobilePrefix:mob/");
assertThat(accessor.getPropertyValue("mobilePrefix")).isEqualTo("mob/");
}
use of org.springframework.beans.PropertyAccessor in project summerb by skarpushin.
the class DataSetLoaderImpl method enumerateOutgoingReferences.
/**
* @param scanForReferences
* dataSet to scan for Many2one & One2one referenced objects
* @param checkForExistence
* data set that contains already loaded objects so that we can
* skip loading these objects again
* @param references
* references to use
* @return map entityTypeCode to list of ids of these entities to be loaded
*/
private Map<String, Set<Object>> enumerateOutgoingReferences(DataSet scanForReferences, DataSet checkForExistence, Ref[] references) {
Map<String, Set<Object>> ret = new HashMap<>();
for (DataTable table : scanForReferences.getTables().values()) {
List<Ref> outgoingRefs = enumOutgoingRefsToTableOrNull(references, table.getName());
if (outgoingRefs == null) {
continue;
}
for (Object rowObj : table.getRows().values()) {
HasId row = (HasId) rowObj;
PropertyAccessor propertyAccessor = PropertyAccessorFactory.forBeanPropertyAccess(row);
for (Ref ref : outgoingRefs) {
Object referencedId = null;
try {
referencedId = propertyAccessor.getPropertyValue(ref.getFromField());
} catch (Throwable t) {
throw new RuntimeException("Failed to read property " + ref.getFromField() + " from " + row, t);
}
if (referencedId == null) {
continue;
}
if (checkForExistence.get(ref.getToEntity()).find(referencedId) != null) {
// that one is already loaded, skip
continue;
}
Set<Object> referencedIds = ret.get(ref.getToEntity());
if (referencedIds == null) {
ret.put(ref.getToEntity(), referencedIds = new HashSet<>());
}
referencedIds.add(referencedId);
}
}
}
return ret;
}
use of org.springframework.beans.PropertyAccessor in project summerb by skarpushin.
the class DataSetLoaderImpl method populateBackReferencesOne2Many.
private void populateBackReferencesOne2Many(EntityTypeToObjectsMap rowsMap, Map<Ref, Set<Object>> refs, DataSet dataSet) {
for (Entry<String, List<HasId>> entry : rowsMap.entrySet()) {
for (HasId row : entry.getValue()) {
PropertyAccessor propertyAccessor = PropertyAccessorFactory.forBeanPropertyAccess(row);
for (Ref ref : refs.keySet()) {
if (!ref.getToEntity().equals(entry.getKey())) {
continue;
}
Object referencedId = null;
try {
referencedId = propertyAccessor.getPropertyValue(ref.getToField());
} catch (Throwable t) {
throw new RuntimeException("Failed to read property " + ref.getFromField() + " from " + row, t);
}
if (referencedId == null) {
continue;
}
RowIdToBackReferencesMap backRefs = dataSet.get(ref.getFromEntity()).getBackRefs();
if (backRefs.get(referencedId) == null) {
backRefs.put(referencedId, new RefToReferencedObjectsIdsMap());
}
RefToReferencedObjectsIdsMap refToObjsMap = backRefs.get(referencedId);
if (refToObjsMap.get(ref.getName()) == null) {
refToObjsMap.put(ref.getName(), new HashSet<>());
}
refToObjsMap.get(ref.getName()).add(row.getId());
}
}
}
}
Aggregations