Generate column for data source items for current resource.
@param dataSource Data source
@param size Size limit
@param currentResource Current resource
@param itemResourceType Item resource type
@return Column
336057
private static Column getCurrentResourceColumn(DataSource dataSource, Integer size,
      Resource currentResource, String itemResourceType) {

    Iterator<Resource> items = dataSource.iterator();

    boolean hasMore = false;
    if (size != null) {
      List<Resource> list = new ArrayList<Resource>();
      while (items.hasNext() && list.size() < size) {
        list.add(items.next());
      }
      hasMore = items.hasNext();
      items = list.iterator();
    }

    Column column = new Column()
        .columnId(currentResource.getPath())
        .hasMore(hasMore)
        .metaElement(true);
    while (items.hasNext()) {
      Resource item = items.next();
      column.addItem(new ColumnItem(item)
          .resourceType(itemResourceType));
    }

    return column;
  }
1197167
@CheckResult
    @NonNull
    public static PowerAdapter asAdapter(@NonNull @LayoutRes int... resources) {
        return new ItemAdapter(toItems(checkNotNull(resources, "resources")));
    }
753409
public void setDataSourceConnectionSource(ConnectionSource<DataSource, DataSourceSettings> connectionSource) {
        this.dataSourceName = connectionSource.getName();
        DataSource source = connectionSource.getSource();
        getProperties().put(Environment.DATASOURCE, source);
        getProperties().put(Environment.CURRENT_SESSION_CONTEXT_CLASS, GrailsSessionContext.class.getName());
        final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        if (contextClassLoader != null && contextClassLoader.getClass().getSimpleName().equalsIgnoreCase("RestartClassLoader")) {
            getProperties().put(AvailableSettings.CLASSLOADERS, contextClassLoader);
        } else {
            getProperties().put(AvailableSettings.CLASSLOADERS, connectionSource.getClass().getClassLoader());
        }
    }
1207219
public void setDataSource(DataSource dataSource) {
        mDataSource = dataSource;
        mDriverClassName = null;
        mURL = null;
        mUsername = null;
        mPassword = null;
    }
1325673
private DataSource getDataSource(ComponentHelper cmp, Resource resource) {
    try {
      /*
       * by default the path is read from request "path" parameter
       * here we overwrite it via a synthetic resource because the path may be overwritten by validation logic
       * to ensure the path is not beyond the configured root path
       */
      ValueMap overwriteProperties = new ValueMapDecorator(ImmutableMap.<String, Object>of("path", resource.getPath()));
      Resource dataSourceResourceWrapper = GraniteUiSyntheticResource.wrapMerge(request.getResource(), overwriteProperties);
      return cmp.getItemDataSource(dataSourceResourceWrapper);
    }
    catch (ServletException | IOException ex) {
      throw new RuntimeException("Unable to get data source.", ex);
    }
  }
1121784
public static DataSource getDataSource(String source) {
		DataSource ds = dataSources.get(source);
		if (ds == null){
			synchronized (dataSourcesStructureLock){
				ds = dataSources.get(source);
				if (ds == null){
					ds = createDataSource(source);
					if (ds != null){
						dataSources.put(source, ds);
					}
				}
			}
		}
		return ds;
	}
