Creates new {@linkplain WebArgumentMetadata} in the target and copies all meta data.

@param sourceView source jCas
@param targetView target jCas
@throws IllegalArgumentException if the {@code targetView} already contains
{@linkplain WebArgumentMetadata}
13100
public static void copy(final JCas sourceView, final JCas targetView)
            throws IllegalArgumentException
    {
        if (hasWebArgumentMetadata(targetView)) {
            throw new IllegalArgumentException(
                    "Target view already contains " + WebArgumentMetadata.class.getName());
        }

        WebArgumentMetadata source = get(sourceView);
        WebArgumentMetadata target = new WebArgumentMetadata(targetView);

        target.setAuthor(source.getAuthor());
        target.setDate(source.getDate());
        target.setDocType(source.getDocType());
        target.setOrigUrl(source.getOrigUrl());
        target.setTopic(source.getTopic());
        target.setThumbsDown(source.getThumbsDown());
        target.setThumbsUp(source.getThumbsUp());
        target.setNotes(source.getNotes());
        target.setOrigId(source.getOrigId());
        target.setTitle(source.getTitle());

        target.addToIndexes();
    }
1219577
@Override
	public String createTarget( String targetContent ) throws IOException {

		// Get the target ID
		TargetValidator tv = new TargetValidator( targetContent );
		tv.validate();
		if( RoboconfErrorHelpers.containsCriticalErrors( tv.getErrors()))
			throw new IOException( "There are errors in the target definition." );

		// Critical section to insert a target.
		// Store the ID, it cannot be reused.
		String targetId = tv.getProperties().getProperty( Constants.TARGET_PROPERTY_ID );
		String creator = tv.getProperties().getProperty( CREATED_BY );
		if( this.targetIds.putIfAbsent( targetId, Boolean.TRUE ) != null ) {

			// No creator? Then there is a conflict.
			if( creator == null )
				throw new IOException( "ID " + targetId + " is already used." );

			// It cannot be reused, unless they were created by the same template.
			File createdByFile = new File( findTargetDirectory( targetId ), CREATED_BY );
			String storedCreator = null;
			if( createdByFile.exists())
				storedCreator = Utils.readFileContent( createdByFile );

			// If they do not match, throw an exception
			if( ! Objects.equals( creator, storedCreator ))
				throw new IOException( "ID " + targetId + " is already used." );

			// Otherwise, we can override the properties
		}

		// Rewrite the properties without the ID.
		// We do not want it to be modified later.
		// We do not serialize java.util.properties#store because it adds
		// a time stamp, removes user comments and looses the properties order.
		targetContent = targetContent.replaceAll( Constants.TARGET_PROPERTY_ID + "\\s*(:|=)[^\n]*(\n|$)", "" );

		// For the same reason, we remove the "created.by" property
		targetContent = targetContent.replaceAll( "\n\n" + Pattern.quote( CREATED_BY ) + "\\s*(:|=)[^\n]*(\n|$)", "" );

		// Write the properties
		File targetFile = new File( findTargetDirectory( targetId ), Constants.TARGET_PROPERTIES_FILE_NAME );
		Utils.createDirectory( targetFile.getParentFile());
		Utils.writeStringInto( targetContent, targetFile );

		// Write the creator, if any
		if( creator != null ) {
			File createdByFile = new File( findTargetDirectory( targetId ), CREATED_BY );
			Utils.writeStringInto( creator, createdByFile );
		}

		return targetId;
	}
