text:
package com.mapcode;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;

import static com.mapcode.Boundary.createBoundaryForTerritoryRecord;
import static com.mapcode.Common.*;

 // ----------------------------------------------------------------------------------------------
 // Package private implementation class. For internal use within the Mapcode implementation only.
 // ----------------------------------------------------------------------------------------------

/**
 * This class contains encoder for mapcodes.
 */
@SuppressWarnings({"MagicNumber", "StringConcatenationMissingWhitespace"})
final class Encoder {
    private static final Logger LOG = LoggerFactory.getLogger(Encoder.class);

    // Get direct access to data model singleton.
    private static final DataModel DATA_MODEL = DataModel.getInstance();

    private Encoder() {
        // Prevent instantiation.
    }

    // ----------------------------------------------------------------------
    // Method called from public Java API.
    // ----------------------------------------------------------------------

    @Nonnull
    static List<Mapcode> encode(
            final double latDeg,
            final double lonDeg,
            @Nullable final Territory territory,
            final boolean limitToOneResult) {

        return encode(latDeg, lonDeg, territory, limitToOneResult, null);
    }

    // ----------------------------------------------------------------------
    // Private methods.
    // ----------------------------------------------------------------------

    private final static char[] ENCODE_CHARS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'B', 'C', 'D', 'F',
            'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z', 'A', 'E', 'U'};

    @Nonnull
    private static List<Mapcode> encode(
            final double argLatDeg,
            final double argLonDeg,
            @Nullable final Territory territory,
            final boolean limitToOneResult,
            @Nullable final Territory argStateOverride) {
        LOG.trace("encode: latDeg={}, lonDeg={}, territory={}, limitToOneResult={}",
                argLatDeg, argLonDeg, (territory == null) ? null : territory.name(), limitToOneResult);

        final Point pointToEncode = Point.fromDeg(argLatDeg, argLonDeg);
        final List<Mapcode> results = new ArrayList<Mapcode>();
        int lastBaseSubTerritoryNumber = -1;

        // Determine whether to walk through all records, or just for one (given) territory.
        final int firstTerritoryRecord = (territory != null) ? territory.getNumber() : 0;
        final int lastTerritoryRecord = (territory != null) ? territory.getNumber() : Territory.AAA.getNumber();
        for (int territoryRecord = firstTerritoryRecord; territoryRecord <= lastTerritoryRecord; territoryRecord++) {

            // Check if the point to encode is covered by the last data record.
            final int firstSubTerritoryRecord = DATA_MODEL.getDataLastRecord(territoryRecord);
            if (createBoundaryForTerritoryRecord(firstSubTerritoryRecord).containsPoint(pointToEncode)) {

                final int lastSubTerritoryRecord = DATA_MODEL.getDataFirstRecord(territoryRecord);
                final Territory currentEncodeTerritory = Territory.fromNumber(territoryRecord);

                for (int subTerritoryRecord = lastSubTerritoryRecord; subTerritoryRecord <= firstSubTerritoryRecord; subTerritoryRecord++) {

                    // Check if the point to encode is contained within the boundary.
                    if (createBoundaryForTerritoryRecord(subTerritoryRecord).containsPoint(pointToEncode)) {

                        // All fine, proceed with creating a mapcode.
                        String mapcode = "";
                        if (Data.isNameless(subTerritoryRecord)) {
                            mapcode = encodeNameless(pointToEncode, subTerritoryRecord, lastSubTerritoryRecord);

                        } else if (Data.getTerritoryRecordType(subTerritoryRecord) > Data.TERRITORY_RECORD_TYPE_PIPE) {
                            mapcode = encodeAutoHeader(pointToEncode, subTerritoryRecord);

                        } else if ((subTerritoryRecord == firstSubTerritoryRecord) &&
                                (currentEncodeTerritory.getParentTerritory() != null)) {
                            results.addAll(encode(argLatDeg, argLonDeg, currentEncodeTerritory.getParentTerritory(),
                                    limitToOneResult, currentEncodeTerritory));
                            continue;

                        } else if (!Data.isRestricted(subTerritoryRecord) || (lastBaseSubTerritoryNumber == lastSubTerritoryRecord)) {
                            if (Data.getCodex(subTerritoryRecord) < 54) {
                                mapcode = encodeGrid(subTerritoryRecord, pointToEncode);
                            }
                        } else {
                            // Skip this record.
                        }

                        // Check if we created a mapcode.
                        if (!mapcode.isEmpty()) {
                            assert mapcode.length() > 4;
                            mapcode = aeuPack(mapcode, false);

                            final Territory encodeTerritory = (argStateOverride != null) ?
                                    argStateOverride : currentEncodeTerritory;

                            // Create new result.
                            final Mapcode newResult = new Mapcode(mapcode, encodeTerritory);

                            // The result should not be stored yet.
                            if (results.contains(newResult)) {
                                LOG.error("encode: Duplicate results found, newResult={}, results={} items",
                                        newResult.getCodeWithTerritory(), results.size());
                            } else {

                                // Remove existing results (if there was a parent territory).
                                if (limitToOneResult) {
                                    results.clear();
                                }
                                results.add(newResult);
                            }

                            lastBaseSubTerritoryNumber = lastSubTerritoryRecord;

                            // Stop if we only need a single result anyway.
                            if (limitToOneResult) {
                                return results;
                            }
                        }
                    }
                }
            }
        }
        LOG.trace("encode: results={} items", results.size());
        LOG.trace("");
        return results;
    }

    @Nonnull
    private static String encodeExtension(
            final Point pointToEncode,
            final int extrax4,
            final int extray,
            final int dividerx4,
            final int dividery,
            final int ydirection) {
        int extraDigits = 8; // always generate 8 digits

        double factorx = Point.MAX_PRECISION_FACTOR * dividerx4;
        double factory = Point.MAX_PRECISION_FACTOR * dividery;
        double valx = (Point.MAX_PRECISION_FACTOR * extrax4) + pointToEncode.getLonFraction();
        double valy = (Point.MAX_PRECISION_FACTOR * extray) + (ydirection * pointToEncode.getLatFraction());

        final StringBuilder sb = new StringBuilder();
        sb.append('-');

        while (true) {
            factorx /= 30;
            //noinspection NumericCastThatLosesPrecision
            final int gx = (int) (valx / factorx);

            factory /= 30;
            //noinspection NumericCastThatLosesPrecision
            final int gy = (int) (valy / factory);

            sb.append(ENCODE_CHARS[((gy / 5) * 5) + (gx / 6)]);
            --extraDigits;
            if (extraDigits == 0) {
                break;
            }

            sb.append(ENCODE_CHARS[(((gy % 5) * 6) + (gx % 6))]);
            --extraDigits;
            if (extraDigits == 0) {
                break;
            }

            valx -= factorx * gx;
            valy -= factory * gy;
        }
        return sb.toString();
    }

    @Nonnull
    private static String encodeGrid(
            final int territoryNumber,
            @Nonnull final Point pointToEncode) {
        int codexm = Data.getCodex(territoryNumber);
        final int orgcodex = codexm;
        if (codexm == 21) {
            codexm = 22;
        } else if (codexm == 14) {
            codexm = 23;
        }
        final int prelen = codexm / 10;
        final int postlen = codexm % 10;
        final int divx;
        int divy = DATA_MODEL.getSmartDiv(territoryNumber);
        if (divy == 1) {
            divx = X_SIDE[prelen];
            divy = Y_SIDE[prelen];
        } else {
            divx = NC[prelen] / divy;
        }

        final int minx = createBoundaryForTerritoryRecord(territoryNumber).getLonMicroDegMin();
        final int miny = createBoundaryForTerritoryRecord(territoryNumber).getLatMicroDegMin();
        final int maxx = createBoundaryForTerritoryRecord(territoryNumber).getLonMicroDegMax();
        final int maxy = createBoundaryForTerritoryRecord(territoryNumber).getLatMicroDegMax();

        final int ygridsize = (((maxy - miny) + divy) - 1) / divy;
        int rely = pointToEncode.getLatMicroDeg() - miny;
        rely = rely / ygridsize;

        final int xgridsize = (((maxx - minx) + divx) - 1) / divx;
        int x = pointToEncode.getLonMicroDeg();
        int relx = x - minx;
        if (relx < 0) {
            x += Point.MICRO_DEG_360;
            relx += Point.MICRO_DEG_360;
        } else if (relx >= Point.MICRO_DEG_360) {
            x -= Point.MICRO_DEG_360;
            relx -= Point.MICRO_DEG_360;
        }
        if (relx < 0) {
            return "";
        }
        relx = relx / xgridsize;
        if ((relx >= divx) || (rely >= divy)) {
            return "";
        }

        final int v;
        if ((divx != divy) && (prelen > 2)) {
            v = encodeSixWide(relx, rely, divx, divy);
        } else {
            v = ((relx * divy) + divy) - 1 - rely;
        }

        String result = encodeBase31(v, prelen);

        if ((prelen == 4) && (divx == 961) && (divy == 961)) {
            result = String.valueOf(result.charAt(0)) + result.charAt(2) + result.charAt(1) + result.charAt(3);
        }

        rely = miny + (rely * ygridsize);
        relx = minx + (relx * xgridsize);

        final int dividery = ((ygridsize + Y_SIDE[postlen]) - 1) / Y_SIDE[postlen];
        final int dividerx = ((xgridsize + X_SIDE[postlen]) - 1) / X_SIDE[postlen];

        result += '.';

        int difx = x - relx;
        int dify = pointToEncode.getLatMicroDeg() - rely;

        final int extrax = difx % dividerx;
        final int extray = dify % dividery;

        difx = difx / dividerx;
        dify = dify / dividery;

        dify = Y_SIDE[postlen] - 1 - dify;
        if (postlen == 3) {
            result += encodeTriple(difx, dify);
        } else {

            String postfix = encodeBase31(((difx) * Y_SIDE[postlen]) + dify, postlen);
            if (postlen == 4) {
                postfix = String.valueOf(postfix.charAt(0)) + postfix.charAt(2) + postfix.charAt(1) + postfix.charAt(3);
            }
            result += postfix;
        }

        if (orgcodex == 14) {
            result = result.charAt(0) + "." + result.charAt(1) + result.substring(3);
        }

        result += encodeExtension(pointToEncode, extrax << 2, extray, dividerx << 2, dividery, 1); // grid

        return Data.headerLetter(territoryNumber) + result;
    }

    @Nonnull
    private static String encodeAutoHeader(
            @Nonnull final Point pointToEncode,
            final int territoryRecord) {
        final StringBuilder stringBuilder = new StringBuilder();
        final int codexm = Data.getCodex(territoryRecord);
        int storageStart = 0;

        // search back to first pipe star
        int firstindex = territoryRecord;
        while ((Data.getTerritoryRecordType(firstindex - 1) > Data.TERRITORY_RECORD_TYPE_PIPE) && (Data.getCodex(firstindex - 1) == codexm)) {
            firstindex--;
        }

        int i = firstindex;
        while (true) {

            final int maxx = createBoundaryForTerritoryRecord(i).getLonMicroDegMax();
            final int maxy = createBoundaryForTerritoryRecord(i).getLatMicroDegMax();
            final int minx = createBoundaryForTerritoryRecord(i).getLonMicroDegMin();
            final int miny = createBoundaryForTerritoryRecord(i).getLatMicroDegMin();

            int h = ((maxy - miny) + 89) / 90;
            final int xdiv = xDivider(miny, maxy);
            int w = ((((maxx - minx) * 4) + xdiv) - 1) / xdiv;

            h = 176 * (((h + 176) - 1) / 176);
            w = 168 * (((w + 168) - 1) / 168);

            int product = (w / 168) * (h / 176) * 961 * 31;

            if (Data.getTerritoryRecordType(i) == Data.TERRITORY_RECORD_TYPE_PLUS) // plus pipe
            {
                final int goodRounder = (codexm >= 23) ? (961 * 961 * 31) : (961 * 961);
                product = ((((storageStart + product + goodRounder) - 1) / goodRounder) * goodRounder) - storageStart;
            }

            if (i == territoryRecord) {
                final int dividerx = (((maxx - minx) + w) - 1) / w;
                final int vx = (pointToEncode.getLonMicroDeg() - minx) / dividerx;
                final int extrax = (pointToEncode.getLonMicroDeg() - minx) % dividerx;

                final int dividery = (((maxy - miny) + h) - 1) / h;
                int vy = (maxy - pointToEncode.getLatMicroDeg()) / dividery;
                int extray = (maxy - pointToEncode.getLatMicroDeg()) % dividery;

                int value = (vx / 168) * (h / 176);
                if ((extray == 0) && (pointToEncode.getLatFraction() > 0)) {
                    vy--;
                    extray += dividery;
                }
                value += (vy / 176);

                final int codexlen = (codexm / 10) + (codexm % 10);
                stringBuilder.append(encodeBase31((storageStart / (961 * 31)) + value, codexlen - 2));
                stringBuilder.append('.');
                stringBuilder.append(encodeTriple(vx % 168, vy % 176));

                stringBuilder.append(
                        encodeExtension(pointToEncode, extrax << 2, extray, dividerx << 2, dividery, -1)); // AutoHeader
                return stringBuilder.toString();
            }

            storageStart += product;
            i++;
        }
    }

    @Nonnull
    private static String encodeNameless(
            @Nonnull final Point pointToEncode,
            final int territoryRecord,
            final int firstTerritoryRecord) {
        // mid-level encode/decode
        // returns "" in case of (argument) error
        final int codexm = Data.getCodex(territoryRecord);
        final int codexlen = (codexm / 10) + (codexm % 10);
        final int firstNamelessRecord = getFirstNamelessRecord(codexm, territoryRecord, firstTerritoryRecord);
        final int a = countCityCoordinatesForCountry(codexm, territoryRecord, firstTerritoryRecord);
        final int p = 31 / a;
        final int r = 31 % a;
        final int nrX = territoryRecord - firstNamelessRecord;

        int storage_offset;

        if ((codexm != 21) && (a <= 31)) {
            storage_offset = ((nrX * p) + ((nrX < r) ? nrX : r)) * (961 * 961);
        } else if ((codexm != 21) && (a < 62)) {
            if (nrX < (62 - a)) {
                storage_offset = nrX * 961 * 961;
            } else {
                storage_offset = ((62 - a) + (((nrX - 62) + a) / 2)) * 961 * 961;
                if (((nrX + a) & 1) != 0) {
                    storage_offset += 16 * 961 * 31;
                }
            }
        } else {
            final int basePower = (codexm == 21) ? (961 * 961) : (961 * 961 * 31);
            int basePowerA = basePower / a;
            if (a == 62) {
                basePowerA++;
            } else {
                basePowerA = 961 * (basePowerA / 961);
            }

            storage_offset = nrX * basePowerA;
        }

        int side = DATA_MODEL.getSmartDiv(territoryRecord);
        final int orgSide = side;
        int xSide = side;

        final int maxy = createBoundaryForTerritoryRecord(territoryRecord).getLatMicroDegMax();
        final int minx = createBoundaryForTerritoryRecord(territoryRecord).getLonMicroDegMin();
        final int miny = createBoundaryForTerritoryRecord(territoryRecord).getLatMicroDegMin();

        final int dividerx4 = xDivider(miny, maxy);
        final int xFracture = pointToEncode.getLonFraction() / 810000;
        final int dminx = pointToEncode.getLonMicroDeg() - minx;
        final int dx = ((4 * dminx) + xFracture) / dividerx4;
        final int extrax4 = (4 * dminx) - (dx * dividerx4); // like modulus, but with floating point value

        final int dividery = 90;
        final int dmaxy = maxy - pointToEncode.getLatMicroDeg();
        int dy = dmaxy / dividery;
        int extray = dmaxy % dividery;

        if ((extray == 0) && (pointToEncode.getLatFraction() > 0)) {
            dy--;
            extray += dividery;
        }

        int v = storage_offset;
        if (Data.isSpecialShape(territoryRecord)) {
            xSide *= side;
            side = 1 + ((maxy - miny) / 90);
            xSide = xSide / side;
            v += encodeSixWide(dx, side - 1 - dy, xSide, side);
        } else {
            v += (dx * side) + dy;
        }

        String result = encodeBase31(v, codexlen + 1);

        if (codexlen == 3) {
            result = result.substring(0, 2) + '.' + result.substring(2);
        } else if (codexlen == 4) {
            if ((codexm == 22) && (a < 62) && (orgSide == 961) && !Data.isSpecialShape(territoryRecord)) {
                result = result.substring(0, 2) + result.charAt(3) + result.charAt(2) + result.charAt(4);
            }
            if (codexm == 13) {
                result = result.substring(0, 2) + '.' + result.substring(2);
            } else {
                result = result.substring(0, 3) + '.' + result.substring(3);
            }
        }
        result += encodeExtension(pointToEncode, extrax4, extray, dividerx4, dividery, -1); // for encodeNameless

        return result;
    }

    @Nonnull
    static String aeuPack(
            @Nonnull final String argStr,
            final boolean argShort) {
        // add vowels to prevent all-digit mapcodes
        String str = argStr;
        int dotpos = -9;
        int rlen = str.length();
        int d;
        String rest = "";
        for (d = 0; d < rlen; d++) {
            if ((str.charAt(d) < '0') || (str.charAt(d) > '9')) // not digit?
            {
                if ((str.charAt(d) == '.') && (dotpos < 0)) // first dot?
                {
                    dotpos = d;
                } else if (str.charAt(d) == '-') {
                    rest = str.substring(d);
                    str = str.substring(0, d);
                    rlen = d;
                } else {
                    return str; // not all-digit (or multiple dots)
                }
            }
        }

        if ((rlen - 2) > dotpos) {
            // does r have a dot, AND at least 2 chars after the dot?
            if (argShort) { // use A only
                final int v = ((((int) str.charAt(0)) - 48) * 100) + ((((int) str.charAt(rlen - 2)) - 48) * 10) + (((int) str.charAt(rlen - 1)) - 48);
                return 'A' + str.substring(1, rlen - 2) + ENCODE_CHARS[v / 32] + ENCODE_CHARS[v % 32] + rest;
            } else { // use A, E and U
                final int v = (((((int) str.charAt(rlen - 2)) - 48) * 10) + ((int) str.charAt(rlen - 1))) - 48;
                str = str.substring(0, rlen - 2) + ENCODE_CHARS[31 + (v / 34)] + ENCODE_CHARS[v % 34];
            }
        }
        return str + rest;
    }

    @Nonnull
    private static String encodeBase31(
            final int argValue,
            final int argNrChars) {
        int value = argValue;
        int nrChars = argNrChars;
        final StringBuilder result = new StringBuilder();
        while (nrChars > 0) {
            nrChars--;
            result.insert(0, ENCODE_CHARS[value % 31]);
            value = value / 31;
        }
        return result.toString();
    }

    private static int encodeSixWide(
            final int x,
            final int y,
            final int width,
            final int height) {
        final int d;
        int col = x / 6;
        final int maxcol = (width - 4) / 6;
        if (col >= maxcol) {
            col = maxcol;
            d = width - (maxcol * 6);
        } else {
            d = 6;
        }
        return ((height * 6 * col) + ((height - 1 - y) * d) + x) - (col * 6);
    }

    @Nonnull
    private static String encodeTriple(
            final int difx,
            final int dify) {
        if (dify < (4 * 34)) {
            return ENCODE_CHARS[((difx / 28) + (6 * (dify / 34)))] + encodeBase31(((difx % 28) * 34) + (dify % 34), 2);
        } else {
            return ENCODE_CHARS[((difx / 24) + 24)] + encodeBase31((((difx % 24) * 40) + dify) - 136, 2);
        }
    }
}