589013
public void buildDataSource(Elements elementUtils, Filer filer, SQLiteDatabaseSchema schema, String daoFactoryName)
			throws Exception {
		ClassName daoFactoryClazz = className(daoFactoryName);
		Converter<String, String> convert = CaseFormat.UPPER_CAMEL.converterTo(CaseFormat.LOWER_CAMEL);

		ClassName dataSourceClassName = generateDataSourceName(schema);

		AnnotationProcessorUtilis.infoOnGeneratedClasses(BindDataSource.class, dataSourceClassName);
		classBuilder = TypeSpec.classBuilder(dataSourceClassName.simpleName()).addModifiers(Modifier.PUBLIC)
				.superclass(AbstractDataSource.class).addSuperinterface(daoFactoryClazz)
				.addSuperinterface(TypeUtility.typeName(schema.getElement().asType()));

		classBuilder.addJavadoc("<p>\n");
		classBuilder.addJavadoc("Implementation of the $L datasource.\n", schema.getName());
		classBuilder.addJavadoc("This class expose database interface through Dao attribute.\n", schema.getName());
		classBuilder.addJavadoc("</p>\n\n");

		JavadocUtility.generateJavadocGeneratedBy(classBuilder);
		classBuilder.addJavadoc("@see $T\n", className(schema.getName()));
		classBuilder.addJavadoc("@see $T\n", daoFactoryClazz);
		for (SQLiteDaoDefinition dao : schema.getCollection()) {
			TypeName daoImplName = BindDaoBuilder.daoTypeName(dao);
			classBuilder.addJavadoc("@see $T\n", dao.getElement());
			classBuilder.addJavadoc("@see $T\n", daoImplName);

			String entity = BindDataSourceSubProcessor.generateEntityName(dao, dao.getEntity());

			classBuilder.addJavadoc("@see $T\n", TypeUtility.typeName(entity));
		}

		// define static fields

		// instance
		classBuilder.addField(FieldSpec.builder(dataSourceClassName, "instance", Modifier.STATIC, Modifier.VOLATILE)
				.addJavadoc("<p>datasource singleton</p>\n").build());
		classBuilder
				.addField(FieldSpec.builder(Object.class, "mutex", Modifier.STATIC, Modifier.FINAL, Modifier.PRIVATE)
						.addJavadoc("<p>Mutex to manage multithread access to instance</p>\n")
						.initializer("new Object()").build());

		for (SQLiteDaoDefinition dao : schema.getCollection()) {
			// TypeName daoInterfaceName =
			// BindDaoBuilder.daoInterfaceTypeName(dao);
			TypeName daoImplName = BindDaoBuilder.daoTypeName(dao);
			classBuilder.addField(FieldSpec.builder(daoImplName, convert.convert(dao.getName()), Modifier.PROTECTED)
					.addJavadoc("<p>dao instance</p>\n").initializer("new $T(this)", daoImplName).build());

			// dao with connections
			{
				MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("get" + dao.getName())
						.addAnnotation(Override.class).addModifiers(Modifier.PUBLIC)
						.returns(BindDaoBuilder.daoTypeName(dao));
				methodBuilder.addCode("return $L;\n", convert.convert(dao.getName()));
				classBuilder.addMethod(methodBuilder.build());
			}
		}

		if (schema.generateRx) {
			generateRx(dataSourceClassName, daoFactoryName);

			for (SQLiteDaoDefinition dao : schema.getCollection()) {
				// subject
				MethodSpec.Builder methodBuilder = MethodSpec
						.methodBuilder("get" + dao.getEntitySimplyClassName() + "Subject")
						.addModifiers(Modifier.PUBLIC);
				methodBuilder
						.addStatement("return $L.getSubject()",
								CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, convert.convert(dao.getName())))
						.returns(ParameterizedTypeName.get(PublishSubject.class, SQLiteEvent.class));
				classBuilder.addMethod(methodBuilder.build());
			}
		}

		// interface
		generateMethodExecuteTransaction(daoFactoryName);

		generateMethodExecuteAsyncTransaction(daoFactoryName, true);
		generateMethodExecuteAsyncTransaction(daoFactoryName, false);

		generateMethodAsyncBatch(daoFactoryName, true);
		generateMethodAsyncBatch(daoFactoryName, false);

		generateMethodExecuteBatch(daoFactoryName);

		generateTransactions(schema);

		// generate instance
		generateInstanceOrBuild(schema, dataSourceClassName.simpleName(), true);

		// generate open
		generateOpen(dataSourceClassName.simpleName());

		// generate openReadOnly
		generateOpenReadOnly(dataSourceClassName.simpleName());

		// generate constructor
		generateConstructor(schema);

		// before use entities, order them with dependencies respect
		List<SQLiteEntity> orderedEntities = orderEntitiesList(schema);

		// onCreate
		boolean useForeignKey = generateOnCreate(schema, orderedEntities);

		// onUpgrade
		generateOnUpgrade(schema, orderedEntities);

		// onConfigure
		generateOnConfigure(useForeignKey);

		// generate
		generateDaoUids(classBuilder, schema);

		//
		// generate prepared statement cleaner
		{

			MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("clearCompiledStatements")
					.addModifiers(Modifier.PUBLIC).returns(Void.TYPE);
			for (SQLiteDaoDefinition dao : schema.getCollection()) {
				methodBuilder.addStatement("$T.clearCompiledStatements()",
						TypeUtility.className(dao.getElement().getQualifiedName().toString() + "Impl"));
			}

			classBuilder.addMethod(methodBuilder.build());
		}

		// generate single thread datasource
		generateDataSourceSingleThread(schema, dataSourceClassName.simpleName());

		// generate build
		generateInstanceOrBuild(schema, dataSourceClassName.simpleName(), false);

		{
			Builder f = FieldSpec
					.builder(ArrayTypeName.of(SQLiteTable.class), "TABLES", Modifier.FINAL, Modifier.STATIC)
					.addJavadoc("List of tables compose datasource\n");

			com.squareup.javapoet.CodeBlock.Builder c = CodeBlock.builder();
			String s = "";

			c.add("{");
			for (SQLiteEntity entity : schema.getEntities()) {
				String tableName = BindTableGenerator.getTableClassName(entity.getName());

				c.add(s + "new $T()", TypeUtility.className(tableName));
				s = ", ";
			}

			for (GeneratedTypeElement entity : schema.generatedEntities) {
				String tableName = BindTableGenerator.getTableClassName(entity.getQualifiedName());

				c.add(s + "new $T()", TypeUtility.className(tableName));
				s = ", ";
			}

			c.add("}");
			f.initializer(c.build());
			classBuilder.addField(f.build());

			classBuilder.addMethod(MethodSpec.methodBuilder("tables").addJavadoc("List of tables compose datasource:\n")
					.addModifiers(Modifier.PUBLIC, Modifier.STATIC).addStatement("return TABLES")
					.returns(ArrayTypeName.of(SQLiteTable.class)).build());
		}

		TypeSpec typeSpec = classBuilder.build();
		JavaWriterHelper.writeJava2File(filer, dataSourceClassName.packageName(), typeSpec);
	}
