Java Code Examples for org.apache.commons.collections.ListUtils

The following examples show how to use org.apache.commons.collections.ListUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Bats   Source File: LateralJoinPrel.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Check to make sure that the fields of the inputs are the same as the output field names.
 * If not, insert a project renaming them.
 */
public RelNode getLateralInput(int ordinal, RelNode input) {
  int offset = ordinal == 0 ? 0 : getInputSize(0);
  Preconditions.checkArgument(DrillJoinRelBase.uniqueFieldNames(input.getRowType()));
  final List<String> fields = getRowType().getFieldNames();
  final List<String> inputFields = input.getRowType().getFieldNames();
  final List<String> outputFields = fields.subList(offset, offset + getInputSize(ordinal));
  if (ListUtils.subtract(outputFields, inputFields).size() != 0) {
    // Ensure that input field names are the same as output field names.
    // If there are duplicate field names on left and right, fields will get
    // lost.
    // In such case, we need insert a rename Project on top of the input.
    return rename(input, input.getRowType().getFieldList(), outputFields);
  } else {
    return input;
  }
}
 
Example 2
Source Project: Bats   Source File: SqlConverter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * check if the schema provided is a valid schema:
 * <li>schema is not indicated (only one element in the names list)<li/>
 *
 * @param names list of schema and table names, table name is always the last element
 * @throws UserException if the schema is not valid.
 */
private void isValidSchema(final List<String> names) throws UserException {
  SchemaPlus defaultSchema = session.getDefaultSchema(this.rootSchema);
  String defaultSchemaCombinedPath = SchemaUtilites.getSchemaPath(defaultSchema);
  List<String> schemaPath = Util.skipLast(names);
  String schemaPathCombined = SchemaUtilites.getSchemaPath(schemaPath);
  String commonPrefix = SchemaUtilites.getPrefixSchemaPath(defaultSchemaCombinedPath,
          schemaPathCombined,
          parserConfig.caseSensitive());
  boolean isPrefixDefaultPath = commonPrefix.length() == defaultSchemaCombinedPath.length();
  List<String> fullSchemaPath = Strings.isNullOrEmpty(defaultSchemaCombinedPath) ? schemaPath :
          isPrefixDefaultPath ? schemaPath : ListUtils.union(SchemaUtilites.getSchemaPathAsList(defaultSchema), schemaPath);
  if (names.size() > 1 && (SchemaUtilites.findSchema(this.rootSchema, fullSchemaPath) == null &&
          SchemaUtilites.findSchema(this.rootSchema, schemaPath) == null)) {
    SchemaUtilites.throwSchemaNotFoundException(defaultSchema, schemaPath);
  }
}
 
Example 3
Source Project: hop   Source File: WorkflowMapConcurrencyTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void updateGetAndReplaceConcurrently() throws Exception {
  AtomicBoolean condition = new AtomicBoolean( true );
  AtomicInteger generator = new AtomicInteger( 10 );

  List<Updater> updaters = new ArrayList<>();
  for ( int i = 0; i < updatersAmount; i++ ) {
    Updater updater = new Updater( workflowMap, generator, updatersCycles );
    updaters.add( updater );
  }

  List<Getter> getters = new ArrayList<>();
  for ( int i = 0; i < gettersAmount; i++ ) {
    getters.add( new Getter( workflowMap, condition ) );
  }

  List<Replacer> replacers = new ArrayList<>();
  for ( int i = 0; i < replaceAmount; i++ ) {
    replacers.add( new Replacer( workflowMap, condition ) );
  }

  //noinspection unchecked
  ConcurrencyTestRunner.runAndCheckNoExceptionRaised( updaters, ListUtils.union( replacers, getters ), condition );

}
 