text:
<?php

namespace App\Http\Controllers;

use App\Http\Requests;
use Illuminate\Http\Request;
use App\Repositories\ArticleRepository;

class ArticleController extends Controller
{
    protected $article;

    public function __construct(ArticleRepository $article)
    {
        $this->article = $article;
    }

    /**
     * Display the articles resource.
     *
     * @return mixed
     */
    public function index($category='', Request $request)
    {
        $articles = $this->article->page($category,config('blog.article.number'), config('blog.article.sort'), config('blog.article.sortColumn'));

        return view('article.index', compact('articles'));
    }

    /**
     * Display the article resource by article slug.
     *
     * @param  string $slug
     * @return mixed
     */
    public function show($slug)
    {
        $article = $this->article->getBySlug($slug);

//        $article->content = collect(json_decode($article->content))->get('html');

        return view('article.show', compact('article'));
    }
}

redpajama_set_name: RedPajamaGithub


text:
package cn.xishan.oftenporter.porter.core.annotation.param;

import cn.xishan.oftenporter.porter.core.base.FilterEmpty;

import java.lang.annotation.*;

/**
 * 进行json序列化。
 * @author Created by https://github.com/CLovinr on 2018/6/30.
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
public @interface JSONSerialize
{
    /**
     * 默认为"",表示使用变量名;否则使用该值。
     */
    String value() default "";

    FilterEmpty filterNullAndEmpty() default FilterEmpty.AUTO;
}