103536
public static DataSource create(DataSource ds, Log log) {
        if (ds == null) {
            throw new IllegalArgumentException();
        }
        if (log == null) {
            log = LogFactory.getLog(LoggingDataSource.class);
        }
        if (!log.isDebugEnabled()) {
            return ds;
        }
        return new LoggingDataSource(log, ds);
    }
925455
private void addSizeColumn() {

        Column<CmsHistoryResourceBean, ?> col = new TextColumn<CmsHistoryResourceBean>() {

            @Override
            public String getValue(CmsHistoryResourceBean historyRes) {

                return "" + historyRes.getSize();
            }
        };
        addColumn(col, CmsHistoryMessages.columnSize());
        setColumnWidth(col, 100, Unit.PX);
    }
1324700
public List<InputColumn<?>> getAvailableInputColumns(final ComponentBuilder componentBuilder,
            final Class<?> dataType) {
        List<InputColumn<?>> result = getAvailableInputColumns(dataType);

        final SourceColumnFinder finder = new SourceColumnFinder();
        finder.addSources(this);

        result = CollectionUtils.filter(result, new Predicate<InputColumn<?>>() {
            @Override
            public Boolean eval(InputColumn<?> inputColumn) {
                if (inputColumn.isPhysicalColumn()) {
                    return true;
                }

                final InputColumnSourceJob origin = finder.findInputColumnSource(inputColumn);
                if (origin == null) {
                    return true;
                }

                if (origin == componentBuilder) {
                    // exclude columns from the component itself
                    return false;
                }

                final Set<Object> sourceComponents = finder.findAllSourceJobs(origin);
                if (sourceComponents.contains(componentBuilder)) {
                    // exclude columns that depend
                    return false;
                }

                return true;
            }
        });

        return result;
    }