Example 4
Source Project: hop   Source File: WorkflowTrackerConcurrencyTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void readAndUpdateTrackerConcurrently() throws Exception {
  final AtomicBoolean condition = new AtomicBoolean( true );

  List<Getter> getters = new ArrayList<Getter>( gettersAmount );
  for ( int i = 0; i < gettersAmount; i++ ) {
    getters.add( new Getter( condition, tracker ) );
  }

  List<Searcher> searchers = new ArrayList<Searcher>( searchersAmount );
  for ( int i = 0; i < searchersAmount; i++ ) {
    int lookingFor = updatersAmount * updatersCycles / 2 + i;
    assertTrue( "We are looking for reachable index", lookingFor < updatersAmount * updatersCycles );
    searchers.add( new Searcher( condition, tracker, mockJobEntryCopy( "workflow-action-" + lookingFor, lookingFor ) ) );
  }

  final AtomicInteger generator = new AtomicInteger( 0 );
  List<Updater> updaters = new ArrayList<Updater>( updatersAmount );
  for ( int i = 0; i < updatersAmount; i++ ) {
    updaters.add( new Updater( tracker, updatersCycles, generator, "workflow-action-%d" ) );
  }

  //noinspection unchecked
  ConcurrencyTestRunner.runAndCheckNoExceptionRaised( updaters, ListUtils.union( getters, searchers ), condition );
  assertEquals( updatersAmount * updatersCycles, generator.get() );
}
 
Example 5
@Override
public List<Server> process(String serviceId, List<Server> servers) {
    if (!grayHoldoutServerProperties.isEnabled() || CollectionUtils.isEmpty(grayHoldoutServerProperties.getServices().get(serviceId))) {
        return servers;
    }

    List<Server> serverList = null;

    if (grayHoldoutServerProperties.isCacheable()) {
        serverList = serversMap.get(serviceId);
        if (CollectionUtils.isNotEmpty(serverList)) {
            return serverList;
        }
    }

    serverList = servers;
    List<Server> unUpServers = getUnUpServers(serviceId);
    if (CollectionUtils.isNotEmpty(unUpServers)) {
        serverList = ListUtils.union(servers, unUpServers);
    }
    if (grayHoldoutServerProperties.isCacheable()) {
        serversMap.put(serviceId, serverList);
    }
    return serverList;
}
 
Example 6
Source Project: spring-cloud-gray   Source File: RibbonServerChooser.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public ServerListResult<Server> distinguishAndMatchGrayServerList(List<Server> servers) {
    ServerListResult<Server> serverListResult = distinguishServerList(servers);
    if (serverListResult == null) {
        return null;
    }

    if (GrayClientHolder.getGraySwitcher().isEanbleGrayRouting()) {
        serverListResult.setGrayServers(
                serverListResult.getGrayServers().stream()
                        .filter(this::matchGrayDecisions)
                        .collect(Collectors.toList()));
    }else{
        serverListResult.setGrayServers(ListUtils.EMPTY_LIST);
    }

    return serverListResult;
}
 
Example 7
@Override
    public boolean test(Collection<String> src, Collection<String> another) {
        if (CollectionUtils.isEmpty(src)) {
            return CollectionUtils.isEmpty(another) ? true : false;
        }
        if (CollectionUtils.isEmpty(another)) {
            return false;
        }

        List<String> srcSorted = new ArrayList<>(src);
        Collections.sort(srcSorted);
        List<String> anotherSorted = new ArrayList<>(another);
        Collections.sort(anotherSorted);

//        return CollectionUtils.isEqualCollection();
        return ListUtils.isEqualList(srcSorted, anotherSorted);
    }
 
Example 8
Source Project: hugegraph-loader   Source File: ElementBuilder.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void extractFromEdge(Map<String, Object> keyValues,
                            List<String> fieldNames) {
    this.pkNames = fieldNames.stream().map(mapping()::mappingField)
                             .collect(Collectors.toList());
    List<String> primaryKeys = this.vertexLabel.primaryKeys();
    E.checkArgument(ListUtils.isEqualList(this.pkNames, primaryKeys),
                    "Make sure the the primary key fields %s are " +
                    "not empty, or check whether the headers or " +
                    "field_mapping are configured correctly",
                    primaryKeys);
    this.pkValues = new Object[this.pkNames.size()];
    for (int i = 0; i < fieldNames.size(); i++) {
        String fieldName = fieldNames.get(i);
        Object fieldValue = keyValues.get(fieldName);
        Object pkValue = mappingValue(fieldName, fieldValue);
        this.pkValues[i] = pkValue;
    }
}
 
