use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.
the class ColumnSet method applySortingAndGroupingInternal.
private void applySortingAndGroupingInternal(Map<IColumn, P_SortingAndGroupingConfig> columnConfigs) {
TreeMap<CompositeObject, IColumn> sortMap = new TreeMap<CompositeObject, IColumn>();
int index = 0;
for (IColumn col : getColumns()) {
int sortIndex = -1;
if (col.isInitialAlwaysIncludeSortAtBegin()) {
sortIndex = col.getInitialSortIndex();
if (sortIndex < 0) {
LOG.warn("AlwaysIncludeSortAtBegin is set but no sort index configured. Table: {}", m_table.getClass().getName());
}
} else if (col.isInitialAlwaysIncludeSortAtEnd()) {
sortIndex = col.getInitialSortIndex();
if (sortIndex < 0) {
LOG.warn("AlwaysIncludeSortAtEnd is set but no sort index configured. Table: {}", m_table.getClass().getName());
}
} else {
sortIndex = columnConfigs.get(col).getSortIndex();
}
if (sortIndex >= 0) {
sortMap.put(new CompositeObject(sortIndex, index), col);
}
// aggregation function:
if (col instanceof INumberColumn) {
((INumberColumn) col).setAggregationFunction(columnConfigs.get(col).getAggregationFunction());
}
index++;
}
clearSortColumns();
clearPermanentHeadSortColumns();
clearPermanentTailSortColumns();
boolean asc;
for (IColumn col : sortMap.values()) {
if (col.isInitialAlwaysIncludeSortAtBegin()) {
asc = col.isInitialSortAscending();
addPermanentHeadSortColumn(col, asc);
} else if (col.isInitialAlwaysIncludeSortAtEnd()) {
asc = col.isInitialSortAscending();
addPermanentTailSortColumn(col, asc);
} else {
asc = columnConfigs.get(col).isAscending();
addSortColumn(col, asc);
}
}
applyGrouping(columnConfigs);
}
use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.
the class CallsView method renderCallTable.
private void renderCallTable(HtmlComponent p, SessionInspector session) {
TreeMap<CompositeObject, CallInspector> timeToCalls = new TreeMap<CompositeObject, CallInspector>();
CallInspector[] callInspectors = session.getCallInspectors();
for (int i = 0; i < callInspectors.length; i++) {
long startTime = callInspectors[i].getInfo().getStartTime();
timeToCalls.put(new CompositeObject(startTime, i), callInspectors[i]);
}
CallInspector[] sorted = timeToCalls.values().toArray(new CallInspector[timeToCalls.size()]);
p.bold("Calls");
p.startTable(1, 0, 3);
p.startTableRow();
p.tableHeaderCell("#");
p.tableHeaderCell("Operation");
p.tableHeaderCell("Started");
p.tableHeaderCell("Duration");
p.tableHeaderCell("Status");
p.endTableRow();
CallInspector validSelection = null;
for (int i = sorted.length - 1; i >= 0; i--) {
if (sorted[i] == m_selectedCall) {
validSelection = m_selectedCall;
}
renderCallRow(p, i + 1, sorted[i]);
}
m_selectedCall = validSelection;
p.endTable();
}
use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.
the class ServicesView method renderServiceTables.
private void renderServiceTables(HtmlComponent p) {
// categorize services
TreeMap<CompositeObject, Collection<ServiceInspector>> servicesMap = new TreeMap<CompositeObject, Collection<ServiceInspector>>();
if (m_serviceInspectors != null) {
for (ServiceInspector inspector : m_serviceInspectors) {
String serviceName = inspector.getService().getClass().getSimpleName();
String sectionName = null;
int sectionOrder;
try {
if (serviceName.matches(".*ProcessService")) {
sectionOrder = 1;
sectionName = "Process Services";
} else if (serviceName.matches(".*OutlineService")) {
sectionOrder = 2;
sectionName = "Outline Services";
} else if (serviceName.matches(".*LookupService")) {
sectionOrder = 3;
sectionName = "Lookup Services";
} else {
List<Class<?>> serviceInterfaces = BeanUtility.getInterfacesHierarchy(inspector.getService().getClass(), Object.class);
Class topInterface = (serviceInterfaces.size() > 0 ? serviceInterfaces.get(serviceInterfaces.size() - 1) : null);
if (topInterface != null && topInterface.getPackage() != null && topInterface.getPackage().getName().indexOf(".common.") >= 0) {
sectionOrder = 4;
sectionName = "Common Services";
} else {
sectionOrder = 5;
sectionName = "Other Services";
}
}
CompositeObject key = new CompositeObject(sectionOrder, sectionName);
Collection<ServiceInspector> list = servicesMap.get(key);
if (list == null) {
list = new ArrayList<ServiceInspector>();
servicesMap.put(key, list);
}
list.add(inspector);
} catch (RuntimeException e) {
LOG.warn("Failed inspecting service {}", inspector.getService().getClass(), e);
}
}
}
// tables per section
for (Map.Entry<CompositeObject, Collection<ServiceInspector>> e : servicesMap.entrySet()) {
String sectionName = (String) e.getKey().getComponent(1);
Collection<ServiceInspector> list = e.getValue();
renderServiceTable(p, sectionName, list);
p.p();
}
}
use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.
the class ServerSessionProviderWithCache method provide.
/**
* Returns the cached server session for the given <em>sessionId</em>, or the context's {@link Subject} if
* <em>sessionId</em> is not specified. On cache miss, a new session is created via {@link ServerSessionProvider}.
*
* @param sessionId
* unique session ID to identify the cached session. If <code>null</code>, the context's {@link Subject} is
* used for identification. On cache miss, this <em>sessionId</em> is used to create a new session, or a
* random UUID if <code>null</code>.
* @param serverRunContext
* applied during session start, and to get the session's {@link Subject}.
* @return session found in cache, or a new session on cache miss.
* @throws RuntimeException
* if session creation failed.
*/
@Override
public <SESSION extends IServerSession> SESSION provide(final String sessionId, final ServerRunContext serverRunContext) {
// 1. Create session lookup key.
final CompositeObject sessionCacheKey = newSessionCacheKey(sessionId, serverRunContext.getSubject());
if (sessionCacheKey == null) {
LOG.warn("Cannot identify cached server session because the cache key is undefined [sessionId={}, subject={}]", sessionId, serverRunContext.getSubject());
return super.provide(sessionId, serverRunContext);
}
// 2. Lookup session in the cache.
@SuppressWarnings("unchecked") SESSION serverSession = (SESSION) m_cache.get(sessionCacheKey);
if (serverSession != null) {
return serverSession;
}
// 3. Cache miss (optimistic locking because session creation might be a long running operation)
serverSession = super.provide(sessionId, serverRunContext);
// 4. Cache the new server session, or return present session if created by another thread in the meantime (optimistic locking).
@SuppressWarnings("unchecked") final SESSION cachedServerSession = (SESSION) m_cache.putIfAbsent(sessionCacheKey, serverSession);
if (cachedServerSession != null) {
serverSession = cachedServerSession;
}
return serverSession;
}
use of org.eclipse.scout.rt.platform.util.CompositeObject in project scout.rt by eclipse.
the class ReflectServiceInventory method getProperties.
public PropertyDescriptor[] getProperties() {
TreeMap<CompositeObject, PropertyDescriptor> sortMap = new TreeMap<CompositeObject, PropertyDescriptor>();
int index = 0;
for (PropertyDescriptor p : m_properties) {
if ("class".equals(p.getName())) {
// ignore
} else {
if (p.getName().startsWith("configured")) {
sortMap.put(new CompositeObject(1, p.getName(), index), p);
} else {
sortMap.put(new CompositeObject(2, p.getName(), index), p);
}
}
index++;
}
return sortMap.values().toArray(new PropertyDescriptor[0]);
}
Aggregations