166005
public <T> Evaluator<T> create(QueryMetadata metadata, List<? extends Expression<?>> sources,
            Expression<T> projection) {
        final CollQuerySerializer serializer = new CollQuerySerializer(templates);
        serializer.append("return ");
        if (projection instanceof FactoryExpression<?>) {
            serializer.append("(");
            serializer.append(ClassUtils.getName(projection.getType()));
            serializer.append(")(");
            serializer.handle(projection);
            serializer.append(")");
        } else {
            serializer.handle(projection);
        }
        serializer.append(";");

        Map<Object,String> constantToLabel = serializer.getConstantToLabel();
        Map<String, Object> constants = getConstants(metadata, constantToLabel);
        Class<?>[] types = new Class<?>[sources.size()];
        String[] names = new String[sources.size()];
        for (int i = 0; i < sources.size(); i++) {
            types[i] = sources.get(i).getType();
            names[i] = sources.get(i).toString();
        }

        // normalize types
        for (int i = 0; i < types.length; i++) {
            if (Primitives.isWrapperType(types[i])) {
                types[i] = Primitives.unwrap(types[i]);
            }
        }

        return factory.createEvaluator(serializer.toString(), projection.getType(), names,
                types, constants);
    }
1075410
protected static String addFileNameToTargetPath(String sourcePath, String targetPath) {
        if (targetPath.endsWith("/")) {
            String filename = Paths.get(sourcePath).getFileName().toString();
            return targetPath + filename;
        }
        return targetPath;
    }
1064122
public static <E> ReadableSource<E> asSource(View<E> view) {
    return new DatasetSourceTarget<E>(view);
  }
396244
public WebTarget appendPathAndQueryParameters(final WebTarget webTarget) {
    ArgumentChecker.notNull(webTarget, "webTarget");
    WebTarget resultTarget = webTarget;
    resultTarget = resultTarget.path(MULTI_SET_NAME + EXTENSION);
    resultTarget = resultTarget.queryParam(COLUMNS_PARAM, buildCodeList(_quandlCodeRequests));
    if (_startDate != null) {
      resultTarget = resultTarget.queryParam(START_DATE_PARAM, _startDate.toString());
    }
    if (_endDate != null) {
      resultTarget = resultTarget.queryParam(END_DATE_PARAM, _endDate.toString());
    }
    if (_frequency != null) {
      resultTarget = resultTarget.queryParam(FREQUENCY_PARAM, _frequency.getQuandlString());
    }
    if (_maxRows != null) {
      resultTarget = resultTarget.queryParam(MAX_ROWS_PARAM, _maxRows);
    }
    if (_transform != null) {
      resultTarget = resultTarget.queryParam(TRANSFORM_PARAM, _transform.getQuandlString());
    }
    if (_sortOrder != null) {
      resultTarget = resultTarget.queryParam(SORT_ORDER_PARAM, _sortOrder.getQuandlString());
    }
    return resultTarget;
  }
206211
@Override
    public T addAsWebInfResource(final Asset resource, final String target) throws IllegalArgumentException {
        Validate.notNull(resource, "Resource should be specified");
        Validate.notNullOrEmpty(target, "Target should be specified");

        return addAsWebInfResource(resource, ArchivePaths.create(target));
    }
599814
@Override
    public T add(Asset asset, ArchivePath target) throws IllegalArgumentException {
        this.getArchive().add(asset, target);
        return covarientReturn();
    }
861928
@Override
    public T addAsWebResource(Asset resource, String target) throws IllegalArgumentException {
        Validate.notNull(resource, "Resource should be specified");
        Validate.notNull(target, "Target should be specified");

        return addAsWebResource(resource, new BasicPath(target));
    }
590928
@Override
    public T addAsResource(String resourceName, ArchivePath target, ClassLoader classLoader)
        throws IllegalArgumentException {
        Validate.notNull(resourceName, "ResourceName should be specified");
        Validate.notNull(target, "Target should be specified");
        Validate.notNull(classLoader, "ClassLoader should be specified");

        return addAsResource(new ClassLoaderAsset(resourceName, classLoader), target);
    }
1044566
@Override
    public T addAsModule(final String resourceName, final String targetPath) throws IllegalArgumentException {
        Validate.notNull(resourceName, "Resource must be specified");
        Validate.notNull(targetPath, "Target Path must be specified");

        return addAsModule(resourceName, new BasicPath(targetPath));
    }