Example 9
Source Project: bird-java   Source File: ZookeeperCacheManager.java    License: MIT License 6 votes vote down vote up
/**
 * 从zookeeper中加载模块以及路由信息
 */
private void loadAllRoute() {
    if (!zkClient.exists(ZkPathConstant.ROUTE_PARENT)) {
        zkClient.createPersistent(ZkPathConstant.ROUTE_PARENT, true);
    }

    List<String> modules = zkClient.getChildren(ZkPathConstant.ROUTE_PARENT);
    modules.forEach(this::loadWatchModule);

    zkClient.subscribeChildChanges(ZkPathConstant.ROUTE_PARENT, (parentPath, currentModules) -> {
        List<String> existModules = new ArrayList<>(MODULE_MAP.keySet());

        List<String> newModules = ListUtils.subtract(currentModules, existModules);
        List<String> removeModules = ListUtils.subtract(existModules, currentModules);

        newModules.forEach(this::loadWatchModule);
        removeModules.forEach(this::unloadModule);
    });
}
 
Example 10
Source Project: flink-siddhi   Source File: SiddhiExecutionPlanner.java    License: Apache License 2.0 6 votes vote down vote up
private void retrievePartition(StreamPartition partition) throws Exception {
    if (partition == null) {
        return;
    }

    if (!streamPartitions.containsKey(partition.getInputStreamId())) {
        streamPartitions.put(partition.getInputStreamId(), partition);
    } else {
        StreamPartition existingPartition = streamPartitions.get(partition.getInputStreamId());
        if (existingPartition.getType().equals(partition.getType())
            && ListUtils.isEqualList(existingPartition.getGroupByList(), partition.getGroupByList())
            || existingPartition.getType().equals(StreamPartition.Type.SHUFFLE) || existingPartition.getType().equals(StreamPartition.Type.PARTITIONWITH)) {
            streamPartitions.put(partition.getInputStreamId(), partition);
        } else {
            throw new Exception("You have incompatible partitions on stream " + partition.getInputStreamId()
                + ": [1] " + streamPartitions.get(partition.getInputStreamId()).toString() + " [2] " + partition.toString() + "");
        }
    }
}
 
Example 11
Source Project: pentaho-kettle   Source File: JobMapConcurrencyTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void updateGetAndReplaceConcurrently() throws Exception {
  AtomicBoolean condition = new AtomicBoolean( true );
  AtomicInteger generator = new AtomicInteger( 10 );

  List<Updater> updaters = new ArrayList<>();
  for ( int i = 0; i < updatersAmount; i++ ) {
    Updater updater = new Updater( jobMap, generator, updatersCycles );
    updaters.add( updater );
  }

  List<Getter> getters = new ArrayList<>();
  for ( int i = 0; i < gettersAmount; i++ ) {
    getters.add( new Getter( jobMap, condition ) );
  }

  List<Replacer> replacers = new ArrayList<>();
  for ( int i = 0; i < replaceAmount; i++ ) {
    replacers.add( new Replacer( jobMap, condition ) );
  }

  //noinspection unchecked
  ConcurrencyTestRunner.runAndCheckNoExceptionRaised( updaters, ListUtils.union( replacers, getters ), condition );

}
 
Example 12
Source Project: eagle   Source File: PolicyExecutionPlannerImpl.java    License: Apache License 2.0 6 votes vote down vote up
private void retrievePartition(StreamPartition partition) {
    if (partition == null) {
        return;
    }

    if (!effectivePartitions.containsKey(partition.getStreamId())) {
        effectivePartitions.put(partition.getStreamId(), partition);
    } else if (!effectivePartitions.get(partition.getStreamId()).equals(partition)) {
        StreamPartition existingPartition = effectivePartitions.get(partition.getStreamId());
        // If same Type & Columns but different sort spec, then use larger
        if (existingPartition.getType().equals(partition.getType())
            && ListUtils.isEqualList(existingPartition.getColumns(), partition.getColumns())
            && partition.getSortSpec().getWindowPeriodMillis() > existingPartition.getSortSpec().getWindowPeriodMillis()
            || existingPartition.getType().equals(StreamPartition.Type.SHUFFLE)) {
            effectivePartitions.put(partition.getStreamId(), partition);
        } else {
            // Throw exception as it unable to conflict effectivePartitions on same stream will not be able to run in distributed mode
            throw new SiddhiAppValidationException("You have incompatible partitions on stream " + partition.getStreamId()
                + ": [1] " + effectivePartitions.get(partition.getStreamId()).toString() + " [2] " + partition.toString() + "");
        }
    }
}
 