text:
package com.base.spring.initialize;

import com.base.spring.domain.*;
import com.base.spring.repository.GroupRepository;
import com.base.spring.repository.RoleRepository;
import com.base.spring.repository.TreeRepository;
import com.base.spring.repository.UserRepository;
import com.base.spring.utils.BCryptPassWordUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.PostConstruct;
import java.util.*;

/**
 * Description : TODO(初始化相关数据)
 * User: h819
 * Date: 2016/1/18
 * Time: 15:38
 * To change this template use File | Settings | File Templates.
 */
@Service
@Transactional(readOnly = true)
@Slf4j
public class InitializeService {
    //private static final log log = LoggerFactory.getLogger(InitializeService.class);

    @Autowired
    TreeRepository treeRepository;
    @Autowired
    UserRepository userRepository;
    @Autowired
    GroupRepository groupRepository;
    @Autowired
    RoleRepository roleRepository;

//    private boolean initMenuTree =false;
//    private boolean initUser =false;
//    private boolean initGroup =false;
//    private boolean initRole =false;

    /**
     * 初始化 TreeNodeType 中定义的所有类型的根节点,所有节点均为该节点的子节点
     *
     * @PostConstruct // 在 Bean 初始化之前执行的操作
     * @PreDestroy //在 bean 销毁之前执行的操作
     */
    @PostConstruct // 在 InitializeService Bean 初始化之后执行的方法
    @Transactional(readOnly = false)
    public void initBaseData() {

        /**
         * 初始化 Tree ,保证根节点存在
         */

        List<TreeType> rootTreeType = treeRepository.findTreeTypes();
        List<TreeType> listType = Arrays.asList(TreeType.values());
        for (TreeType type : listType) {
            if (!rootTreeType.contains(type)) {
                log.info("init {} tree root node", type);
                TreeEntity root = new TreeEntity(type, "root_" + type, 0, true, null);
                treeRepository.save(root);
            }
        }

        /**
         * 初始化 Tree
         */
        initMenuTree();
        initPageResourceTree();
        initStandardTree();

        /**
         * 初始化 User
         */

        initUser();
    }

