Search in sources :

Example 11 with Department

use of com.qlangtech.tis.manage.biz.dal.pojo.Department in project tis by qlangtech.

the class DepartmentAction method doAddDepartment.

/**
 * 添加部门
 *
 * @param context
 */
public void doAddDepartment(Context context) {
    Department department = new Department();
    this.processDepartment(context, department, (dpt) -> {
        dpt.setDptId(this.getDepartmentDAO().insertSelective(dpt));
        DataxAction.cleanDepsCache();
        this.addActionMessage(context, "成功添加部门:" + dpt.getName());
    });
}
Also used : Department(com.qlangtech.tis.manage.biz.dal.pojo.Department)

Example 12 with Department

use of com.qlangtech.tis.manage.biz.dal.pojo.Department in project tis by qlangtech.

the class ResSynManager method getSynchronizedOnlineSnapshot.

/**
 * 执行将日常配置推送到线上的操作
 *
 * @param context
 * @param module
 * @return
 * @throws UnsupportedEncodingException
 * @throws SchemaFileInvalidException
 */
public Boolean getSynchronizedOnlineSnapshot(final Context context, final BasicModule module) throws Exception {
    final SnapshotDomain onlineResDomain = this.getOnlineResDomain();
    List<ResSyn> reslist = this.getCompareResult();
    List<ResSyn> pushResource = new ArrayList<ResSyn>();
    for (ResSyn res : reslist) {
        if (!res.isSame()) {
            // 若日常和线上相等,则该资源就不推送了
            pushResource.add(res);
            continue;
        }
    // pushResource.add(res);
    }
    if (pushResource.size() < 1) {
        module.addErrorMessage(context, "all config resource has been updated already");
        return false;
    }
    // return snapshot;
    UploadResource push = null;
    List<UploadResource> uploadResources = new ArrayList<UploadResource>();
    for (ResSyn res : pushResource) {
        if (res.getDaily() == null) {
            continue;
        }
        push = new UploadResource();
        push.setResourceType(res.getGetter().getFileName());
        push.setContent(res.getDaily().getContent());
        push.setMd5Code(res.getDaily().getMd5Code());
        uploadResources.add(push);
    }
    ConfigPush configPush = new ConfigPush();
    configPush.setCollection(this.collectionName);
    configPush.setSnapshotId(this.getDailyRes().getSnapshot().getSnId());
    if (this.getOnlineResDomain() != null) {
        configPush.setRemoteSnapshotId(this.getOnlineResDomain().getSnapshot().getSnId());
    }
    configPush.setUploadResources(uploadResources);
    if (onlineResDomain == null) {
        // 说明线上还没有第一次发布
        Department dpt = new Department();
        // dpt.setDptId();
        // dpt.setFullName();
        Application app = this.runContext.getApplicationDAO().loadFromWriteDB(this.getDailyRes().getAppId());
        dpt.setFullName(app.getDptName());
        configPush.setDepartment(dpt);
        configPush.setReception(app.getRecept());
    } else {
        configPush.setReception(this.getDailyRes().getSnapshot().getCreateUserName());
    }
    Writer writer = null;
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        writer = new OutputStreamWriter(out, BasicModule.getEncode());
        HttpConfigFileReader.xstream.toXML(configPush, writer);
        writer.flush();
        // System.out.println(new String(out.toByteArray(),
        // BasicModule.getEncode()));
        final URL url = new URL(Config.getTerminatorRepositoryOnline() + "/config/config.ajax?action=app_syn_action&event_submit_do_init_app_from_daily=y");
        return HttpUtils.post(url, out.toByteArray(), new PostFormStreamProcess<Boolean>() {

            @Override
            public ContentType getContentType() {
                return ContentType.Multipart_byteranges;
            }

            @Override
            public Boolean p(int status, InputStream stream, Map<String, List<String>> headerFields) {
                try {
                    String result = IOUtils.toString(stream, BasicModule.getEncode());
                    JSONTokener tokener = new JSONTokener(result);
                    JSONObject json = new JSONObject(tokener);
                    JSONArray errs = json.getJSONArray("errormsg");
                    if (errs.length() > 0) {
                        for (int i = 0; i < errs.length(); i++) {
                            module.addErrorMessage(context, errs.getString(i));
                        }
                        return false;
                    }
                    JSONArray msg = json.getJSONArray("msg");
                    return true;
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        });
    } finally {
        IOUtils.closeQuietly(writer);
    }
}
Also used : URL(java.net.URL) Department(com.qlangtech.tis.manage.biz.dal.pojo.Department) UploadResource(com.qlangtech.tis.manage.biz.dal.pojo.UploadResource) JSONArray(org.json.JSONArray) MalformedURLException(java.net.MalformedURLException) JSONTokener(org.json.JSONTokener) JSONObject(org.json.JSONObject) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application)