Example 13
Source Project: eagle   Source File: PolicyDefinition.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(Object that) {
    if (that == this) {
        return true;
    }
    if (!(that instanceof Definition)) {
        return false;
    }
    Definition another = (Definition) that;
    if (another.type.equals(this.type)
            && another.value.equals(this.value)
            && ListUtils.isEqualList(another.inputStreams, this.inputStreams)
            && ListUtils.isEqualList(another.outputStreams, this.outputStreams)) {
        return true;
    }
    return false;
}
 
Example 14
Source Project: eagle   Source File: AlertDeduplication.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(Object that) {
    if (that == this) {
        return true;
    }
    if (!(that instanceof AlertDeduplication)) {
        return false;
    }
    AlertDeduplication another = (AlertDeduplication) that;
    if (ListUtils.isEqualList(another.dedupFields, this.dedupFields)
            && Objects.equals(another.dedupIntervalMin, this.dedupIntervalMin)
            && Objects.equals(another.outputStreamId, this.outputStreamId)) {
        return true;
    }
    return false;
}
 
Example 15
Source Project: openhab1-addons   Source File: GroupItem.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * The accepted data types of a group item is the same as of the underlying base item.
 * If none is defined, the intersection of all sets of accepted data types of all group
 * members is used instead.
 *
 * @return the accepted data types of this group item
 */
@Override
@SuppressWarnings("unchecked")
public List<Class<? extends State>> getAcceptedDataTypes() {
    if (baseItem != null) {
        return baseItem.getAcceptedDataTypes();
    } else {
        List<Class<? extends State>> acceptedDataTypes = null;

        for (Item item : members) {
            if (acceptedDataTypes == null) {
                acceptedDataTypes = item.getAcceptedDataTypes();
            } else {
                acceptedDataTypes = ListUtils.intersection(acceptedDataTypes, item.getAcceptedDataTypes());
            }
        }
        return acceptedDataTypes == null ? ListUtils.EMPTY_LIST : acceptedDataTypes;
    }
}
 
Example 16
Source Project: pentaho-kettle   Source File: JobTrackerConcurrencyTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void readAndUpdateTrackerConcurrently() throws Exception {
  final AtomicBoolean condition = new AtomicBoolean( true );

  List<Getter> getters = new ArrayList<Getter>( gettersAmount );
  for ( int i = 0; i < gettersAmount; i++ ) {
    getters.add( new Getter( condition, tracker ) );
  }

  List<Searcher> searchers = new ArrayList<Searcher>( searchersAmount );
  for ( int i = 0; i < searchersAmount; i++ ) {
    int lookingFor = updatersAmount * updatersCycles / 2 + i;
    assertTrue( "We are looking for reachable index", lookingFor < updatersAmount * updatersCycles );
    searchers.add( new Searcher( condition, tracker, mockJobEntryCopy( "job-entry-" + lookingFor, lookingFor ) ) );
  }

  final AtomicInteger generator = new AtomicInteger( 0 );
  List<Updater> updaters = new ArrayList<Updater>( updatersAmount );
  for ( int i = 0; i < updatersAmount; i++ ) {
    updaters.add( new Updater( tracker, updatersCycles, generator, "job-entry-%d" ) );
  }

  //noinspection unchecked
  ConcurrencyTestRunner.runAndCheckNoExceptionRaised( updaters, ListUtils.union( getters, searchers ), condition );
  assertEquals( updatersAmount * updatersCycles, generator.get() );
}
 