    /**
     * 初始化菜单树,作为基础树
     * 其中下面几个树节点,不能修改,为本系统默认的菜单(index.ftl 导航也是这个名称)
     * 1. 菜单管理
     * 1.1 树结构管理
     * 1.1.1 菜单树
     * 1.1.2 部门树
     * 1.1.3 其他业务树
     * -
     * 1.2 用户管理
     * 1.2.1 用户
     * 1.2.2 用户组
     * -
     * 1.3 角色管理
     * 1.3.1 菜单角色
     * 1.3.2 标准资源角色
     * -
     * <p>
     * 其他菜单只作为示例,可根据实际需要修改
     */
    private void initMenuTree() {

        /**
         * 包含 "菜单管理",意味着已经初始化,
         */
        List<TreeEntity> exist = treeRepository.findByName("菜单管理");

        if (!exist.isEmpty()) {
            log.info("menu tree has initialized , continue ");
            return;
        }

        log.info("initialize menu tree ... ");
        createMenuTree();

    }

    /**
     * 1. 按钮/资源
     * 1.1 菜单树
     * 1.1.1 树结构编辑
     * 1.1.2 节点 URL
     * -
     */
    private void initPageResourceTree() {

        /**
         * 包含 "按钮/资源" ,意味着已经初始化,
         */
        List<TreeEntity> exist = treeRepository.findByName("按钮/资源");

        if (!exist.isEmpty()) {
            log.info("menu tree has initialized , continue ");
            return;
        }

        log.info("initialize pageResource tree ... ");
        createPageResourceTree();

    }

    private void initStandardTree() {

        /**
         * 包含 "按钮/资源" ,意味着已经初始化,
         */
        List<TreeEntity> exist = treeRepository.findByName("国家标准");

        if (!exist.isEmpty()) {
            log.info("menu tree has initialized , continue ");
            return;
        }

        log.info("initialize standard tree ... ");
        createStandardTree();

    }

    private void createPageResourceTree() {
        //系统启动的时候,这几种类型的父节点已经创建完毕,在下面添加子节点即可
        TreeEntity pageResource = treeRepository.findRoot(TreeType.PageResource).get(); // PageResource
        Set<TreeEntity> set = new HashSet<>();

        /**
         * url 只适用于 ace admin 1.4 , ajax 方式
         * 注意 url 应该和 index.ftl , NavigateController 中 RequestMapping 对应
         * #page/admin/ztree-type?treeType=Menu
         * 只填写 #page/ 后面部分
         */

        /**
         * 初始化 "按钮/资源",为系统默认菜单,不能改动
         */
        //一级菜单
        TreeEntity menu = new TreeEntity(TreeType.Menu, "按钮/资源", 0, true, pageResource);
        set.addAll(Arrays.asList(menu));

        /**
         * 初始化 "按钮/资源" , 可以根据业务系统需要自行设计,这里仅为演示
         * -
         * 按钮/资源菜单仅为授权使用,系统不显示
         *
         */
        //一级菜单
        TreeEntity menu1 = new TreeEntity(TreeType.Menu, "菜单树", 0, true, menu);  //应用中的文件资源
        TreeEntity menu2 = new TreeEntity(TreeType.Menu, "文件资源", 1, true, menu);
        TreeEntity menu3 = new TreeEntity(TreeType.Menu, "其他资源", 2, true, menu);
        TreeEntity menu4 = new TreeEntity(TreeType.Menu, "PDF 文件", 3, true, menu);  //单独对 pdf 的操作
        set.addAll(Arrays.asList(menu1, menu2, menu3, menu4));

        //菜单树
        TreeEntity menu11 = new TreeEntity(TreeType.Menu, "树结构编辑", 0, false, menu1);
        TreeEntity menu12 = new TreeEntity(TreeType.Menu, "节点 URL", 0, false, menu1);
        TreeEntity menu13 = new TreeEntity(TreeType.Menu, "节点关联标准", 0, false, menu1);
        set.addAll(Arrays.asList(menu11, menu12, menu13));

        //文件资源
        TreeEntity menu21 = new TreeEntity(TreeType.Menu, "查看文件", 0, false, menu2);
        TreeEntity menu22 = new TreeEntity(TreeType.Menu, "下载附件", 0, false, menu2);
        TreeEntity menu23 = new TreeEntity(TreeType.Menu, "查看列表", 0, false, menu2);
        set.addAll(Arrays.asList(menu21, menu22, menu23));

        //其他资源
        TreeEntity menu31 = new TreeEntity(TreeType.Menu, "显示图片", 0, false, menu3);
        TreeEntity menu32 = new TreeEntity(TreeType.Menu, "资源列表", 0, false, menu3);
        set.addAll(Arrays.asList(menu31, menu32));

        //PDF 的操作
        TreeEntity menu41 = new TreeEntity(TreeType.Menu, "查看", 0, false, menu4);
        TreeEntity menu42 = new TreeEntity(TreeType.Menu, "打印", 1, false, menu4);
        TreeEntity menu43 = new TreeEntity(TreeType.Menu, "下载", 2, false, menu4);
        set.addAll(Arrays.asList(menu41, menu42, menu43));

        treeRepository.saveAll(set);

    }

    private void createStandardTree() {

        //系统启动的时候,这几种类型的父节点已经创建完毕,在下面添加子节点即可
        TreeEntity standard = treeRepository.findRoot(TreeType.Standard).get();
        Set<TreeEntity> set = new HashSet<>();

        /**
         * 初始化 Standard
         */
        // standard 1
        TreeEntity standard1 = new TreeEntity(TreeType.Standard, "国内", 0, true, standard);
        set.addAll(Arrays.asList(standard1));
        TreeEntity standard11 = new TreeEntity(TreeType.Standard, "国家标准", 0, true, standard1);
        TreeEntity standard12 = new TreeEntity(TreeType.Standard, "行业标准", 1, true, standard1);
        TreeEntity standard13 = new TreeEntity(TreeType.Standard, "地方标准", 2, true, standard1);
        set.addAll(Arrays.asList(standard11, standard12, standard13));

        // standard 11
        TreeEntity standard111 = new TreeEntity(TreeType.Standard, "国家标准", 0, false, standard11);
        TreeEntity standard112 = new TreeEntity(TreeType.Standard, "军用标准", 1, false, standard11);
        TreeEntity standard113 = new TreeEntity(TreeType.Standard, "计量规程", 2, false, standard11);
        TreeEntity standard114 = new TreeEntity(TreeType.Standard, "计量规范", 3, false, standard11);
        set.addAll(Arrays.asList(standard111, standard112, standard113, standard114));

        // standard 12
        TreeEntity standard121 = new TreeEntity(TreeType.Standard, "安全生产", 0, false, standard12);
        TreeEntity standard122 = new TreeEntity(TreeType.Standard, "电子信息", 1, false, standard12);
        TreeEntity standard123 = new TreeEntity(TreeType.Standard, "医药健康", 2, false, standard12);
        set.addAll(Arrays.asList(standard121, standard122, standard123));

        // standard 13
        TreeEntity standard131 = new TreeEntity(TreeType.Standard, "北京DB11", 0, false, standard13);
        TreeEntity standard132 = new TreeEntity(TreeType.Standard, "天津DB12", 1, false, standard13);
        TreeEntity standard133 = new TreeEntity(TreeType.Standard, "河北DB13", 2, false, standard13);
        set.addAll(Arrays.asList(standard131, standard132, standard133));

        // standard 2
        TreeEntity standard2 = new TreeEntity(TreeType.Standard, "国外", 0, true, standard);
        set.addAll(Arrays.asList(standard2));
        TreeEntity standard21 = new TreeEntity(TreeType.Standard, "iso标准", 0, false, standard2);
        TreeEntity standard22 = new TreeEntity(TreeType.Standard, "iec标准", 1, false, standard2);
        TreeEntity standard23 = new TreeEntity(TreeType.Standard, "itu标准", 2, false, standard2);
        set.addAll(Arrays.asList(standard21, standard22, standard23));

        treeRepository.saveAll(set);
    }

