/** * Finds a valid known CDAP entity which can be considered as the parent for the MetadataEntity by walking up the * key-value hierarchy of the MetadataEntity * * @param metadataEntity whose EntityType needs to be determined * @return {@link EntityType} of the given metadataEntity */ @Nullable private static EntityType findParentType(MetadataEntity metadataEntity) { List<String> keys = new ArrayList<>(); metadataEntity.getKeys().forEach(keys::add); int curIndex = keys.size() - 1; EntityType entityType = null; while (curIndex >= 0) { try { entityType = EntityType.valueOf(keys.get(curIndex).toUpperCase()); // found a valid entity type; break; } catch (IllegalArgumentException e) { // the current key is not a valid cdap entity type so try up in hierarchy curIndex--; } } return entityType; }
/** * Finds a valid known CDAP entity which can be considered as the parent for the MetadataEntity by walking up the * key-value hierarchy of the MetadataEntity * * @param metadataEntity whose EntityType needs to be determined * @return {@link EntityType} of the given metadataEntity */ @Nullable private static EntityType findParentType(MetadataEntity metadataEntity) { List<String> keys = new ArrayList<>(); metadataEntity.getKeys().forEach(keys::add); int curIndex = keys.size() - 1; EntityType entityType = null; while (curIndex >= 0) { try { entityType = EntityType.valueOf(keys.get(curIndex).toUpperCase()); // found a valid entity type; break; } catch (IllegalArgumentException e) { // the current key is not a valid cdap entity type so try up in hierarchy curIndex--; } } return entityType; }
private String addQueryParams(String path, MetadataEntity metadataEntity, @Nullable MetadataScope scope, boolean aggregateRun) { StringBuilder builder = new StringBuilder(path); String prefix = "?"; if (!Iterables.getLast(metadataEntity.getKeys()).equalsIgnoreCase(metadataEntity.getType())) { // if last leaf node is not the entity type specify it through query para builder.append(prefix); builder.append("type="); builder.append(metadataEntity.getType()); prefix = "&"; } // the default value of aggregateRun is true so in the case it is false we need to include it as query param if (!aggregateRun) { builder.append(prefix); builder.append("aggregateRun="); builder.append(false); prefix = "&"; } if (scope == null) { return builder.toString(); } else { builder.append(prefix); builder.append("scope="); builder.append(scope); } return builder.toString(); } }
StringBuilder builder = new StringBuilder(path); String prefix = "?"; if (!Iterables.getLast(metadataEntity.getKeys()).equalsIgnoreCase(metadataEntity.getType())) {