218141
@Override
  protected MtasDataItemDoubleFull getItem(int i) {
    if (i >= 0 && i < size) {
      return new MtasDataItemDoubleFull(
          ArrayUtils.toPrimitive(fullValueList[i]),
          hasSub() ? subCollectorListNextLevel[i] : null, getStatsItems(),
          sortType, sortDirection, errorNumber[i], errorList[i],
          sourceNumberList[i]);
    } else {
      return null;
    }
  }
5603
private void fillDetailResourceTypes(CmsListItem item, String detailId) {

        CmsSearchManager searchManager = OpenCms.getSearchManager();
        StringBuffer html = new StringBuffer();

        String doctypeName = (String)item.get(LIST_COLUMN_NAME);
        CmsSearchDocumentType docType = searchManager.getDocumentTypeConfig(doctypeName);

        // output of resource types
        Iterator<String> itResourcetypes = docType.getResourceTypes().iterator();
        html.append("<ul>\n");
        while (itResourcetypes.hasNext()) {
            html.append("  <li>\n").append("  ").append(itResourcetypes.next()).append("\n");
            html.append("  </li>");
        }

        html.append("</ul>\n");
        item.set(detailId, html.toString());
    }
953661
@Override
    public Object generate(Client<?> client, String dataType)
    {

        final String generatedId = "Select now() from system_schema.columns";
        ResultSet rSet = ((DSClient) client).execute(generatedId, null);

        UUID uuid = rSet.iterator().next().getUUID(0);
        return uuid;
    }
1314518
public static DataSource createDataSource(String source, String type, String... configs){
		String config = StringUtils.join(configs, " ");
		return createDataSource(source, type, config);
	}
904908
public static DataSource createDataSource(final byte[] yamlBytes) throws SQLException, IOException {
        YamlOrchestrationShardingRuleConfiguration config = unmarshal(yamlBytes);
        return createDataSource(config.getDataSources(), config.getShardingRule(), config.getProps(), config.getOrchestration());
    }
1147649
@SuppressWarnings("deprecation")
    private CmsNewResourceInfo createResourceTypeInfo(I_CmsResourceType resType, CmsResource copyResource) {

        String name = resType.getTypeName();
        Locale locale = getWorkplaceLocale();
        String subtitle = CmsWorkplaceMessages.getResourceTypeDescription(locale, name);
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(subtitle)) {
            subtitle = CmsWorkplaceMessages.getResourceTypeName(locale, name);
        }
        if (copyResource != null) {
            CmsNewResourceInfo info = new CmsNewResourceInfo(
                copyResource.getTypeId(),
                name,
                CmsWorkplaceMessages.getResourceTypeName(locale, name),
                CmsWorkplaceMessages.getResourceTypeDescription(locale, name),
                copyResource.getStructureId(),
                false,
                subtitle);
            info.setBigIconClasses(CmsIconUtil.getIconClasses(name, null, false));
            return info;
        } else {
            CmsNewResourceInfo info = new CmsNewResourceInfo(
                resType.getTypeId(),
                name,
                CmsWorkplaceMessages.getResourceTypeName(locale, name),
                CmsWorkplaceMessages.getResourceTypeDescription(locale, name),
                null,
                false,
                subtitle);
            info.setBigIconClasses(CmsIconUtil.getIconClasses(name, null, false));
            return info;
        }
    }
1366124
protected GenericDataSourceBase<OUT, ?> translateToDataFlow() {
		String name = this.name != null ? this.name : "at " + dataSourceLocationName + " (" + inputFormat.getClass().getName() + ")";
		if (name.length() > 150) {
			name = name.substring(0, 150);
		}

		@SuppressWarnings({"unchecked", "rawtypes"})
		GenericDataSourceBase<OUT, ?> source = new GenericDataSourceBase(this.inputFormat,
			new OperatorInformation<OUT>(getType()), name);
		source.setParallelism(parallelism);
		if (this.parameters != null) {
			source.getParameters().addAll(this.parameters);
		}
		if (this.splitDataProperties != null) {
			source.setSplitDataProperties(this.splitDataProperties);
		}
		return source;
	}