Example 13 with Department

use of com.qlangtech.tis.manage.biz.dal.pojo.Department in project tis by qlangtech.

the class UserAction method doGetChildDpt.

/**
 * get child department
 *
 * @param context
 */
public void doGetChildDpt(Context context) {
    Integer dptid = this.getInt("pid");
    DepartmentCriteria query = new DepartmentCriteria();
    query.createCriteria().andParentIdEqualTo(dptid);
    List<Option> result = new ArrayList<Option>();
    for (Department dpt : this.getDepartmentDAO().selectByExample(query)) {
        result.add(new Option(dpt.getName(), String.valueOf(dpt.getDptId())));
    }
    context.put(AjaxValve.BIZ_RESULT, result);
}
Also used : Department(com.qlangtech.tis.manage.biz.dal.pojo.Department) Option(com.qlangtech.tis.manage.common.Option) DepartmentCriteria(com.qlangtech.tis.manage.biz.dal.pojo.DepartmentCriteria)

Example 14 with Department

use of com.qlangtech.tis.manage.biz.dal.pojo.Department in project tis by qlangtech.

the class AppDomain method execute.

public void execute(Context context) throws Exception {
    AppDomainInfo appDomain = getAppDomain();
    if (appDomain == null) {
        // 跳转到指定上下文的页面
        // .withTarget("changedomain");
        getRundataInstance().redirectTo("changedomain");
        return;
    }
    Department department = null;
    // final Department department = this.getDepartmentDAO().loadFromWriteDB(
    // appDomain.getDptid());
    // Application app = this.getApplicationDAO().loadFromWriteDB(
    // appDomain.getAppid());
    Application app = new Application();
    app.setProjectName(appDomain.getAppName());
    // 校验是否选择了当前应用?
    if ((appDomain instanceof Nullable) || !shallSelectApp(department, app)) {
        appDomain = CheckAppDomainExistValve.createNull();
        context.put(ChangeDomainAction.SELECT_APP_NAME, getNotSelectDomainCaption());
    } else {
        boolean shallnotShowEnvironment = (context.get("shallnotShowEnvironment") != null) && (Boolean) context.get("shallnotShowEnvironment");
        context.put(ChangeDomainAction.SELECT_APP_NAME, getAppDesc(appDomain, department, app, shallnotShowEnvironment));
    }
    context.put("dptid", appDomain.getDptid());
    context.put("appid", appDomain.getAppid());
    context.put("runid", appDomain.getRunEnvironment().getId());
}
Also used : AppDomainInfo(com.qlangtech.tis.manage.common.AppDomainInfo) Department(com.qlangtech.tis.manage.biz.dal.pojo.Department) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application) Nullable(com.qlangtech.tis.pubhook.common.Nullable)

Aggregations

Department (com.qlangtech.tis.manage.biz.dal.pojo.Department)14 DepartmentCriteria (com.qlangtech.tis.manage.biz.dal.pojo.DepartmentCriteria)5 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)2 Func (com.qlangtech.tis.manage.spring.aop.Func)2 Validator (com.qlangtech.tis.plugin.annotation.Validator)2 Date (java.util.Date)2 UploadResource (com.qlangtech.tis.manage.biz.dal.pojo.UploadResource)1 UsrDptRelation (com.qlangtech.tis.manage.biz.dal.pojo.UsrDptRelation)1 UsrDptRelationCriteria (com.qlangtech.tis.manage.biz.dal.pojo.UsrDptRelationCriteria)1 AppDomainInfo (com.qlangtech.tis.manage.common.AppDomainInfo)1 Option (com.qlangtech.tis.manage.common.Option)1 Nullable (com.qlangtech.tis.pubhook.common.Nullable)1 IControlMsgHandler (com.qlangtech.tis.runtime.module.misc.IControlMsgHandler)1 DelegateControl4JsonPostMsgHandler (com.qlangtech.tis.runtime.module.misc.impl.DelegateControl4JsonPostMsgHandler)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 JSONTokener (org.json.JSONTokener)1