IDEMPIERE-5501 Misses in cache IDisplayTypeFactory (#1592)

This commit is contained in:
Carlos Ruiz 2022-11-29 04:46:40 +01:00 committed by GitHub
parent 7cac30ad13
commit 2fa0d49ac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 92 additions and 53 deletions

View File

@ -232,12 +232,15 @@ public final class DisplayType
if (service != null) if (service != null)
return service.isID(displayType); return service.isID(displayType);
} }
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream() if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isID(displayType)) .filter(e -> e.getService() != null && e.getService().isID(displayType))
.findFirst(); .findFirst();
if (found.isPresent()) { if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get()); s_displayTypeFactoryCache.put(displayType, found.get());
return true; return found.get().getService().isID(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
} }
return false; return false;
@ -261,12 +264,15 @@ public final class DisplayType
if (service != null) if (service != null)
return service.isNumeric(displayType); return service.isNumeric(displayType);
} }
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream() if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isNumeric(displayType)) .filter(e -> e.getService() != null && e.getService().isNumeric(displayType))
.findFirst(); .findFirst();
if (found.isPresent()) { if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get()); s_displayTypeFactoryCache.put(displayType, found.get());
return true; return found.get().getService().isNumeric(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
} }
return false; return false;
@ -296,13 +302,16 @@ public final class DisplayType
return v != null ? v.intValue() : 0; return v != null ? v.intValue() : 0;
} }
} }
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream() if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().getDefaultPrecision(displayType) != null) .filter(e -> e.getService() != null && e.getService().getDefaultPrecision(displayType) != null)
.findFirst(); .findFirst();
if (found.isPresent()) { if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get()); s_displayTypeFactoryCache.put(displayType, found.get());
Integer v = found.get().getService().getDefaultPrecision(displayType); Integer v = found.get().getService().getDefaultPrecision(displayType);
return v != null ? v.intValue() : 0; return v != null ? v.intValue() : 0;
}
s_displayTypeFactoryCache.put(displayType, null);
} }
return 0; return 0;
} // getDefaultPrecision } // getDefaultPrecision
@ -334,12 +343,15 @@ public final class DisplayType
if (service != null) if (service != null)
return service.isText(displayType); return service.isText(displayType);
} }
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream() if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isText(displayType)) .filter(e -> e.getService() != null && e.getService().isText(displayType))
.findFirst(); .findFirst();
if (found.isPresent()) { if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get()); s_displayTypeFactoryCache.put(displayType, found.get());
return true; return found.get().getService().isText(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
} }
return false; return false;
} // isText } // isText
@ -364,12 +376,15 @@ public final class DisplayType
if (service != null) if (service != null)
return service.isDate(displayType); return service.isDate(displayType);
} }
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream() if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isDate(displayType)) .filter(e -> e.getService() != null && e.getService().isDate(displayType))
.findFirst(); .findFirst();
if (found.isPresent()) { if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get()); s_displayTypeFactoryCache.put(displayType, found.get());
return true; return found.get().getService().isDate(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
} }
return false; return false;
@ -394,12 +409,15 @@ public final class DisplayType
if (service != null) if (service != null)
return service.isList(displayType); return service.isList(displayType);
} }
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream() if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isList(displayType)) .filter(e -> e.getService() != null && e.getService().isList(displayType))
.findFirst(); .findFirst();
if (found.isPresent()) { if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get()); s_displayTypeFactoryCache.put(displayType, found.get());
return true; return found.get().getService().isList(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
} }
return false; return false;
@ -427,12 +445,15 @@ public final class DisplayType
if (service != null) if (service != null)
return service.isLookup(displayType); return service.isLookup(displayType);
} }
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream() if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isLookup(displayType)) .filter(e -> e.getService() != null && e.getService().isLookup(displayType))
.findFirst(); .findFirst();
if (found.isPresent()) { if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get()); s_displayTypeFactoryCache.put(displayType, found.get());
return true; return found.get().getService().isLookup(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
} }
return false; return false;
@ -455,12 +476,15 @@ public final class DisplayType
if (service != null) if (service != null)
return service.isLOB(displayType); return service.isLOB(displayType);
} }
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream() if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isLOB(displayType)) .filter(e -> e.getService() != null && e.getService().isLOB(displayType))
.findFirst(); .findFirst();
if (found.isPresent()) { if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get()); s_displayTypeFactoryCache.put(displayType, found.get());
return true; return found.get().getService().isLOB(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
} }
return false; return false;
@ -542,12 +566,15 @@ public final class DisplayType
return f; return f;
} }
} }
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream() if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().getNumberFormat(displayType, language, pattern) != null) .filter(e -> e.getService() != null && e.getService().getNumberFormat(displayType, language, pattern) != null)
.findFirst(); .findFirst();
if (found.isPresent()) { if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get()); s_displayTypeFactoryCache.put(displayType, found.get());
return found.get().getService().getNumberFormat(displayType, language, pattern); return found.get().getService().getNumberFormat(displayType, language, pattern);
}
s_displayTypeFactoryCache.put(displayType, null);
} }
format.setMaximumIntegerDigits(MAX_DIGITS); format.setMaximumIntegerDigits(MAX_DIGITS);
@ -673,12 +700,15 @@ public final class DisplayType
return v; return v;
} }
} }
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream() if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().getDateFormat(displayType, language, pattern) != null) .filter(e -> e.getService() != null && e.getService().getDateFormat(displayType, language, pattern) != null)
.findFirst(); .findFirst();
if (found.isPresent()) { if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get()); s_displayTypeFactoryCache.put(displayType, found.get());
return found.get().getService().getDateFormat(displayType, language, pattern); return found.get().getService().getDateFormat(displayType, language, pattern);
}
s_displayTypeFactoryCache.put(displayType, null);
} }
} }
@ -760,12 +790,15 @@ public final class DisplayType
return v; return v;
} }
} }
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream() if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().getClass(displayType, yesNoAsBoolean) != null) .filter(e -> e.getService() != null && e.getService().getClass(displayType, yesNoAsBoolean) != null)
.findFirst(); .findFirst();
if (found.isPresent()) { if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get()); s_displayTypeFactoryCache.put(displayType, found.get());
return found.get().getService().getClass(displayType, yesNoAsBoolean); return found.get().getService().getClass(displayType, yesNoAsBoolean);
}
s_displayTypeFactoryCache.put(displayType, null);
} }
} }
// //
@ -851,12 +884,15 @@ public final class DisplayType
return v; return v;
} }
} }
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream() if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().getSQLDataType(displayType, columnName, fieldLength) != null) .filter(e -> e.getService() != null && e.getService().getSQLDataType(displayType, columnName, fieldLength) != null)
.findFirst(); .findFirst();
if (found.isPresent()) { if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get()); s_displayTypeFactoryCache.put(displayType, found.get());
return found.get().getService().getSQLDataType(displayType, columnName, fieldLength); return found.get().getService().getSQLDataType(displayType, columnName, fieldLength);
}
s_displayTypeFactoryCache.put(displayType, null);
} }
if (!DisplayType.isText(displayType)) if (!DisplayType.isText(displayType))
@ -955,12 +991,15 @@ public final class DisplayType
return v; return v;
} }
} }
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream() if (! s_displayTypeFactoryCache.containsKey(displayType)) {
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().getDescription(displayType) != null) .filter(e -> e.getService() != null && e.getService().getDescription(displayType) != null)
.findFirst(); .findFirst();
if (found.isPresent()) { if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get()); s_displayTypeFactoryCache.put(displayType, found.get());
return found.get().getService().getDescription(displayType); return found.get().getService().getDescription(displayType);
}
s_displayTypeFactoryCache.put(displayType, null);
} }
// //