    private void createMenuTree() {

        //系统启动的时候,这几种类型的父节点已经创建完毕,在下面添加子节点即可
        TreeEntity menu = treeRepository.findRoot(TreeType.Menu).get(); // menu
        Set<TreeEntity> set = new HashSet<>();

        /**
         * url 只适用于 ace admin 1.4 , ajax 方式
         * 注意 url 应该和 index.ftl , NavigateController 中 RequestMapping 对应
         * #page/admin/ztree-type?treeType=Menu
         * 只填写 #page/ 后面部分
         */

        /**
         * 初始化 "菜单管理",为系统默认菜单,不能改动
         */
        //一级菜单
        TreeEntity menu1 = new TreeEntity(TreeType.Menu, "系统管理", 0, true, menu);
        menu1.setCss("menu-icon fa fa-cogs red bigger-130");
        menu1.setUrl("#");
        set.addAll(Arrays.asList(menu1));
        /**
         * 系统默认菜单,不能改动
         */
        TreeEntity menu11 = new TreeEntity(TreeType.Menu, "菜单管理", 0, true, menu1);
        menu11.setCss("menu-icon fa fa-sitemap");
        menu11.setUrl("#");
        TreeEntity menu12 = new TreeEntity(TreeType.Menu, "用户管理", 1, true, menu1);
        menu12.setCss("menu-icon fa fa-user-plus");
        menu12.setUrl("#");
        TreeEntity menu13 = new TreeEntity(TreeType.Menu, "角色管理", 2, true, menu1);
        menu13.setCss("menu-icon fa fa-object-group");
        menu13.setUrl("#");
        TreeEntity menu14 = new TreeEntity(TreeType.Menu, "系统设置", 3, true, menu1);
        menu14.setCss("menu-icon fa fa-gear");
        menu14.setUrl("#");
        set.addAll(Arrays.asList(menu11, menu12, menu13, menu14));

        // 菜单管理 (系统默认菜单,不能改动)
        TreeEntity menu111 = new TreeEntity(TreeType.Menu, "菜单树", 0, false, menu11);
        menu111.setUrl("admin/ztree-type?treeType=Menu");
        menu111.setCss("menu-icon fa fa-caret-right");
        TreeEntity menu112 = new TreeEntity(TreeType.Menu, "部门树", 1, false, menu11);
        menu112.setUrl("admin/ztree-type?treeType=DepartMent");
        menu112.setCss("menu-icon fa fa-caret-right");
        TreeEntity menu113 = new TreeEntity(TreeType.Menu, "标准结构树", 2, false, menu11);
        menu113.setUrl("admin/ztree-type?treeType=Standard");
        menu113.setCss("menu-icon fa fa-caret-right");
        set.addAll(Arrays.asList(menu111, menu112, menu113));

        // 用户管理   (系统默认菜单,不能改动)
        TreeEntity menu131 = new TreeEntity(TreeType.Menu, "用户", 0, false, menu12);
        menu131.setUrl("admin/jqgrid-user");
        menu131.setCss("menu-icon fa fa-caret-right");
        TreeEntity menu132 = new TreeEntity(TreeType.Menu, "用户组", 1, false, menu12);
        menu132.setUrl("admin/jqgrid-group");
        menu132.setCss("menu-icon fa fa-caret-right");
        set.addAll(Arrays.asList(menu131, menu132));

        //角色管理   (系统默认菜单,不能改动)
        TreeEntity menu141 = new TreeEntity(TreeType.Menu, "菜单角色", 0, false, menu13);
        menu141.setUrl("admin/jqgrid-roles?treeType=Menu");
        menu141.setCss("menu-icon fa fa-caret-right");
        TreeEntity menu142 = new TreeEntity(TreeType.Menu, "标准资源角色", 1, false, menu13);
        menu142.setUrl("admin/jqgrid-roles?treeType=Standard");
        menu142.setCss("menu-icon fa fa-caret-right");
        set.addAll(Arrays.asList(menu141, menu142));

        //系统设置  (菜单示例,可根据需要修改)
        TreeEntity menu151 = new TreeEntity(TreeType.Menu, "参数配置", 0, false, menu14);
        menu151.setCss("menu-icon fa fa-caret-right");
        menu151.setUrl("");
        TreeEntity menu152 = new TreeEntity(TreeType.Menu, "定时任务", 1, false, menu14);
        menu152.setCss("menu-icon fa fa-caret-right");
        menu152.setUrl("");
        TreeEntity menu153 = new TreeEntity(TreeType.Menu, "系统日志", 2, false, menu14);
        menu153.setCss("menu-icon fa fa-caret-right");
        menu153.setUrl("");
        set.addAll(Arrays.asList(menu151, menu152, menu153));

        /**
         * 初始化 "业务系统管理"菜单,根据具体的应用修改。
         */
        //一级菜单
        TreeEntity menu2 = new TreeEntity(TreeType.Menu, "业务系统管理", 0, true, menu);
        menu2.setCss("menu-icon fa fa-desktop red bigger-130");
        menu2.setUrl("");
        set.addAll(Arrays.asList(menu2));

        //用户菜单 (菜单示例,可根据需要修改)
        TreeEntity menu21 = new TreeEntity(TreeType.Menu, "站点维护", 0, false, menu2);
        menu21.setCss("menu-icon fa fa-circle-o");
        menu21.setUrl("");
        TreeEntity menu22 = new TreeEntity(TreeType.Menu, "高级检索", 1, false, menu2);
        menu22.setCss("menu-icon fa fa-circle-o");
        menu22.setUrl("");
        TreeEntity menu23 = new TreeEntity(TreeType.Menu, "用户管理", 2, false, menu2);
        menu23.setCss("menu-icon fa fa-circle-o");
        menu23.setUrl("");
        TreeEntity menu24 = new TreeEntity(TreeType.Menu, "缴费管理", 3, false, menu2);
        menu24.setCss("menu-icon fa fa-circle-o");
        menu24.setUrl("");
        TreeEntity menu25 = new TreeEntity(TreeType.Menu, "模版设置", 4, false, menu2);
        menu25.setCss("menu-icon fa fa-circle-o");
        menu25.setUrl("");
        TreeEntity menu26 = new TreeEntity(TreeType.Menu, "消息管理", 5, false, menu2);
        menu26.setCss("menu-icon fa fa-circle-o");
        menu26.setUrl("");
        TreeEntity menu27 = new TreeEntity(TreeType.Menu, "个人设置", 6, false, menu2);
        menu27.setCss("menu-icon fa fa-circle-o");
        menu27.setUrl("");
        TreeEntity menu28 = new TreeEntity(TreeType.Menu, "其他菜单", 7, true, menu2);
        menu28.setCss("menu-icon fa fa-circle-o");
        menu28.setUrl("");
        set.addAll(Arrays.asList(menu21, menu22, menu23, menu24, menu25, menu26, menu27, menu28));

        // 其他菜单
        TreeEntity menu281 = new TreeEntity(TreeType.Menu, "菜单1", 0, false, menu28);
        menu281.setCss("menu-icon fa fa-caret-right");
        menu281.setUrl("");
        TreeEntity menu282 = new TreeEntity(TreeType.Menu, "菜单2", 1, false, menu28);
        menu282.setCss("menu-icon fa fa-caret-right");
        menu282.setUrl("");
        set.addAll(Arrays.asList(menu281, menu282));

        treeRepository.saveAll(set);
    }