Example 17
Source Project: openhab1-addons   Source File: GroupItem.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * The accepted command types of a group item is the same as of the underlying base item.
 * If none is defined, the intersection of all sets of accepted command types of all group
 * members is used instead.
 *
 * @return the accepted command types of this group item
 */
@Override
@SuppressWarnings("unchecked")
public List<Class<? extends Command>> getAcceptedCommandTypes() {
    if (baseItem != null) {
        return baseItem.getAcceptedCommandTypes();
    } else {
        List<Class<? extends Command>> acceptedCommandTypes = null;

        for (Item item : members) {
            if (acceptedCommandTypes == null) {
                acceptedCommandTypes = item.getAcceptedCommandTypes();
            } else {
                acceptedCommandTypes = ListUtils.intersection(acceptedCommandTypes, item.getAcceptedCommandTypes());
            }
        }
        return acceptedCommandTypes == null ? ListUtils.EMPTY_LIST : acceptedCommandTypes;
    }
}
 
Example 18
Source Project: opensoc-streaming   Source File: PcapGetterHBaseImplTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Test_remove duplicates.
 * 
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
@Test
public void test_removeDuplicates() throws IOException {
  PcapGetterHBaseImpl pcapGetter = (PcapGetterHBaseImpl) PcapGetterHBaseImpl
      .getInstance();
  List<String> keys = new ArrayList<String>();

  keys.add("18800006-1800000b-06-0050-5af6");
  keys.add("18800006-1800000b-11-0035-3810");
  keys.add("18800006-1800000b-06-0019-caac");
  keys.add("18800006-1800000b-06-0050-5af6");

  List<String> deDupKeys = pcapGetter.removeDuplicateKeys(keys);
  Assert.isTrue(deDupKeys.size() == 3);
  List<String> testKeys = new ArrayList<String>();
  keys.add("18800006-1800000b-06-0050-5af6");
  keys.add("18800006-1800000b-11-0035-3810");
  keys.add("18800006-1800000b-06-0019-caac");

  ListUtils.isEqualList(deDupKeys, testKeys);
}
 
Example 19
Source Project: opensoc-streaming   Source File: PcapGetterHBaseImplTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Test_sort keys by asc order_with out reverse traffic.
 * 
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
@Test
public void test_sortKeysByAscOrder_withOutReverseTraffic()
    throws IOException {
  PcapGetterHBaseImpl pcapGetter = (PcapGetterHBaseImpl) PcapGetterHBaseImpl
      .getInstance();
  List<String> keys = new ArrayList<String>();
  keys.add("18800006-1800000b-11-0035-3810");
  keys.add("18800006-1800000b-06-0050-5af6");
  keys.add("18800006-1800000b-06-0019-caac");

  List<String> result = pcapGetter.sortKeysByAscOrder(keys, false);

  List<String> testKeys = new ArrayList<String>();
  testKeys.add("18800006-1800000b-06-0019-caac");
  testKeys.add("18800006-1800000b-06-0050-5af6");
  testKeys.add("18800006-1800000b-11-0035-3810");

  Assert.isTrue(ListUtils.isEqualList(result, testKeys));
}
 
Example 20
@Override
public List<String> getSearchResult() {
	List<String> mainSearchResult = super.getSearchResult();
	try {
		Integer userType = this.getUserType();
		if (null == userType || userType == 0) {
			return mainSearchResult;
		} else {
			Boolean entandoUser = (userType == 1);
			List<String> ldapUsernames = this.getLdapUsernames();
			List<String> newList = null;
			if (entandoUser) {
				newList = (List<String>) ListUtils.removeAll(mainSearchResult, ldapUsernames);
			} else {
				newList = (List<String>) ListUtils.intersection(mainSearchResult, ldapUsernames);
			}
			return newList;
		}
	} catch (Throwable t) {
		ApsSystemUtils.logThrowable(t, this, "getSearchResult");
		throw new RuntimeException("Error while searching users", t);
	}
}
 