1197565
@Override
    public T addAsManifestResource(Package resourcePackage, String resourceName, String target)
        throws IllegalArgumentException {
        Validate.notNull(resourcePackage, "ResourcePackage must be specified");
        Validate.notNull(resourceName, "ResourceName must be specified");
        Validate.notNull(target, "Target must be specified");

        return addAsManifestResource(resourcePackage, resourceName, ArchivePaths.create(target));
    }
1303494
@Override
    public T addAsManifestResource(String resourceName, String target) throws IllegalArgumentException {
        Validate.notNull(resourceName, "ResourceName should be specified");
        Validate.notNull(target, "Target should be specified");

        return addAsManifestResource(fileFromResource(resourceName), target);
    }
559733
public static String dumpArguments(JCas jCas, boolean includeProperties, boolean includeRelations)
    {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        PrintStream out = new PrintStream(outputStream);

        String documentId = DocumentMetaData.get(jCas).getDocumentId();

        out.println("======== #" + documentId + " begin ==========================");

        Collection<ArgumentComponent> argumentComponents = JCasUtil
                .select(jCas, ArgumentComponent.class);

        out.println("----------------- ArgumentComponent -----------------");
        out.println("# of argument units: " + argumentComponents.size());

        for (ArgumentComponent argumentComponent : argumentComponents) {
            out.println(argumentUnitToString(argumentComponent));

            if (includeProperties) {
                out.println(formatProperties(argumentComponent));
            }

            if (argumentComponent instanceof Claim) {
                Claim claim = (Claim) argumentComponent;
                String stance = claim.getStance();

                if (stance != null) {
                    out.println("Stance: " + stance);
                }
            }
        }

        Collection<ArgumentRelation> argumentRelations = JCasUtil
                .select(jCas, ArgumentRelation.class);

        if (includeRelations) {
            out.println("----------------- ArgumentRelation -----------------");
            out.println("# of argument relations: " + argumentRelations.size());

            for (ArgumentRelation argumentRelation : argumentRelations) {
                out.println(argumentRelation.getType().getShortName());
                out.println("   source: " + argumentUnitToString(
                        argumentRelation.getSource()));
                out.println("   target: " + argumentUnitToString(
                        argumentRelation.getTarget()));

                if (includeProperties) {
                    out.println(formatProperties(argumentRelation));
                }
            }
        }

        out.println("======== #" + documentId + " end ==========================");

        try {
            return outputStream.toString("utf-8");
        }
        catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
239344
private List<PBXObjectRef> addSources(final Map objects, final String sourceTree, final String basePath,
      final Map<String, TargetInfo> targets) {
    final List<PBXObjectRef> sourceGroupChildren = new ArrayList<>();

    final List<File> sourceList = new ArrayList<>(targets.size());
    for (final TargetInfo info : targets.values()) {
      final File[] targetsources = info.getSources();
      Collections.addAll(sourceList, targetsources);
    }
    final File[] sortedSources = sourceList.toArray(new File[sourceList.size()]);
    Arrays.sort(sortedSources, new Comparator<File>() {
      @Override
      public int compare(final File o1, final File o2) {
        return o1.getName().compareTo(o2.getName());
      }
    });
    for (final File sortedSource : sortedSources) {
      final PBXObjectRef fileRef = createPBXFileReference(sourceTree, basePath, sortedSource);
      sourceGroupChildren.add(fileRef);
      objects.put(fileRef.getID(), fileRef.getProperties());
    }

    return sourceGroupChildren;
  }
1031964
public static <T> void bindArguments(T target, Bundle bundle) {
        @SuppressWarnings("unchecked")
        BundleBinding<T> binding = (BundleBinding<T>) getBundleBinding(target.getClass().getClassLoader(), target.getClass());
        if (binding != null) {
            binding.bindArguments(target, bundle);
        }
    }
783346
public function merge(PropertyMetadata $sourceMapping, PropertyMetadata $targetMapping)
    {
        foreach (get_object_vars($sourceMapping) as $key => $value) {
            if ($value !== null) {
                $targetMapping->{$key} = $value;
            }
        }

        return $targetMapping;
    }