    /**
     * 初始化一个超级用户 sysadmin ,作为系统保留用户,可以对系统做任何操作
     * -
     * 信息应该做修改
     * -
     * 如果没有更改,登录后提示,或强制修改
     */
    private void initUser() {

        /**
         * 用户已经初始化
         */
        if (userRepository.findByLoginName("admin").isPresent()) {
            log.info("user has initialized , continue");
            return;
        }

        log.info("initialize admin user ...");

        UserEntity user = new UserEntity();
        user.setLoginName("admin");
        user.setUserName("系统管理员");
        user.setPassword(BCryptPassWordUtils.encode("sysadmin"));
        user.setEmail("admin@mail.com");
        user.setValid(true);
        user.setEnabled(true);
        // user.setRoles(Sets.newHashSet(new RoleEntity("")));

        /**
         * 设置角色
         */
        Optional<RoleEntity> adminRole = roleRepository.findByName("系统管理员角色");
        if (!adminRole.isPresent()) {
            initRole();
            adminRole = roleRepository.findByName("系统管理员角色");  // 再次查询
        }

        if (adminRole.isPresent()) {
            user.addRole(adminRole.get());
        }

        /**
         * 设置组
         */
        Optional<GroupEntity> adminGroup = groupRepository.findByName("系统管理员组");
        if (!adminGroup.isPresent()) {
            initGroup();
            adminGroup = groupRepository.findByName("系统管理员组");// 再次查询
        }

        if (adminGroup.isPresent()) {
            user.addGroup(adminGroup.get());
        }

        userRepository.save(user);

    }

    /**
     * 初始化用户组 ,作为系统保留组
     * -
     */
    private void initGroup() {

        if (groupRepository.findByName("系统管理员组").isPresent() &&
                groupRepository.findByName("用户组").isPresent()) {

            log.info("group has initialized , continue");
            return;
        }

        log.info("initialize group ...");

        GroupEntity admins = new GroupEntity();
        admins.setName("系统管理员组");
        admins.setValid(true);
        admins.setEnabled(true);

        GroupEntity users = new GroupEntity();
        users.setName("用户组");
        users.setValid(true);
        users.setEnabled(true);

        groupRepository.save(admins);
        groupRepository.save(users);

    }

    /**
     * 初始化一个超级用户 sysadmin ,作为系统保留用户,可以对系统做任何操作
     * -
     */
    private void initRole() {

        if (roleRepository.findByName("系统管理员角色").isPresent() &&
                roleRepository.findByName("用户角色").isPresent()) {

            log.info("role has initialized , continue");
            return;
        }

        log.info("initialize role ...");

        RoleEntity admins = new RoleEntity();
        admins.setName("系统管理员角色");
        admins.setValid(true);
        admins.setEnabled(true);

        RoleEntity users = new RoleEntity();
        users.setName("用户角色");
        users.setValid(true);
        users.setEnabled(true);

        roleRepository.save(admins);
        roleRepository.save(users);
    }

}


text:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
   - Configuration Database Entry for ParameterTuning
   -
   - Author: Fanny Corset
   -
   - History:
   -   2003-01-28  FC  Created
  -->
<ParameterTuning xmlns="urn:schemas-cosylab-com:ParameterTuning:1.0" xmlns:baci="urn:schemas-cosylab-com:BACI:1.0" xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	    <logLevel description="level of messaging" default_value="0" units="A"/>
	    <NPAE description="NPAE coefficient for tpoint" default_value="0" units="A"/>
	    <ACES description="ACES coefficient for tpoint" default_value="0" units="A"/>
	    <ACEC description="ACEC coefficient for tpoint" default_value="0" units="A"/>
	    <ECES description="ECES coefficient for tpoint" default_value="0" units="A"/>
	    <ECEC description="ECEC coefficient for tpoint" default_value="0" units="A"/>
	    <nbBaselineBin description="number of Baseline bins for Phase Calibration" default_value="3" units="A"/>
	    <bSubstractThermalPhaseNoise description="bSubstractThermalPhaseNoise" statesDescription="YES,NO" default_value="0" units="w/o"/>
	    <dataMode description="dataMode" statesDescription="DATACAPTURER,FITS,VOTABLE" default_value="0" units="w/o"/>
	    <metaDataFileName description="metaDataFileName" default_value="" units="A"/>
	    <corrDataFileName description="corrDataFileName" default_value="" units="A"/>
	    <polynomDegree description="degree of polynomial for Phase Calibration Curve" default_value="2" units="A"/>
	    <timeRange description="time range" default_value="0" units="A"/>
</ParameterTuning>


text:
create table ACT_HI_PROCINST (
    ID_ varchar(64) not null,
    PROC_INST_ID_ varchar(64) not null,
    BUSINESS_KEY_ varchar(255),
    PROC_DEF_ID_ varchar(64) not null,
    START_TIME_ timestamp not null,
    END_TIME_ timestamp,
    DURATION_ bigint,
    START_USER_ID_ varchar(255),
    START_ACT_ID_ varchar(255),
    END_ACT_ID_ varchar(255),
    SUPER_PROCESS_INSTANCE_ID_ varchar(64),
	  UNI_BUSINESS_KEY varchar (255)  not null  generated always as (case when "BUSINESS_KEY_" is null then "ID_" else "BUSINESS_KEY_" end),
	  UNI_PROC_DEF_ID varchar (64)  not null  generated always as (case when "PROC_DEF_ID_" is null then "ID_" else "PROC_DEF_ID_" end),
    DELETE_REASON_ varchar(4000),
    primary key (ID_)
);

alter table ACT_HI_PROCINST add constraint PROC_INST_ID_ unique(PROC_INST_ID_);

create table ACT_HI_ACTINST (
    ID_ varchar(64) not null,
    PROC_DEF_ID_ varchar(64) not null,
    PROC_INST_ID_ varchar(64) not null,
    EXECUTION_ID_ varchar(64) not null,
    ACT_ID_ varchar(255) not null,
    TASK_ID_ varchar(64),
    CALL_PROC_INST_ID_ varchar(64),
    ACT_NAME_ varchar(255),
    ACT_TYPE_ varchar(255) not null,
    OWNER_ varchar(64),
    ASSIGNEE_ varchar(64),
    START_TIME_ timestamp not null,
    END_TIME_ timestamp,
    DURATION_ bigint,
    primary key (ID_)
);

create table ACT_HI_TASKINST (
    ID_ varchar(64) not null,
    PROC_DEF_ID_ varchar(64),
    TASK_DEF_KEY_ varchar(255),
    PROC_INST_ID_ varchar(64),
    EXECUTION_ID_ varchar(64),
    NAME_ varchar(255),
    PARENT_TASK_ID_ varchar(64),
    DESCRIPTION_ varchar(4000),
    OWNER_ varchar(255),
    ASSIGNEE_ varchar(255),
    START_TIME_ timestamp not null,
    END_TIME_ timestamp,
    DURATION_ bigint,
    DELETE_REASON_ varchar(4000),
    PRIORITY_ integer,
    DUE_DATE_ timestamp,
    primary key (ID_)
);

create table ACT_HI_VARINST (
    ID_ varchar(64) not null,
    PROC_INST_ID_ varchar(64),
    EXECUTION_ID_ varchar(64),
    TASK_ID_ varchar(64),
    NAME_ varchar(255) not null,
    VAR_TYPE_ varchar(100),
    REV_ integer,
    BYTEARRAY_ID_ varchar(64),
    DOUBLE_ double precision,
    LONG_ bigint,
    TEXT_ varchar(4000),
    TEXT2_ varchar(4000),
    primary key (ID_)
);

create table ACT_HI_DETAIL (
    ID_ varchar(64) not null,
    TYPE_ varchar(255) not null,
    PROC_INST_ID_ varchar(64),
    EXECUTION_ID_ varchar(64),
    TASK_ID_ varchar(64),
    ACT_INST_ID_ varchar(64),
    NAME_ varchar(255) not null,
    VAR_TYPE_ varchar(255),
    REV_ integer,
    TIME_ timestamp not null,
    BYTEARRAY_ID_ varchar(64),
    DOUBLE_ double precision,
    LONG_ bigint,
    TEXT_ varchar(4000),
    TEXT2_ varchar(4000),
    primary key (ID_)
);