Example 21
/**
 * Performs any filtering necessary on the collection before building the collection fields.
 *
 * <p>If showInactive is set to false and the collection line type implements {@code Inactivatable},
 * invokes the active collection filter. Then any {@link CollectionFilter} instances configured for the collection
 * group are invoked to filter the collection. Collections lines must pass all filters in order to be
 * displayed</p>
 *
 * @param view view instance that contains the collection
 * @param model object containing the views data
 * @param collectionGroup collection group component instance that will display the collection
 * @param collection collection instance that will be filtered
 */
protected List<Integer> performCollectionFiltering(View view, Object model, CollectionGroup collectionGroup,
        Collection<?> collection) {
    List<Integer> filteredIndexes = new ArrayList<Integer>();
    for (int i = 0; i < collection.size(); i++) {
        filteredIndexes.add(Integer.valueOf(i));
    }

    if (Inactivatable.class.isAssignableFrom(collectionGroup.getCollectionObjectClass()) && !collectionGroup
            .isShowInactiveLines()) {
        List<Integer> activeIndexes = collectionGroup.getActiveCollectionFilter().filter(view, model,
                collectionGroup);
        filteredIndexes = ListUtils.intersection(filteredIndexes, activeIndexes);
    }

    for (CollectionFilter collectionFilter : collectionGroup.getFilters()) {
        List<Integer> indexes = collectionFilter.filter(view, model, collectionGroup);
        filteredIndexes = ListUtils.intersection(filteredIndexes, indexes);
        if (filteredIndexes.isEmpty()) {
            break;
        }
    }

    return filteredIndexes;
}
 
Example 22
/**
 * Call back when a dictionary file is changed. Calls the spring bean reader
 * to reload the file (which will override beans as necessary and destroy
 * singletons) and runs the indexer
 *
 * @see no.geosoft.cc.io.FileListener#fileChanged(java.io.File)
 */
public void fileChanged(File file) {
    LOG.info("reloading dictionary configuration for " + file.getName());
    try {
        List<String> beforeReloadBeanNames = Arrays.asList(ddBeans.getBeanDefinitionNames());
        
        Resource resource = new FileSystemResource(file);
        xmlReader.loadBeanDefinitions(resource);
        
        List<String> afterReloadBeanNames = Arrays.asList(ddBeans.getBeanDefinitionNames());
        
        List<String> addedBeanNames = ListUtils.removeAll(afterReloadBeanNames, beforeReloadBeanNames);
        String namespace = KRADConstants.DEFAULT_NAMESPACE;
        if (fileToNamespaceMapping.containsKey(file.getAbsolutePath())) {
            namespace = fileToNamespaceMapping.get(file.getAbsolutePath());
        }

        ddIndex.addBeanNamesToNamespace(namespace, addedBeanNames);

        performDictionaryPostProcessing(true);
    } catch (Exception e) {
        LOG.info("Exception in dictionary hot deploy: " + e.getMessage(), e);
    }
}
 
Example 23
Source Project: das   Source File: ProjectController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 2、根据GROUP ID获取项目列表 翻页
 */
@RequestMapping(value = "/list", method = RequestMethod.POST)
public ServiceResult<ListResult<ProjectView>> getGroupUsers(@RequestBody Paging<ProjectModel> paging, @CurrentUser LoginUser user) throws SQLException {
    if (null == paging.getData().getDal_group_id() || paging.getData().getDal_group_id() == 0) {
        if (permissionService.isManagerById(user.getId())) {
            return ServiceResult.success(projectService.findProjectPageList(paging));
        } else {
            return ServiceResult.success(ListResult.builder().list(ListUtils.EMPTY_LIST).build());
        }
    } else if (-1 == paging.getData().getDal_group_id()) {

    }
    return ServiceResult.success(projectService.findProjectPageList(paging));
}
 
Example 24
Source Project: das   Source File: DatabaseSetController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 2、根据groupId查询逻辑数据库列表 dbset 分页
 */
