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());
});
}
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);
}
}
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);
}
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());
}
Aggregations