create table ACT_HI_COMMENT (
    ID_ varchar(64) not null,
    TYPE_ varchar(255),
    TIME_ timestamp not null,
    USER_ID_ varchar(255),
    TASK_ID_ varchar(64),
    PROC_INST_ID_ varchar(64),
    ACTION_ varchar(255),
    MESSAGE_ varchar(4000),
    FULL_MSG_ BLOB,
    primary key (ID_)
);

create table ACT_HI_ATTACHMENT (
    ID_ varchar(64) not null,
    REV_ integer,
    USER_ID_ varchar(255),
    NAME_ varchar(255),
    DESCRIPTION_ varchar(4000),
    TYPE_ varchar(255),
    TASK_ID_ varchar(64),
    PROC_INST_ID_ varchar(64),
    URL_ varchar(4000),
    CONTENT_ID_ varchar(64),
    primary key (ID_)
);

create unique index ACT_UNIQ_HI_BUS_KEY on ACT_HI_PROCINST(UNI_PROC_DEF_ID, UNI_BUSINESS_KEY);
create index ACT_IDX_HI_PRO_INST_END on ACT_HI_PROCINST(END_TIME_);
create index ACT_IDX_HI_PRO_I_BUSKEY on ACT_HI_PROCINST(BUSINESS_KEY_);
create index ACT_IDX_HI_ACT_INST_START on ACT_HI_ACTINST(START_TIME_);
create index ACT_IDX_HI_ACT_INST_END on ACT_HI_ACTINST(END_TIME_);
create index ACT_IDX_HI_ACT_INST_COMP on ACT_HI_ACTINST(EXECUTION_ID_, ACT_ID_, END_TIME_, ID_);
create index ACT_IDX_HI_DETAIL_PROC_INST on ACT_HI_DETAIL(PROC_INST_ID_);
create index ACT_IDX_HI_DETAIL_ACT_INST on ACT_HI_DETAIL(ACT_INST_ID_);
create index ACT_IDX_HI_DETAIL_TIME on ACT_HI_DETAIL(TIME_);
create index ACT_IDX_HI_DETAIL_NAME on ACT_HI_DETAIL(NAME_);
create index ACT_IDX_HI_DETAIL_TASK_ID on ACT_HI_DETAIL(TASK_ID_);
create index ACT_IDX_HI_PROCVAR_PROC_INST on ACT_HI_VARINST(PROC_INST_ID_);
create index ACT_IDX_HI_PROCVAR_NAME_TYPE on ACT_HI_VARINST(NAME_, VAR_TYPE_);
create index ACT_IDX_HI_ACT_INST_PROCINST on ACT_HI_ACTINST(PROC_INST_ID_, ACT_ID_);


text:
package io.cloudslang.content.jclouds.execute;

import io.cloudslang.content.jclouds.entities.inputs.ServerIdentificationInputs;
import io.cloudslang.content.jclouds.entities.outputs.Outputs;
import io.cloudslang.content.jclouds.factory.ComputeFactory;
import io.cloudslang.content.jclouds.services.ComputeService;
import io.cloudslang.content.jclouds.utilities.InputsValidator;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by persdana on 6/23/2015.
 */
public class ResumeServerExecutor {
    private static final String SERVER_SUSPENDED = "server resumed";

    public Map<String, String> execute(ServerIdentificationInputs serverIdentificationInputs) throws Exception {
        Map<String, String> result = new HashMap<>();
        InputsValidator.validateServerIdentificationInputs(serverIdentificationInputs);

        ComputeService cs = ComputeFactory.getComputeService(serverIdentificationInputs);
        cs.resume(serverIdentificationInputs.getRegion(), serverIdentificationInputs.getServerId());

        result.put(Outputs.RETURN_CODE, Outputs.SUCCESS_RETURN_CODE);
        result.put(Outputs.RETURN_RESULT, SERVER_SUSPENDED);

        return  result;
    }
}


text:
# lua-compat-5.3

Lua-5.3-style APIs for Lua 5.2 and 5.1.

## What is it

This is a small module that aims to make it easier to write code
in a Lua-5.3-style that is compatible with Lua 5.1, Lua 5.2, and Lua
5.3. This does *not* make Lua 5.2 (or even Lua 5.1) entirely
compatible with Lua 5.3, but it brings the API closer to that of Lua
5.3.

It includes:

* _For writing Lua_: The Lua module `compat53`, which can be require'd
  from Lua scripts and run in Lua 5.1, 5.2, and 5.3, including a
  backport of the `utf8` module, the 5.3 `table` module, and the
  string packing functions straight from the Lua 5.3 sources.
* _For writing C_: A C header and file which can be linked to your
  Lua module written in C, providing some functions from the C API
  of Lua 5.3 that do not exist in Lua 5.2 or 5.1, making it easier to
  write C code that compiles with all three versions of liblua.

## How to use it

### Lua module

```lua
require("compat53")
```

`compat53` makes changes to your global environment and does not return
a meaningful return value, so the usual idiom of storing the return of
`require` in a local variable makes no sense.

When run under Lua 5.3, this module does nothing.