@RequestMapping(value = "/list", method = RequestMethod.POST)
public ServiceResult<ListResult<DatabaseSetView>> loadPageList(@RequestBody Paging<DatabaseSet> paging, @CurrentUser LoginUser user) throws SQLException {
    if (StringUtils.isNotBlank(paging.getData().getApp_id())) {
        if (permissionService.isManagerById(user.getId())) {
            return ServiceResult.success(databaseSetService.findDbSetPageListByAppid(paging));
        } else {
            return ServiceResult.success(ListResult.builder().list(ListUtils.EMPTY_LIST).build());
        }
    }
    return ServiceResult.success(databaseSetService.findDbSetPageList(paging));
}
 
Example 25
Source Project: das   Source File: DatabaseSetEntryController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 1、根据逻辑数据库查询列表 DbsetEntry
 */
@RequestMapping(value = "/{dbsetId}/list")
public ServiceResult<List<DatabaseSetEntry>> list(@PathVariable("dbsetId") Long dbsetId) throws Exception {
    if (null == dbsetId || dbsetId == 0) {
        return ServiceResult.success(ListUtils.EMPTY_LIST);
    }
    return ServiceResult.success(dataBaseSetEntryDao.getAllDbSetEntryByDbSetId(dbsetId));
}
 
Example 26
Source Project: das   Source File: DatabaseSetEntryController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 2、根据groupId查询逻辑数据库列表 DbsetEntry 分页
 */
@RequestMapping(value = "/list", method = RequestMethod.POST)
public ServiceResult<ListResult<DatabaseSetEntryView>> loadPageList(@RequestBody Paging<DatabaseSetEntry> paging) throws SQLException {
    if (null == paging.getData().getDbset_id() || paging.getData().getDbset_id() == 0) {
        return ServiceResult.success(ListUtils.EMPTY_LIST);
    }
    return ServiceResult.success(databaseSetEntryService.findDbSetEntryPageList(paging));
}
 
Example 27
Source Project: das   Source File: DatabaseSetEntryService.java    License: Apache License 2.0 5 votes vote down vote up
public List<String> getNamesByEntryIds(List<Integer> dbset_ids) throws SQLException {
    if (CollectionUtils.isEmpty(dbset_ids)) {
        return ListUtils.EMPTY_LIST;
    }
    List<DatabaseSetEntry> list = dataBaseSetEntryDao.getAllDbSetEntryByDbSetIds(dbset_ids);
    List<String> shardings = list.stream().map(i -> i.getSharding()).collect(Collectors.toList());
    return shardings;
}
 
Example 28
Source Project: das   Source File: DatabaseService.java    License: Apache License 2.0 5 votes vote down vote up
public ServiceResult<List<String>> getDBCatalogs(Long dbsetId) throws Exception {
    if (null == dbsetId) {
        return ServiceResult.success(ListUtils.EMPTY_LIST);
    }
    DataBaseInfo dataBaseInfo = dataBaseDao.getMasterCologByDatabaseSetId(dbsetId);
    if (null == dataBaseInfo) {
        return ServiceResult.fail("未找到对应的表,请添加表关联!!");
    }
    return getDBCatalogsByDbId(dataBaseInfo.getId());
}
 
Example 29
Source Project: das   Source File: DatabaseService.java    License: Apache License 2.0 5 votes vote down vote up
public ConfigCkeckResult<List<ConfigDataResponse>> getCheckData(LoginUser user, DataBaseInfo dataBaseInfo) {
    try {
        List<ConfigDataResponse> list = dataBaseConfiguration.getCheckData(user, dataBaseInfo);
        return ConfigCkeckResult.success("success", list);
    } catch (Exception e) {
        return ConfigCkeckResult.fail(StringUtil.getMessage(e), ListUtils.EMPTY_LIST);
    }
}
 
Example 30
Source Project: das   Source File: DatabaseSetService.java    License: Apache License 2.0 5 votes vote down vote up
public ConfigCkeckResult<List<ConfigDataResponse>> getCheckData(LoginUser user, DatabaseSet dbset) {
    try {
        List<ConfigDataResponse> list = dbSetConfiguration.getCheckData(user, dbset);
        return ConfigCkeckResult.success("success", list);
    } catch (Exception e) {
        return ConfigCkeckResult.fail(StringUtil.getMessage(e), ListUtils.EMPTY_LIST);
    }
}