public SelectCmd(String s, WithHash w) { super(); selectCmd = s; with = w; if (w != null) { cl_size = w.size(); sv = (Vector) w.get(ParseStr.S_SORT); if (sv != null) cl_size--; } else { cl_size = 0; sv = null; } txMode = SDMSTransaction.READONLY; }
private Vector collist(ResultSetMetaData mdset) throws SQLException { Vector desc = new Vector(); int j = 0; for (int i = 1; i <= mdset.getColumnCount(); i++) { String cn = mdset.getColumnName(i).toUpperCase(); if (cl_size > 0 && with.get(cn) != null) { Integer t = (Integer) with.get(cn); clist[j] = i; ctype[j] = t.intValue(); j++; } desc.addElement(cn); } cl_size = j; sort(); return desc; }
public void go(SystemEnvironment sysEnv) throws SDMSException { try { obj.resolve(sysEnv); } catch (final NotFoundException nfe) { } final Long seId = obj.seId; final Vector mappedPath = new Vector(obj.path); final String mappedName = (String) mappedPath.remove(mappedPath.size() - 1); final SDMSSchedule parent = SDMSScheduleTable.getSchedule(sysEnv, mappedPath); final Long parentId = parent.getId(sysEnv); if (SDMSScheduleTable.idx_parentId_name.containsKey( sysEnv, new SDMSKey(parentId, mappedName))) { if (replace) { final AlterSchedule as = new AlterSchedule(obj, with, Boolean.FALSE); as.setEnv(env); as.go(sysEnv); result = as.result; return; } throw new DuplicateKeyException( new SDMSMessage( sysEnv, "04207251651", "Object with name $1 already exists within $2", mappedName, SDMSScheduleTable.getObject(sysEnv, parentId).pathString(sysEnv))); } final Long ivalId; final String intervalName = (String) with.get(ParseStr.S_INTERVAL); if (intervalName == null) ivalId = null; else { final SDMSInterval ival = SDMSIntervalTable.idx_name_getUnique(sysEnv, IntervalUtil.mapIdName(intervalName, seId)); ivalId = ival.getId(sysEnv); } final Long uId = env.uid(); final SDMSUser u = SDMSUserTable.getObject(sysEnv, uId); final Long gId; if (!with.containsKey(ParseStr.S_GROUP)) { gId = u.getDefaultGId(sysEnv); } else { final String gName = (String) with.get(ParseStr.S_GROUP); gId = SDMSGroupTable.idx_name_deleteVersion_getUnique(sysEnv, new SDMSKey(gName, new Long(0))) .getId(sysEnv); if (!SDMSMemberTable.idx_gId_uId.containsKey(sysEnv, new SDMSKey(gId, uId)) && !SDMSMemberTable.idx_gId_uId.containsKey( sysEnv, new SDMSKey(SDMSObject.adminGId, uId))) { throw new CommonErrorException( new SDMSMessage( sysEnv, "03401151027", "User $1 does not belong to Group $2", u.getName(sysEnv), gName)); } } Long inheritPrivs; if (with.containsKey(ParseStr.S_INHERIT)) { inheritPrivs = (Long) with.get(ParseStr.S_INHERIT); if (inheritPrivs == null) inheritPrivs = new Long(0); } else inheritPrivs = null; long lpriv = (inheritPrivs == null ? parent.getPrivilegeMask() : inheritPrivs.longValue()); if ((parent.getPrivilegeMask() & lpriv) != lpriv) { throw new CommonErrorException(new SDMSMessage(sysEnv, "03202061327", "Incompatible grant")); } inheritPrivs = new Long(lpriv); if (!with.containsKey(ParseStr.S_ACTIVE)) active = Boolean.TRUE; else active = (Boolean) with.get(ParseStr.S_ACTIVE); String tz; String warning = ""; if (with.containsKey(ParseStr.S_TIME)) { tz = (String) with.get(ParseStr.S_TIME); TimeZone tmp = TimeZone.getTimeZone(tz); if (!tz.equals(tmp.getID())) { throw new CommonErrorException( new SDMSMessage(sysEnv, "03207031503", "Time Zone " + tz + " unknown")); } } else { TimeZone tmp = TimeZone.getDefault(); tz = tmp.getID(); } SDMSScheduleTable.table.create( sysEnv, mappedName, gId, ivalId, parentId, tz, seId, active, inheritPrivs); result.setFeedback(new SDMSMessage(sysEnv, "04207251652", "Schedule created")); }
public void go(SystemEnvironment sysEnv) throws SDMSException { final DateTime dt = new DateTime(new Date()); boolean secondsIgnore = false; boolean duplicateFilterIgnore = false; boolean ignoreUpperRange = false; String warning = null; final SDMSInterval ival = (SDMSInterval) obj.resolve(sysEnv); ivalId = obj.objId; if (with.containsKey(ParseStr.S_BASE)) { final WithHash baseIntervalWith = (WithHash) with.get(ParseStr.S_BASE); if (baseIntervalWith == null) { ival.setBaseInterval(sysEnv, null); ival.setBaseIntervalMultiplier(sysEnv, null); } else { final Integer baseInterval = (Integer) baseIntervalWith.get(ParseStr.S_INTERVAL); final Integer baseIntervalMultiplier = IntervalUtil.getMultiplier(sysEnv, baseIntervalWith); ival.setBaseInterval(sysEnv, baseInterval); ival.setBaseIntervalMultiplier(sysEnv, baseIntervalMultiplier); } } if (with.containsKey(ParseStr.S_DURATION)) { final WithHash durationWith = (WithHash) with.get(ParseStr.S_DURATION); if (durationWith == null) { ival.setDuration(sysEnv, null); ival.setDurationMultiplier(sysEnv, null); } else { final Integer duration = (Integer) durationWith.get(ParseStr.S_INTERVAL); final Integer durationMultiplier = IntervalUtil.getMultiplier(sysEnv, durationWith); ival.setDuration(sysEnv, duration); ival.setDurationMultiplier(sysEnv, durationMultiplier); } } if (with.containsKey(ParseStr.S_SYNCTIME)) { if (IntervalUtil.getDateTime(sysEnv, dt, with, ParseStr.S_SYNCTIME)) secondsIgnore = true; dt.fixToMinDate(); dt.suppressSeconds(); ival.setSyncTime(sysEnv, dt.toLong()); } if (with.containsKey(ParseStr.S_STARTTIME)) { if (with.get(ParseStr.S_STARTTIME) == null) { ival.setStartTime(sysEnv, null); } else { if (IntervalUtil.getDateTime(sysEnv, dt, with, ParseStr.S_STARTTIME)) secondsIgnore = true; dt.fixToMinDate(); dt.suppressSeconds(); ival.setStartTime(sysEnv, dt.toLong()); } } if (with.containsKey(ParseStr.S_ENDTIME)) { if (with.get(ParseStr.S_ENDTIME) == null) { ival.setEndTime(sysEnv, null); } else { if (IntervalUtil.getDateTime(sysEnv, dt, with, ParseStr.S_ENDTIME)) secondsIgnore = true; dt.fixToMaxDate(); dt.suppressSeconds(); ival.setEndTime(sysEnv, dt.toLong()); } } final Long startTime = ival.getStartTime(sysEnv); final Long endTime = ival.getEndTime(sysEnv); if ((startTime != null) && (endTime != null)) { final TimerDate startDate = new TimerDate(new DateTime(startTime, false).toDate()); final TimerDate endDate = new TimerDate(new DateTime(endTime, false).toDate()); if (endDate.eq(startDate)) throw new CommonErrorException( new SDMSMessage( sysEnv, "04210011321", ParseStr.S_STARTTIME + " and " + ParseStr.S_ENDTIME + " must be different")); } if (with.containsKey(ParseStr.S_EMBEDDED)) { final String embeddedName = (String) with.get(ParseStr.S_EMBEDDED); if (embeddedName == null) ival.setEmbeddedIntervalId(sysEnv, null); else { final SDMSInterval embeddedIval = SDMSIntervalTable.idx_name_getUnique( sysEnv, IntervalUtil.mapIdName(embeddedName, obj.seId)); final Long embeddedIvalId = embeddedIval.getId(sysEnv); ival.setEmbeddedIntervalId(sysEnv, embeddedIvalId); } } if ((ival.getEmbeddedIntervalId(sysEnv) != null) && (ival.getDuration(sysEnv) != null)) throw new CommonErrorException( new SDMSMessage( sysEnv, "04311251855", "intervals with " + ParseStr.S_EMBEDDED + " cannot have " + ParseStr.S_DURATION)); if (with.containsKey(ParseStr.S_DELAY)) { warning = "DELAY not longer supported"; } if (with.containsKey(ParseStr.S_INVERSE)) { final Boolean isInverse = (Boolean) with.get(ParseStr.S_INVERSE); ival.setIsInverse(sysEnv, isInverse); } if (with.containsKey(ParseStr.S_MERGE)) { warning = "MERGE not longer supported"; } if (with.containsKey(ParseStr.S_SELECTION)) { IntervalUtil.killSelections(sysEnv, ivalId); switch (IntervalUtil.createSelections(sysEnv, ivalId, with)) { case IntervalUtil.IGNORED_SECONDS: secondsIgnore = true; break; case IntervalUtil.IGNORED_UPPER_RANGE: ignoreUpperRange = true; } } if (with.containsKey(ParseStr.S_FILTER)) { IntervalUtil.killFilter(sysEnv, ivalId); duplicateFilterIgnore = IntervalUtil.createFilter(sysEnv, ivalId, obj.seSpec, with); } ival.setSeId(sysEnv, obj.seId); checkSet = new HashSet(); checkStructure(sysEnv, ivalId); SystemEnvironment.timer.notifyChange(sysEnv, ival, TimerThread.ALTER); if (with.containsKey(ParseStr.S_GROUP)) { final String gName = (String) with.get(ParseStr.S_GROUP); final Long gId = SDMSGroupTable.idx_name_deleteVersion_getUnique(sysEnv, new SDMSKey(gName, new Long(0))) .getId(sysEnv); ChownChecker.check(sysEnv, gId); ival.setOwnerId(sysEnv, gId); } if (duplicateFilterIgnore) result.setFeedback( new SDMSMessage( sysEnv, "04209270127", "Interval created (WARNING: duplicate " + ParseStr.S_FILTER + " will be ignored)")); else if (secondsIgnore) result.setFeedback( new SDMSMessage( sysEnv, "04209201344", "Interval altered (WARNING: seconds will be ignored)")); else if (ignoreUpperRange) result.setFeedback( new SDMSMessage( sysEnv, "04209270144", "Interval created (WARNING: upper range(s) will be ignored)")); else result.setFeedback( new SDMSMessage( sysEnv, "04207241731", "Interval altered" + (warning == null ? "" : ". " + warning))); }