When run under Lua 5.2 or 5.1, it replaces some of your standard
functions and adds new ones to bring your environment closer to that
of Lua 5.3. It also tries to load the backported `utf8`, `table`, and
string packing modules automatically. If unsuccessful, pure Lua
versions of the new `table` functions are used as a fallback, and
[Roberto's struct library][1] is tried for string packing.

### C code

There are two ways of adding the C API compatibility functions/macros to
your project:
* If `COMPAT53_PREFIX` is *not* `#define`d, `compat-5.3.h` `#include`s
  `compat-5.3.c`, and all functions are made `static`. You don't have to
  compile/link/add `compat-5.3.c` yourself. This is useful for one-file
  projects.
* If `COMPAT53_PREFIX` is `#define`d, all exported functions are renamed
  behind the scenes using this prefix to avoid linker conflicts with other
  code using this package. This doesn't change the way you call the
  compatibility functions in your code. You have to compile and link
  `compat-5.3.c` to your project yourself. You can change the way the
  functions are exported using the `COMPAT53_API` macro (e.g. if you need
  some `__declspec` magic).

## What's implemented

### Lua

* the `utf8` module backported from the Lua 5.3 sources
* `string.pack`, `string.packsize`, and `string.unpack` from the Lua
  5.3 sources or from the `struct` module. (`struct` is not 100%
  compatible to Lua 5.3's string packing!)
* `math.maxinteger` and `math.mininteger`, `math.tointeger`, `math.type`,
  and `math.ult`
* `ipairs` respects `__index` metamethod
* `table.move`
* `table` library respects metamethods

For Lua 5.1 additionally:
* `load` and `loadfile` accept `mode` and `env` parameters
* `table.pack` and `table.unpack`
* string patterns may contain embedded zeros
* `string.rep` accepts `sep` argument
* `string.format` calls `tostring` on arguments for `%s`
* `math.log` accepts base argument
* `xpcall` takes additional arguments
* `pcall` and `xpcall` can execute functions that yield
* `pairs` respects `__pairs` metamethod
* `rawlen` (but `#` still doesn't respect `__len` for tables)
* `package.searchers` as alias for `package.loaders`
* `package.searchpath`
* `coroutine` functions dealing with the main coroutine
* `coroutine.create` accepts functions written in C
* return code of `os.execute`
* `io.write` and `file:write` return file handle
* `io.lines` and `file:lines` accept format arguments (like `io.read`)
* `debug.setmetatable` returns object
* `debug.getuservalue` and `debug.setuservalue`

### C

* `lua_KContext`
* `lua_KFunction`
* `lua_dump` (extra `strip` parameter, ignored)
* `lua_getfield` (return value)
* `lua_geti` and `lua_seti`
* `lua_getglobal` (return value)
* `lua_getmetafield` (return value)
* `lua_gettable` (return value)
* `lua_getuservalue` and `lua_setuservalue` (limited compatibility)
* `lua_isinteger`
* `lua_numbertointeger`
* `lua_callk` and `lua_pcallk` (limited compatibility)
* `lua_rawget` and `lua_rawgeti` (return values)
* `lua_rawgetp` and `lua_rawsetp`
* `luaL_requiref` (now checks `package.loaded` first)
* `lua_rotate`
* `lua_stringtonumber`

For Lua 5.1 additionally:
* `LUA_OK`
* `LUA_OP*` macros for `lua_arith` and `lua_compare`
* `lua_Unsigned`
* `luaL_Stream`
* `LUA_FILEHANDLE`
* `lua_absindex`
* `lua_arith`
* `lua_compare`
* `lua_len`, `lua_rawlen`, and `luaL_len`
* `lua_copy`
* `lua_pushglobaltable`
* `luaL_testudata`
* `luaL_setfuncs`, `luaL_newlibtable`, and `luaL_newlib`
* `luaL_setmetatable`
* `luaL_getsubtable`
* `luaL_traceback`
* `luaL_fileresult`
* `luaL_checkversion` (with empty body, only to avoid compile errors)
* `luaL_tolstring`
* `luaL_buffinitsize`, `luaL_prepbuffsize`, and `luaL_pushresultsize`
* `lua_pushunsigned`, `lua_tounsignedx`, `lua_tounsigned`,
  `luaL_checkunsigned`, `luaL_optunsigned`, if
  `LUA_COMPAT_APIINTCASTS` is defined.

## What's not implemented

* bit operators
* integer division operator
* utf8 escape sequences
* 64 bit integers
* `coroutine.isyieldable`
* Lua 5.1: `_ENV`, `goto`, labels, ephemeron tables, etc. See
  [`lua-compat-5.2`][2] for a detailed list.
* the following C API functions/macros:
  * `lua_isyieldable`
  * `lua_getextraspace`
  * `lua_arith` (new operators missing)
  * `lua_push(v)fstring` (new formats missing)
  * `lua_upvalueid` (5.1)
  * `lua_upvaluejoin` (5.1)
  * `lua_version` (5.1)
  * `lua_yieldk` (5.1)
  * `luaL_execresult` (5.1)
  * `luaL_loadbufferx` (5.1)
  * `luaL_loadfilex` (5.1)

### Yieldable C functions

The emulation of `lua_(p)callk` for previous Lua versions is not 100%
perfect, because the continuation functions in Lua 5.2 have different
signatures than the ones in Lua 5.3 (and Lua 5.1 doesn't have
continuation functions at all). But with the help of a small macro the
same code can be used for all three Lua versions (the 5.1 version
won't support yielding though).

Original Lua 5.3 code (example adapted from the Lua 5.3 manual):

```C
static int k (lua_State *L, int status, lua_KContext ctx) {
  ...  /* code 2 */
}

int original_function (lua_State *L) {
  ...     /* code 1 */
  return k(L, lua_pcallk(L, n, m, h, ctx2, k), ctx1);
}
```

Portable version:

```C
LUA_KFUNCTION( k ) {
  ...  /* code 2; parameters L, status, and ctx available here */
}

int original_function (lua_State *L) {
  ...     /* code 1 */
  return k(L, lua_pcallk(L, n, m, h, ctx2, k), ctx1);
}
```

## See also

* For Lua-5.2-style APIs under Lua 5.1, see [lua-compat-5.2][2],
  which also is the basis for most of the code in this project.
* For Lua-5.1-style APIs under Lua 5.0, see [Compat-5.1][3]

## Credits

This package contains code written by:

* [The Lua Team](http://www.lua.org)
* Philipp Janda ([@siffiejoe](http://github.com/siffiejoe))
* Tomás Guisasola Gorham ([@tomasguisasola](http://github.com/tomasguisasola))
* Hisham Muhammad ([@hishamhm](http://github.com/hishamhm))
* Renato Maia ([@renatomaia](http://github.com/renatomaia))

  [1]: http://www.inf.puc-rio.br/~roberto/struct/
  [2]: http://github.com/keplerproject/lua-compat-5.2/
  [3]: http://keplerproject.org/compat/


text:
Verified Construction of Static Single Assignment Form
======================================================

Abstract
--------
Modern compilers use an intermediate representation in static single assignment (SSA) form, which simplifies many optimizations.
However, the high implementation complexity of efficient SSA construction algorithms poses a challenge to verified compilers.
In this paper, we consider a variant of the recent SSA construction algorithm by Braun et al. that combines simplicity and efficiency, and is therefore a promising candidate to tackle this challenge.
We prove the correctness of the algorithm using the theorem prover Isabelle/HOL.
Furthermore, we prove that the algorithm constructs pruned SSA form and, in case of a reducible control flow graph, minimal SSA form.
To the best of our knowledge, these are the first formal proofs regarding the quality of an SSA construction algorithm.
Finally, we replace the unverified SSA construction of the CompCertSSA project with code extracted by Isabelle's code generator to demonstrate the applicability to real world programs.

Requirements
------------

For running the formalization you need

- A running version of [Isabelle2016](https://isabelle.in.tum.de/) with `isabelle` in your `$PATH`.
- the [archive of formal proofs (AFP)](http://afp.sf.net/) installed as an Isabelle component.
  See [http://afp.sf.net/using.shtml](http://afp.sf.net/using.shtml) for details on how to do that.

For building the CompCertSSA compiler using our SSA construction algorithm

- see [http://compcert.inria.fr/download.html](http://compcert.inria.fr/download.html) for additional requirements.

Build instructions
------------------

You can use GNU make to build several targets:

- `compcertSSA`: downloads CompCertSSA stable version 2.0 from the [CompCertSSA homepage](http://compcertssa.gforge.inria.fr/),
  and applies a patch weaving in some glue code to use the SSA construction from Braun et al. (see `./compcertSSA-Braun.patch` for details)

- `FormalSSA`: runs the Isabelle formalization and generates the verified SSA construction algorithm.
  (File `./compcertSSA/midend/SSA/BraunSSA.ml`)

- `ccomp`: builds the CompCertSSA compiler for the target platform `ia32-linux`. You can change that by setting the environment variable `COMPCERTSSA_TARGET` to the target platform of your choice (see `Makefile`).

- `ifplot`: performs measurements on the family of test programs referenced in section 7 of our paper and plots the result via `gnuplot`. You can change the testing parameters by editing the `Makefile`.


text:
package main
import (
"fmt"
"log"
"net/http"
"strings"
)

func title(url string) error{
    resp,err:=http.Get(url)
    if err!=nil{
        log.Fatalf("%v",err)
    }
    defer fmt.Println("Begin?")
    defer func(){resp.Body.Close();fmt.Println("releasing...")}()
    defer fmt.Println("After?")
    ct:=resp.Header.Get("Content-Type")
    if ct!="text/html" &&!strings.HasPrefix(ct,"text/html;"){
        return fmt.Errorf("%s has type %s",url,ct)
    }else{
        fmt.Println("Finished")
        return nil
    }
// Finished
// After?
// Begin?
// Ok

}

func main() {
    if err:=title("http://www.baidu.com");err==nil{
        fmt.Println("Ok")
    }
}


text:
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
J. F. Klotzsch & C. A. F. Garcke, Bot. Ergebn Reise Waldemar 79, t. 79. 1862

#### Original name
null

### Remarks
null


text:
package com.wealdtech.android.fabric.action;

import android.view.View;
import android.widget.Toast;
import com.wealdtech.android.fabric.Rule;

/**
 * An action to show an Android alert
 */
public class AlertViewAction extends ViewAction
{
  private String text;

  public AlertViewAction(final View view, final String text)
  {
    super(view);
    this.text = text;
  }

  public static AlertViewAction alert(final View view, final String alert)
  {
    return new AlertViewAction(view, alert);
  }

  @Override
  public void act(final Rule rule)
  {
    Toast.makeText(view.getContext(), text, Toast.LENGTH_SHORT).show();
  }
}