Example usage for java.util Hashtable remove

List of usage examples for java.util Hashtable remove

Introduction

In this page you can find the example usage for java.util Hashtable remove.

Prototype

public synchronized V remove(Object key) 

Source Link

Document

Removes the key (and its corresponding value) from this hashtable.

Usage

From source file:net.ustyugov.jtalk.service.JTalkService.java

public void removeMessagesCountForJid(String account, String jid) {
    if (messagesCount.containsKey(account)) {
        Hashtable<String, Integer> hash = messagesCount.get(account);
        Enumeration<String> keys = hash.keys();
        while (keys.hasMoreElements()) {
            String key = keys.nextElement();
            if (key.startsWith(jid)) {
                hash.remove(key);
            }/*from ww  w  .  j  a  v  a  2s  .  c  om*/
        }
    }
    //       updateWidget();
}

From source file:edu.ku.brc.specify.utilapps.RegisterApp.java

/**
 * @param entries//  w ww .  j  a v a 2s .c om
 * @return
 */
private Vector<String> getKeyWordsList(final Collection<RegProcEntry> entries) {
    Properties props = new Properties();
    Hashtable<String, Boolean> statKeywords = new Hashtable<String, Boolean>();
    for (RegProcEntry entry : entries) {
        props.clear();
        props.putAll(entry.getProps());

        String os = props.getProperty("os_name");
        String ver = props.getProperty("os_version");
        props.put("platform", os + " " + ver);

        for (Object keywordObj : props.keySet()) {
            statKeywords.put(keywordObj.toString(), true);
        }
    }

    String[] trackKeys = rp.getTrackKeys();

    for (String keyword : new Vector<String>(statKeywords.keySet())) {
        if (keyword.startsWith("Usage") || keyword.startsWith("num_") || keyword.endsWith("_portal")
                || keyword.endsWith("_number") || keyword.endsWith("_website") || keyword.endsWith("id")
                || keyword.endsWith("os_name") || keyword.endsWith("os_version")) {
            statKeywords.remove(keyword);

        } else {
            for (String key : trackKeys) {
                if (keyword.startsWith(key)) {
                    statKeywords.remove(keyword);
                }
            }
        }
    }

    statKeywords.remove("date");
    //statKeywords.remove("time");
    statKeywords.put("by_date", true);
    statKeywords.put("by_month", true);
    statKeywords.put("by_year", true);

    return new Vector<String>(statKeywords.keySet());
}

From source file:gov.nih.nci.cabig.caaers.service.synchronizer.TreatmentAssignmentSynchronizer.java

public void migrate(Study dbStudy, Study xmlStudy, DomainObjectImportOutcome<Study> outcome) {
    //create an Index of existing ones (available in DB)
    Hashtable<String, TreatmentAssignment> dbTacIndexMap = new Hashtable<String, TreatmentAssignment>();
    Hashtable<String, TreatmentAssignment> dbCtepIndexMap = new Hashtable<String, TreatmentAssignment>();
    for (TreatmentAssignment ta : dbStudy.getActiveTreatmentAssignments()) {
        String ctepDbId = StringUtils.upperCase(ta.getCtepDbIdentifier());
        String tac = StringUtils.upperCase(ta.getCode());
        dbTacIndexMap.put(tac, ta);/*w ww.j  av a 2s.  c  o  m*/
        if (StringUtils.isNotEmpty(ctepDbId))
            dbCtepIndexMap.put(ctepDbId, ta);
    }

    //Identify New TreatmentAssignments and also update existing ones.
    for (TreatmentAssignment xmlTreatmentAssignment : xmlStudy.getTreatmentAssignments()) {

        // //CAAERS-7367 - /REFACTORED - always prefer the tac that is available.
        String ctepDbId = StringUtils.upperCase(xmlTreatmentAssignment.getCtepDbIdentifier());
        String tac = StringUtils.upperCase(xmlTreatmentAssignment.getCode());
        if (StringUtils.isEmpty(tac) && StringUtils.isEmpty(ctepDbId))
            continue; //no I cannot process this record
        TreatmentAssignment ta = null;

        //try to identify the TA by ctep-id
        if (StringUtils.isNotEmpty(ctepDbId)) {
            ta = dbCtepIndexMap.get(ctepDbId);
        }
        //TA not found : try to find by tac
        if (ta == null)
            ta = dbTacIndexMap.get(tac);

        //still tac null -- create a new one.
        if (ta == null) {
            ta = xmlTreatmentAssignment;
            dbStudy.addTreatmentAssignment(xmlTreatmentAssignment);
            continue;
        }

        //it is an existing TA, so lets sync up the attributes
        ta.setCtepDbIdentifier(xmlTreatmentAssignment.getCtepDbIdentifier());
        ta.setCode(xmlTreatmentAssignment.getCode());
        ta.setDescription(xmlTreatmentAssignment.getDescription());
        ta.setComments(xmlTreatmentAssignment.getComments());
        ta.setDoseLevelOrder(xmlTreatmentAssignment.getDoseLevelOrder());

        //marking the TA as processed by removing it from index
        dbTacIndexMap.remove(tac);

    }

    //soft delete - all the TAs that were not present in XML Study
    AbstractMutableRetireableDomainObject.retire(dbTacIndexMap.values());

}

From source file:org.unitime.timetable.model.Solution.java

public boolean commitSolution(List<String> messages, org.hibernate.Session hibSession,
        String sendNotificationPuid) throws Exception {
    List solutions = hibSession.createCriteria(Solution.class).add(Restrictions.eq("owner", getOwner())).list();
    Solution uncommittedSolution = null;
    for (Iterator i = solutions.iterator(); i.hasNext();) {
        Solution s = (Solution) i.next();
        if (s.equals(this))
            continue;
        if (s.isCommited().booleanValue()) {
            uncommittedSolution = s;/*from  w w w  .  ja v  a2s  .  c  om*/
            s.uncommitSolution(hibSession, null);
        }
    }
    if (DEBUG)
        sLog.debug("commit[" + getUniqueId() + "," + getOwner().getName()
                + "] -------------------------------------------------------");

    boolean isOK = true;
    for (Object[] o : (List<Object[]>) hibSession.createQuery(
            "select r, a1, a2 from Location r inner join r.assignments a1 inner join r.assignments a2 "
                    + "where a1.solution.uniqueId = :solutionId and a2.solution.commited = true and a2.solution.owner.uniqueId != :ownerId and "
                    + "bit_and(a1.days, a2.days) > 0 and (a1.timePattern.type = :exactType or a2.timePattern.type = :exactType or "
                    + "(a1.startSlot < a2.startSlot + a2.timePattern.slotsPerMtg and a2.startSlot < a1.startSlot + a1.timePattern.slotsPerMtg))")
            .setLong("ownerId", getOwner().getUniqueId()).setLong("solutionId", getUniqueId())
            .setInteger("exactType", TimePattern.sTypeExactTime).list()) {
        Location room = (Location) o[0];
        Assignment a = (Assignment) o[1];
        Assignment b = (Assignment) o[2];
        if (!room.isIgnoreRoomCheck() && a.getTimeLocation().hasIntersection(b.getTimeLocation())
                && !shareRooms(a, b)) {
            messages.add("Class " + a.getClassName() + " " + a.getTimeLocation().getName(CONSTANTS.useAmPm())
                    + " overlaps with " + b.getClassName() + " "
                    + b.getTimeLocation().getName(CONSTANTS.useAmPm()) + " (room " + room.getLabel() + ")");
            isOK = false;
        }
    }

    for (Object[] o : (List<Object[]>) hibSession.createQuery(
            "select i1, a1, a2 from ClassInstructor c1 inner join c1.instructor i1 inner join c1.classInstructing.assignments a1, "
                    + "ClassInstructor c2 inner join c2.instructor i2 inner join c2.classInstructing.assignments a2 where c1.lead = true and c2.lead = true and "
                    + "i1.department.solverGroup.uniqueId = :ownerId and i2.department.solverGroup.uniqueId != :ownerId and i2.department.session = :sessionId and "
                    + "i1.externalUniqueId is not null and i1.externalUniqueId = i2.externalUniqueId and "
                    + "a1.solution.uniqueId = :solutionId and a2.solution.commited = true and a2.solution.owner.uniqueId != :ownerId and "
                    + "bit_and(a1.days, a2.days) > 0 and (a1.timePattern.type = :exactType or a2.timePattern.type = :exactType or "
                    + "(a1.startSlot < a2.startSlot + a2.timePattern.slotsPerMtg and a2.startSlot < a1.startSlot + a1.timePattern.slotsPerMtg))")
            .setLong("ownerId", getOwner().getUniqueId()).setLong("solutionId", getUniqueId())
            .setLong("sessionId", getOwner().getSession().getUniqueId())
            .setInteger("exactType", TimePattern.sTypeExactTime).list()) {
        DepartmentalInstructor instructor = (DepartmentalInstructor) o[0];
        Assignment a = (Assignment) o[1];
        Assignment b = (Assignment) o[2];
        if (a.getTimeLocation().hasIntersection(b.getTimeLocation()) && !shareRooms(a, b)) {
            messages.add("Class " + a.getClassName() + " " + a.getTimeLocation().getName(CONSTANTS.useAmPm())
                    + " overlaps with " + b.getClassName() + " "
                    + b.getTimeLocation().getName(CONSTANTS.useAmPm()) + " (instructor "
                    + instructor.nameLastNameFirst() + ")");
            isOK = false;
        }
    }

    if (!isOK) {
        if (sendNotificationPuid != null)
            sendNotification(uncommittedSolution, this, sendNotificationPuid, false, messages);
        return false;
    }

    // NOTE: In order to decrease the amount of interaction between solutions persistance of committed student conflicts was disabled
    /*
    SolverInfoDef defJenrlInfo = SolverInfoDef.findByName(hibSession,"JenrlInfo");
    Hashtable solverInfos = new Hashtable();
    AssignmentDAO adao = new AssignmentDAO(); 
    q = hibSession.createQuery(
    "select a.uniqueId, oa.uniqueId, count(*) from "+
    "Solution s inner join s.assignments a inner join s.studentEnrollments as e, "+
    "Solution os inner join os.assignments oa inner join os.studentEnrollments as oe "+
    "where "+
    "s.uniqueId=:solutionId and os.owner.session.uniqueId=:sessionId and os.owner.uniqueId!=:ownerId and "+
    "a.clazz=e.clazz and oa.clazz=oe.clazz and a.clazz.schedulingSubpart!=oa.clazz.schedulingSubpart and e.studentId=oe.studentId "+
    "group by a.uniqueId, oa.uniqueId");
    q.setLong("ownerId",getOwner().getUniqueId().longValue());
    q.setLong("solutionId",getUniqueId());
    q.setLong("sessionId",getOwner().getSession().getUniqueId().longValue());
    Iterator otherAssignments = q.iterate();
    while (otherAssignments.hasNext()) {
       Object[] result = (Object[])otherAssignments.next();
       Assignment assignment = adao.get((Integer)result[0],hibSession);
       Assignment otherAssignment = adao.get((Integer)result[1],hibSession);
       int jenrl = ((Number)result[2]).intValue();
               
       if (assignment==null || otherAssignment==null || jenrl==0 || !assignment.isInConflict(otherAssignment)) continue;
       addCommitJenrl(hibSession, assignment, otherAssignment, jenrl, defJenrlInfo, solverInfos);
      }   
            
    for (Iterator i=solverInfos.values().iterator();i.hasNext();) {
       SolverInfo sInfo = (SolverInfo)i.next();
       hibSession.saveOrUpdate(sInfo);
    }
    */

    setCommitDate(new Date());
    setCommited(Boolean.TRUE);

    //      createDivSecNumbers(hibSession, messages);

    EventContact contact = null;
    if (sendNotificationPuid != null) {
        contact = EventContact.findByExternalUniqueId(sendNotificationPuid);
        if (contact == null) {
            TimetableManager manager = TimetableManager.findByExternalId(sendNotificationPuid);
            if (manager != null) {
                contact = new EventContact();
                contact.setFirstName(manager.getFirstName());
                contact.setMiddleName(manager.getMiddleName());
                contact.setLastName(manager.getLastName());
                contact.setExternalUniqueId(manager.getExternalUniqueId());
                contact.setEmailAddress(manager.getEmailAddress());
                hibSession.save(contact);
            }
        }
    }
    Hashtable<Long, ClassEvent> classEvents = new Hashtable();
    for (Iterator i = hibSession.createQuery(
            "select e from Solution s inner join s.assignments a, ClassEvent e where e.clazz=a.clazz and s.uniqueId=:solutionId")
            .setLong("solutionId", getUniqueId()).iterate(); i.hasNext();) {
        ClassEvent e = (ClassEvent) i.next();
        classEvents.put(e.getClazz().getUniqueId(), e);
    }
    for (Iterator i = getAssignments().iterator(); i.hasNext();) {
        Assignment a = (Assignment) i.next();
        ClassEvent event = a.generateCommittedEvent(classEvents.get(a.getClassId()), true);
        classEvents.remove(a.getClassId());
        if (event != null && !event.getMeetings().isEmpty()) {
            event.setMainContact(contact);
            if (event.getNotes() == null)
                event.setNotes(new HashSet<EventNote>());
            EventNote note = new EventNote();
            note.setEvent(event);
            note.setNoteType(event.getUniqueId() == null ? EventNote.sEventNoteTypeCreateEvent
                    : EventNote.sEventNoteTypeEditEvent);
            note.setTimeStamp(new Date());
            note.setUser(contact == null ? "System" : contact.getName());
            note.setUserId(sendNotificationPuid);
            note.setTextNote(getOwner().getName() + " committed");
            note.setMeetings(a.getPlacement().getLongName(CONSTANTS.useAmPm()));
            event.getNotes().add(note);
            hibSession.saveOrUpdate(event);
        }
        if (event != null && event.getMeetings().isEmpty() && event.getUniqueId() != null)
            hibSession.delete(event);
    }

    if (ApplicationProperty.ClassAssignmentChangePastMeetings.isTrue()) {
        for (Enumeration e = classEvents.elements(); e.hasMoreElements();) {
            ClassEvent event = (ClassEvent) e.nextElement();
            hibSession.delete(event);
        }
    } else {
        Calendar cal = Calendar.getInstance(Locale.US);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        Date today = cal.getTime();

        for (Enumeration e = classEvents.elements(); e.hasMoreElements();) {
            ClassEvent event = (ClassEvent) e.nextElement();
            for (Iterator<Meeting> i = event.getMeetings().iterator(); i.hasNext();)
                if (!i.next().getMeetingDate().before(today))
                    i.remove();
            if (event.getMeetings().isEmpty()) {
                hibSession.delete(event);
            } else {
                if (event.getNotes() == null)
                    event.setNotes(new HashSet<EventNote>());
                EventNote note = new EventNote();
                note.setEvent(event);
                note.setNoteType(EventNote.sEventNoteTypeDeletion);
                note.setTimeStamp(new Date());
                note.setUser(contact == null ? "System" : contact.getName());
                note.setUserId(sendNotificationPuid);
                note.setTextNote(getOwner().getName() + " committed, class was removed or unassigned");
                note.setMeetings("N/A");
                event.getNotes().add(note);
                hibSession.saveOrUpdate(event);
            }
        }
    }

    if (sendNotificationPuid != null)
        sendNotification(uncommittedSolution, this, sendNotificationPuid, true, messages);

    // Manually fix the Clazz_.committedAssignment cache.
    for (Assignment a : getAssignments())
        a.getClazz().setCommittedAssignment(a);

    return true;
}

From source file:com.codename1.android.AndroidLayoutImporter.java

private void applyStyles(Element inputSrcElement, Element out) {
    String type = out.getAttribute("type");
    String id = "Android" + type + (styleIndex++);
    String selId = id + ".sel";
    String unselId = id;/* w ww .  j a  va  2s  . c  om*/
    String pressedId = id + ".press";
    String disabledId = id + ".dis";

    outputResources.setThemeProperty(themeName, unselId + ".derive", type);
    outputResources.setThemeProperty(themeName, selId + "#derive", type + ".sel");
    outputResources.setThemeProperty(themeName, pressedId + "#derive", type + ".press");
    outputResources.setThemeProperty(themeName, disabledId + "#derive", type + ".dis");
    out.setAttribute("uiid", id);

    // If there is a width/height specified, we will use 3 piece borders to 
    // force preserved space.
    if ((getNS(inputSrcElement, "width", null) != null || getNS(inputSrcElement, "height", null) != null
            || getNS(inputSrcElement, "minHeight", null) != null
            || getNS(inputSrcElement, "minWidth", null) != null)
            && getNS(inputSrcElement, "background", null) == null) {
        // Removing this for now, because using border images just to ensure width is
        // crazy heavy and really shouldn't be necessary... will find a better way.
        /*
        String minWidth = getNS(inputSrcElement, "minWidth", getNS(inputSrcElement, "width", "5dp"));
        String minHeight = getNS(inputSrcElement, "minHeight", getNS(inputSrcElement, "height", "5dp"));
        System.out.println("Creating border with width "+minWidth+" and height "+minHeight+" for id "+id);
        Border border = Border.createHorizonalImageBorder(createBlankImage(minWidth, minHeight), createBlankImage("1dp", minHeight), createBlankImage("1dp", minHeight));
                
        setAllStyles(id, "border", border);
            */
    }

    if (getNS(inputSrcElement, "paddingTop", null) != null
            || getNS(inputSrcElement, "paddingBottom", null) != null
            || getNS(inputSrcElement, "paddingLeft", null) != null
            || getNS(inputSrcElement, "paddingRight", null) != null) {
        String padding = parseNumber(getNS(inputSrcElement, "paddingTop", "0")).value + ","
                + parseNumber(getNS(inputSrcElement, "paddingBottom", "0")).value + ","
                + parseNumber(getNS(inputSrcElement, "paddingLeft", "0")).value + ","
                + parseNumber(getNS(inputSrcElement, "paddingRight", "0")).value;

        byte[] paddingUnits = new byte[] { parseNumber(get(inputSrcElement, "paddingTop", "0")).unit,
                parseNumber(getNS(inputSrcElement, "paddingRight", "0")).unit,
                parseNumber(getNS(inputSrcElement, "paddingBottom", "0")).unit,
                parseNumber(getNS(inputSrcElement, "paddingLeft", "0")).unit };
        //System.out.println("Setting padding: "+padding);
        setAllStyles(id, "padding", padding);
        setAllStyles(id, "padUnit", paddingUnits);
    }

    if (getNS(inputSrcElement, "marginTop", null) != null
            || getNS(inputSrcElement, "marginBottom", null) != null
            || getNS(inputSrcElement, "marginLeft", null) != null
            || getNS(inputSrcElement, "marginRight", null) != null) {
        String margin = parseNumber(get(inputSrcElement, "marginTop", "0")).value + ","
                + parseNumber(getNS(inputSrcElement, "marginBottom", "0")).value + ","
                + parseNumber(getNS(inputSrcElement, "marginLeft", "0")).value + ","
                + parseNumber(getNS(inputSrcElement, "marginRight", "0")).value;

        byte[] marginUnits = new byte[] { parseNumber(get(inputSrcElement, "marginTop", "0")).unit,
                parseNumber(getNS(inputSrcElement, "marginRight", "0")).unit,
                parseNumber(getNS(inputSrcElement, "marginBottom", "0")).unit,
                parseNumber(getNS(inputSrcElement, "marginLeft", "0")).unit };
        //System.out.println("Setting margin "+margin);
        setAllStyles(id, "margin", margin);
        setAllStyles(id, "marUnit", marginUnits);
    }

    if (get(inputSrcElement, "background", null) != null) {
        // We have a custom background
        String backgroundStr = getNS(inputSrcElement, "background", null);
        if (backgroundStr.startsWith("@drawable/")) {
            try {
                backgroundStr = backgroundStr.substring(backgroundStr.indexOf("/") + 1);
                List<Element> items = getSelectorElementsForDrawable(backgroundStr);

                // 

                if (items != null) {
                    String defaultBackground = null;
                    String pressedBackground = null;
                    String disabledBackground = null;
                    String selectedBackground = null;
                    for (Element item : items) {

                        if (item.hasAttributeNS(NS_ANDROID, "drawable")) {
                            String itemDrawableStr = item.getAttributeNS(NS_ANDROID, "drawable");
                            if (itemDrawableStr.startsWith("@drawable/")) {
                                itemDrawableStr = itemDrawableStr.substring(itemDrawableStr.indexOf("/") + 1);
                            }
                            File itemDrawable = findDrawableResource(itemDrawableStr);
                            if (itemDrawable == null || (!itemDrawable.getName().endsWith(".png")
                                    && !itemDrawable.getName().endsWith(".jpg"))) {
                                // Let's not support nested xml drawables just yet...
                                // we'll skip this
                                continue;
                            }
                            if (!outputResources.containsResource(itemDrawable.getName())) {
                                // If the resource file hasn't imported the image yet, we won't set it here
                                continue;
                            }

                            if (item.hasAttributeNS(NS_ANDROID, "state_pressed")
                                    && "true".equals(item.getAttributeNS(NS_ANDROID, "state_pressed"))) {
                                pressedBackground = itemDrawable.getName();
                                //outputResources.setThemeProperty(themeName, pressedId+"#border", createImageBorder(itemDrawable.getName()));
                            } else if (item.hasAttributeNS(NS_ANDROID, "state_enabled")
                                    && "false".equals(item.getAttributeNS(NS_ANDROID, "state_enabled"))) {
                                //outputResources.setThemeProperty(themeName, disabledId+"#border", createImageBorder(itemDrawable.getName()));
                                disabledBackground = itemDrawable.getName();
                            } else if (item.hasAttributeNS(NS_ANDROID, "state_focused")
                                    && "true".equals(item.getAttributeNS(NS_ANDROID, "state_focused"))) {
                                selectedBackground = itemDrawable.getName();
                            } else {
                                defaultBackground = itemDrawable.getName();
                                //outputResources.setThemeProperty(themeName, id+".border", createImageBorder(itemDrawable.getName()));
                            }
                        }
                    }

                    if (defaultBackground != null) {
                        if (pressedBackground == null)
                            pressedBackground = defaultBackground;
                        if (selectedBackground == null)
                            selectedBackground = defaultBackground;
                        if (disabledBackground == null)
                            disabledBackground = defaultBackground;
                    }

                    if (defaultBackground != null) {
                        outputResources.setThemeProperty(themeName, id + ".border",
                                createImageBorder(defaultBackground));
                    }
                    if (pressedBackground != null) {
                        outputResources.setThemeProperty(themeName, pressedId + "#border",
                                createImageBorder(pressedBackground));
                    }
                    if (selectedBackground != null) {
                        outputResources.setThemeProperty(themeName, selId + "#border",
                                createImageBorder(pressedBackground));
                    }
                    if (disabledBackground != null) {
                        outputResources.setThemeProperty(themeName, disabledId + "#border",
                                createImageBorder(disabledBackground));
                    }
                }
            } catch (SAXException ex) {
                Logger.getLogger(AndroidLayoutImporter.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(AndroidLayoutImporter.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }

    if (false && (get(inputSrcElement, "drawable", null) != null
            || get(inputSrcElement, "drawableTop", null) != null
            || get(inputSrcElement, "drawableRight", null) != null
            || get(inputSrcElement, "drawableBottom", null) != null
            || get(inputSrcElement, "drawableLeft", null) != null)) {
        String iconDrawableStr = null;
        int iconPosition = -1;
        if (inputSrcElement.hasAttributeNS(NS_ANDROID, "drawableLeft")) {
            iconDrawableStr = get(inputSrcElement, "drawableLeft", null);
            iconPosition = Component.LEFT;
        } else if (get(inputSrcElement, "drawableRight", null) != null) {
            iconDrawableStr = get(inputSrcElement, "drawableRight", null);
            iconPosition = Component.RIGHT;
        } else if (get(inputSrcElement, "drawableTop", null) != null) {
            iconDrawableStr = get(inputSrcElement, "drawableTop", null);
            iconPosition = Component.TOP;
        } else if (get(inputSrcElement, "drawableBottom", null) != null) {
            iconDrawableStr = get(inputSrcElement, "drawableBottom", null);
            iconPosition = Component.BOTTOM;
        }

        if (iconPosition >= 0) {
            switch (iconPosition) {
            case Component.TOP:
                out.setAttribute("textPosition", String.valueOf(Component.BOTTOM));
                break;
            case Component.BOTTOM:
                out.setAttribute("textPosition", String.valueOf(Component.TOP));
                break;
            case Component.LEFT:
                out.setAttribute("textPosition", String.valueOf(Component.RIGHT));
                break;
            case Component.RIGHT:
                out.setAttribute("textPosition", String.valueOf(Component.LEFT));
                break;
            }
            String backgroundStr = iconDrawableStr;
            if (backgroundStr.startsWith("@drawable/")) {
                try {
                    backgroundStr = backgroundStr.substring(backgroundStr.indexOf("/") + 1);
                    List<Element> items = getSelectorElementsForDrawable(backgroundStr);
                    if (items != null) {
                        for (Element item : items) {

                            if (item.hasAttributeNS(NS_ANDROID, "drawable")) {
                                String itemDrawableStr = item.getAttributeNS(NS_ANDROID, "drawable");
                                if (itemDrawableStr.startsWith("@drawable/")) {
                                    itemDrawableStr = itemDrawableStr
                                            .substring(itemDrawableStr.indexOf("/") + 1);
                                }
                                File itemDrawable = findDrawableResource(itemDrawableStr);
                                if (itemDrawable == null || (!itemDrawable.getName().endsWith(".png")
                                        && !itemDrawable.getName().endsWith(".jpg"))) {
                                    // Let's not support nested xml drawables just yet...
                                    // we'll skip this
                                    continue;
                                }
                                if (!outputResources.containsResource(itemDrawable.getName())) {
                                    // If the resource file hasn't imported the image yet, we won't set it here
                                    continue;
                                }
                                if (item.hasAttributeNS(NS_ANDROID, "state_pressed")
                                        && "true".equals(item.getAttributeNS(NS_ANDROID, "state_pressed"))) {
                                    out.setAttribute("pressedIcon", itemDrawableStr);
                                } else if (item.hasAttributeNS(NS_ANDROID, "state_enabled")
                                        && "false".equals(item.getAttributeNS(NS_ANDROID, "state_enabled"))) {

                                    out.setAttribute("disabledIcon", itemDrawableStr);
                                } else {
                                    out.setAttribute("icon", itemDrawableStr);
                                }
                            }
                        }
                    }
                } catch (SAXException ex) {
                    Logger.getLogger(AndroidLayoutImporter.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException ex) {
                    Logger.getLogger(AndroidLayoutImporter.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }

    // Try to find an existing style that we can merge
    Hashtable<String, Object> theme = outputResources.getTheme(themeName);

    String matchingId = findMatchingId(id, theme);
    if (matchingId != null) {
        //System.out.println("Found UIID with identical styles to "+id+".  Removing "+id+" and just using "+matchingId);
        // There is already a UIID that is identical to this one, so let's just
        // use that.
        out.setAttribute("uiid", matchingId);

        Set<String> keysToRemove = new HashSet<String>();
        String prefix = id + ".";
        for (String key : theme.keySet()) {
            if (key.startsWith(prefix)) {
                keysToRemove.add(key);
            }
        }
        for (String key : keysToRemove) {
            theme.remove(key);
        }
        outputResources.setTheme(themeName, theme);
    }
}

From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java

protected Vector<FormCellLabel> getAvailableLabels() {
    Vector<FormCellLabel> list = new Vector<FormCellLabel>();
    Hashtable<String, FormCellLabel> labelHash = new Hashtable<String, FormCellLabel>();
    //Hashtable<String, FormCellLabel> labelForHash = new Hashtable<String, FormCellLabel>();
    // Add all the labels
    for (FormRowIFace row : formViewDef.getRows()) {
        for (FormCellIFace cell : row.getCells()) {
            if (cell instanceof FormCellLabel) {
                //labelForHash.put(((FormCellLabel)cell).getLabelFor(), (FormCellLabel)cell);
                labelHash.put(cell.getIdent(), (FormCellLabel) cell);
            }/* w ww .  j a  va  2s .c o  m*/
        }
    }

    // remove the ones in use
    for (FormRowIFace row : formViewDef.getRows()) {
        for (FormCellIFace cell : row.getCells()) {
            if (cell instanceof FormCellField) {
                FormCellField fcf = (FormCellField) cell;
                FormCellLabel label = labelHash.get(fcf.getIdent());
                if (label != null) {
                    labelHash.remove(label.getIdent());
                }
            }
        }
    }
    list.addAll(labelHash.values());
    return list;
}

From source file:org.panlab.tgw.resources.PTMResource.java

@POST // The Java method will produce content identified by the MIME Media
// type "text/plain"
@Produces("text/xml")
@Consumes("application/x-www-form-urlencoded")
public String postResource(@PathParam("ptmid") String ptmid, @PathParam("resourceid") String resourceid,
        String content) {//from w w  w.j  a  va  2 s  .  com
    log.info("POST (" + j + ") /" + ptmid + "/" + resourceid + " " + content);
    try {

        XMLElement tempTop = XMLUtil.getTopElement(content);
        if (org.panlab.tgw.App.getStatus(ptmid) != 0) {
            String type = tempTop.m_name;
            return createError(org.panlab.tgw.App.statusText(org.panlab.tgw.App.getStatus(ptmid)), resourceid,
                    type);
        }
        if (org.panlab.tgw.App.getRAStatus(resourceid) != 0) {
            String type = tempTop.m_name;
            return createError("RA: " + resourceid + " has reported an error", resourceid, type);
        }
        String context = XMLUtil.getXMLElement(content, "context");
        String vctid = XMLUtil.getXMLElement(context, "vctId");
        content = XMLUtil.getXMLElement(content, "configuration");
        tempTop.m_value = content;
        content = tempTop.toString();
        if (tempTop.m_name.equalsIgnoreCase("vlan")) {
            Object[] tempList = XMLUtil.getElements(content);
            if (tempList != null && tempList.length > 0) {
                String tempid = ((XMLElement) (tempList[0])).m_value;
                tempid = tempid.substring(0, tempid.indexOf("."));
                ptmid = tempid;
                resourceid = ptmid + ".top-0";
                log.info("changed to: " + ptmid + "/" + resourceid);
            }
        }
        log.info("POST (" + j + ") /" + ptmid + "/" + resourceid + " vctID:" + vctid + " " + content);
        if (ptmid.equalsIgnoreCase("share")) {
            T1ServiceLocator l = new T1ServiceLocator();
            T1SoapBindingStub stub;
            XMLElement top = XMLUtil.getTopElement(content);
            Object elements[] = XMLUtil.getElements(content);
            log.info(top.m_name);
            if (top.m_name.equalsIgnoreCase("vpn")) {
                int vpnsize = elements.length;
                Hashtable<String, String> igwSettings = new Hashtable<String, String>();
                for (int i = 0; i < elements.length; i++) {
                    XMLElement temp = (XMLElement) elements[i];
                    log.info(temp.toString());
                    if (temp.m_attribute != null) {
                        String ptm = temp.m_value.substring(0, temp.m_value.indexOf("."));
                        stub = (T1SoapBindingStub) (l.getT1((URL) (org.panlab.tgw.App.ptm_indexes.get(ptm))));
                        ProvisioningResponse ref;
                        ref = stub.query(vctid, temp.m_value, "<connectivity></connectivity>", null);
                        log.info(ref.getConfig_data());
                        igwSettings.put(temp.m_value, ref.getConfig_data());
                    }
                }
                String vpn_id = "";
                Enumeration<String> en = igwSettings.keys();
                log.info("igwSettings " + igwSettings.size());
                while (en.hasMoreElements()) {
                    String current = en.nextElement();
                    String currentdetails = igwSettings.get(current);
                    log.info(current + ": " + currentdetails);
                    while (en.hasMoreElements()) {
                        String other = en.nextElement();
                        String otherdetails = igwSettings.get(other);

                        String ptm = current.substring(0, current.indexOf("."));
                        vpn_id += current;
                        stub = (T1SoapBindingStub) (l.getT1((URL) (org.panlab.tgw.App.ptm_indexes.get(ptm))));
                        ProvisioningResponse ref;
                        ref = stub.update(vctid, current, otherdetails, null);
                        log.info(ref.getStatus_code());
                        ptm = other.substring(0, other.indexOf("."));
                        vpn_id += other;
                        stub = (T1SoapBindingStub) (l.getT1((URL) (org.panlab.tgw.App.ptm_indexes.get(ptm))));
                        ref = stub.update(vctid, other, currentdetails, null);
                        log.info(ref.getStatus_code());

                    }
                    igwSettings.remove(current);
                    log.info("igwSettings " + igwSettings.size());
                    en = igwSettings.keys();
                }
                log.info("VPN_ID: " + vpn_id);
                return createOK(vpn_id, "vpn");
            } else
                return createError("Share ptm expects only vlan or vpn. Check VCT design", resourceid,
                        top.m_name);

        } else {
            T1ServiceLocator l = new T1ServiceLocator();
            T1SoapBindingStub stub;
            XMLElement top = XMLUtil.getTopElement(content);
            Object elements[] = XMLUtil.getElements(content);
            String conf = "";
            Vector<String> referencedRAIDs = new Vector<String>();
            for (int i = 0; i < elements.length; i++) {
                XMLElement temp = (XMLElement) elements[i];
                log.info(temp.toString());
                if (temp.m_attributes.containsKey("type")
                        && temp.m_attributes.get("type").equalsIgnoreCase("\"reference\"")) {
                    if (!(temp.m_value.equalsIgnoreCase(""))) {
                        referencedRAIDs.add(temp.m_value);
                        String ptm = temp.m_value.substring(0, temp.m_value.indexOf("."));
                        stub = (T1SoapBindingStub) (l.getT1((URL) (org.panlab.tgw.App.ptm_indexes.get(ptm))));
                        ProvisioningResponse ref;
                        if (resourceid.endsWith("top-0") && top.m_name.equalsIgnoreCase("vlan"))
                            ref = stub.query(vctid, temp.m_value, "<connectivity></connectivity>", null);
                        else
                            ref = stub.query(vctid, temp.m_value, "<reference></reference>", null);

                        log.info(temp.m_value + " ref data: " + ref.getConfig_data());
                        if (resourceid.endsWith("top-0") && top.m_name.equalsIgnoreCase("vlan"))
                            elements[i] = new XMLElement("item-" + i, null, null, ref.getConfig_data());
                        else
                            elements[i] = new XMLElement(temp.m_name, null, null, ref.getConfig_data());
                    }
                }
                if (temp.m_value != null)
                    conf += elements[i].toString();
            }

            ProvisioningResponse res = null;
            if (top.m_attributes.containsKey("action")
                    && top.m_attributes.get("action").equalsIgnoreCase("\"update\"")) {
                log.info(top.m_attributes.get("action"));
                log.info("SENDING: " + conf);
                stub = (T1SoapBindingStub) (l.getT1((URL) (org.panlab.tgw.App.ptm_indexes.get(ptmid))));
                if (top.m_attributes.containsKey("mode")
                        && top.m_attributes.get("mode").equalsIgnoreCase("\"asynchronous\""))
                    res = stub.update(vctid, resourceid, conf,
                            "https://" + System.getProperty("publicIP") + ":8070/axis/services/TeagleGW");
                else
                    res = stub.update(vctid, resourceid, conf, null);
                log.info("https://" + java.net.Inet4Address.getLocalHost() + ":8070/axis/services/TeagleGW");
            } else {
                conf = "<" + top.m_name + ">" + conf + "</" + top.m_name + ">";
                log.info("SENDING: " + conf);
                stub = (T1SoapBindingStub) (l.getT1((URL) (org.panlab.tgw.App.ptm_indexes.get(ptmid))));
                //log.info(vctid+" "+resourceid+" "+conf);
                if (top.m_attributes.containsKey("mode")
                        && top.m_attributes.get("mode").equalsIgnoreCase("\"asynchronous\""))
                    res = stub.create(vctid, resourceid, conf,
                            "https://62.103.214.70:8070/axis/services/TeagleGW");
                else
                    res = stub.create(vctid, resourceid, conf, null);
                if (res != null) {
                    if (!(res.getConfig_data().contains("FAIL")))
                        resourceid = XMLUtil.getXMLElement(res.getConfig_data(), "uuid");
                    else
                        resourceid = res.getConfig_data();
                }
            }
            if (res != null) {
                int referencedSize = referencedRAIDs.size();
                if (!(top.m_attributes.containsKey("mode")) || (top.m_attributes.containsKey("mode")
                        && !(top.m_attributes.get("mode").equalsIgnoreCase("\"asynchronous\""))))
                    if (referencedSize > 0) {
                        stub = (T1SoapBindingStub) (l.getT1((URL) (org.panlab.tgw.App.ptm_indexes.get(ptmid))));
                        ProvisioningResponse ref;
                        ref = stub.query(vctid, resourceid, "<reference></reference>", null);
                        conf = "<" + top.m_name + ">" + ref.getConfig_data() + "</" + top.m_name + ">";
                        log.info("The following data have to be sent to all referenced resources by "
                                + resourceid + " :" + conf);
                        if (!org.panlab.tgw.App.CIRCULAR_REFERENCE) {
                            log.info("reverse reference disabled");
                            referencedSize = 0;
                        }
                        for (int k = 0; k < referencedSize; k++) {
                            String temp = referencedRAIDs.remove(0);
                            if (temp != null) {
                                log.info("Updating " + temp);
                                log.info(conf);
                                String ptm = temp.substring(0, temp.indexOf("."));
                                stub = (T1SoapBindingStub) (l
                                        .getT1((URL) (org.panlab.tgw.App.ptm_indexes.get(ptm))));
                                ProvisioningResponse update;
                                update = stub.update(vctid, temp, conf, null);
                                log.info("Updated " + temp + " :" + update.getStatus_code());
                            }
                        }
                    }
                //String type = resourceid.substring(resourceid.lastIndexOf(".")+1,resourceid.lastIndexOf("-"));
                String response = "";
                if (top.m_attributes.containsKey("action")
                        && top.m_attributes.get("action").equalsIgnoreCase("\"update\"")) {
                    log.info("RETURNING conf: " + res.getConfig_data());
                    log.info("RETURNING status: " + res.getStatus_code());
                    log.info("RETURNING id: " + res.getRequest_id());
                    response = res.getStatus_code();
                } else {
                    log.info("RETURNING conf: " + res.getConfig_data());
                    log.info("RETURNING status: " + res.getStatus_code());
                    log.info("RETURNING id: " + res.getRequest_id());
                    response = res.getConfig_data();
                }
                if (top.m_attributes.containsKey("mode")
                        && top.m_attributes.get("mode").equalsIgnoreCase("\"asynchronous\"")) {
                    App.async_reqs.put(res.getRequest_id(), new Notification(res.getRequest_id(), "", "", vctid,
                            "RETURN_STATUS", "MESSAGE", "", ptmid, top.m_name, referencedRAIDs));

                    return createOK(null, top.m_name/*type*/, res.getRequest_id());
                } else {
                    m_ids.put(resourceid, vctid);
                    return createOK(resourceid, top.m_name/*type*/);
                }
            } else {
                //String type = resourceid.substring(resourceid.lastIndexOf(".")+1,resourceid.lastIndexOf("-"));
                return createError("Null response from PTM", resourceid, top.m_name/*type*/);
            }

        }
    } catch (Exception error) {
        //error.printStackTrace();
        String type = resourceid.substring(resourceid.lastIndexOf(".") + 1, resourceid.lastIndexOf("-"));
        log.info("RETURNING: " + error.getMessage());
        return createError(error.getMessage(), resourceid, type);
    }
}

From source file:oscar.dms.actions.DmsInboxManageAction.java

private void setQueueDocsInSession(ArrayList<EDoc> privatedocs, HttpServletRequest request) {
    // docs according to queue name
    Hashtable queueDocs = new Hashtable();
    QueueDao queueDao = (QueueDao) SpringUtils.getBean("queueDao");
    List<Hashtable> queues = queueDao.getQueues();
    for (int i = 0; i < queues.size(); i++) {
        Hashtable ht = queues.get(i);
        List<EDoc> EDocs = new ArrayList<EDoc>();
        String queueId = (String) ht.get("id");
        queueDocs.put(queueId, EDocs);//  w  w  w . j a  v  a  2  s.co  m
    }
    logger.debug("queueDocs=" + queueDocs);
    for (int i = 0; i < privatedocs.size(); i++) {
        EDoc eDoc = privatedocs.get(i);
        String docIdStr = eDoc.getDocId();
        Integer docId = -1;
        if (docIdStr != null && !docIdStr.equalsIgnoreCase("")) {
            docId = Integer.parseInt(docIdStr);
        }
        List<QueueDocumentLink> queueDocLinkList = queueDocumentLinkDAO.getQueueFromDocument(docId);

        for (QueueDocumentLink qdl : queueDocLinkList) {
            Integer qidInt = qdl.getQueueId();
            String qidStr = qidInt.toString();
            logger.debug("qid in link=" + qidStr);
            if (queueDocs.containsKey(qidStr)) {
                List<EDoc> EDocs = new ArrayList<EDoc>();
                EDocs = (List<EDoc>) queueDocs.get(qidStr);
                EDocs.add(eDoc);
                logger.debug("add edoc id to queue id=" + eDoc.getDocId());
                queueDocs.put(qidStr, EDocs);
            }
        }
    }

    // remove queues which has no docs linked to
    Enumeration queueIds = queueDocs.keys();
    while (queueIds.hasMoreElements()) {
        String queueId = (String) queueIds.nextElement();
        List<EDoc> eDocs = new ArrayList<EDoc>();
        eDocs = (List<EDoc>) queueDocs.get(queueId);
        if (eDocs == null || eDocs.size() == 0) {
            queueDocs.remove(queueId);
            logger.debug("removed queueId=" + queueId);
        }
    }

    request.getSession().setAttribute("queueDocs", queueDocs);
}

From source file:org.kepler.kar.KARBuilder.java

public void generateKAR(TableauFrame tableauFrame, String overrideModDeps) throws IllegalActionException {
    if (isDebugging)
        log.debug("generateKAR()");

    if (_karLSID == null) {
        try {/* w w  w.ja  v  a  2s  .  c  om*/
            _karLSID = LSIDGenerator.getInstance().getNewLSID();
        } catch (Exception e) {
            log.error("could not generate new LSID for KAR: " + e.getMessage());
            e.printStackTrace();
        }
    }

    try {

        // Get KAREntries for the Save Initiator List
        Hashtable<KAREntry, InputStream> initiatorEntries = handleInitiatorList();
        addEntriesToPrivateItems(initiatorEntries);

        int pass = 1;

        // Loop through KAR Entry handlers until no more KAREntry objects
        // are returned
        Vector<KeplerLSID> previousPassEntryLSIDs = getKAREntryLSIDs(initiatorEntries);
        if (isDebugging)
            log.debug("Pass " + pass + " entries: " + previousPassEntryLSIDs.toString());
        while (previousPassEntryLSIDs.size() > 0) {
            pass++;

            // Get the KAREntries from all of the handlers
            Hashtable<KAREntry, InputStream> entries = queryKAREntryHandlers(previousPassEntryLSIDs,
                    tableauFrame);
            if (entries != null) {

                previousPassEntryLSIDs.removeAllElements();
                if (isDebugging)
                    log.debug("Pass " + pass + " entries: ");
                Vector<KeplerLSID> repeats = new Vector<KeplerLSID>();
                for (KAREntry karEntryKey : entries.keySet()) {
                    String entryName = karEntryKey.getName();
                    String entryType = karEntryKey.getType();
                    KeplerLSID entryLSID = karEntryKey.getLSID();
                    if (isDebugging)
                        log.debug(entryName + "  " + entryLSID + "  " + entryType);
                    if (_karItemLSIDs.contains(entryLSID)) {
                        // TODO make sure existing Entry Handlers do not produce repeated LSIDs.
                        // This should never happen.
                        System.out.println("KARBuilder generateKAR() Trying to add " + entryName + " with "
                                + "type:" + entryType + " but an entry with lsid:" + entryLSID + " has already "
                                + "been added to KAR. Will NOT add this entry.");
                        repeats.add(entryLSID);
                    } else if (_karItemNames.contains(entryName)) {
                        // TODO make sure existing Entry Handlers do not produce repeated LSIDs.
                        // This should never happen.
                        System.out.println("KARBuilder generateKAR() An entry with entryName" + entryName
                                + " has already been added to KAR. Will NOT add this entry with lsid:"
                                + entryLSID);
                        repeats.add(entryLSID);
                    } else {
                        previousPassEntryLSIDs.add(entryLSID);
                    }
                }
                // A kludge to protect against entry handlers returning entries that have already been added
                for (KeplerLSID repeatedLSID : repeats) {
                    for (KAREntry ke : entries.keySet()) {
                        if (ke.getLSID().equals(repeatedLSID)) {
                            entries.remove(ke);
                            if (isDebugging)
                                log.debug("Removed " + repeatedLSID + " from pass " + pass + " entries");
                            break;
                        }
                    }
                }

                addEntriesToPrivateItems(entries);
            }
        }

        prepareManifest(overrideModDeps);

        writeKARFile();

    } catch (Exception e) {
        throw new IllegalActionException("Error building the KAR file: " + e.getMessage());
    }

}

From source file:oscar.dms.actions.DmsInboxManageAction.java

private void setProviderDocsInSession(ArrayList<EDoc> privatedocs, HttpServletRequest request) {
    ArrayList<Hashtable<String, String>> providers = ProviderData.getProviderListOfAllTypes();
    Hashtable<String, List<EDoc>> providerDocs = new Hashtable<String, List<EDoc>>();
    for (int i = 0; i < providers.size(); i++) {
        Hashtable<String, String> ht = providers.get(i);
        List<EDoc> EDocs = new ArrayList<EDoc>();
        String providerNo = ht.get("providerNo");
        providerDocs.put(providerNo, EDocs);
    }//from w  ww.  j a va  2 s. c o m
    for (int i = 0; i < privatedocs.size(); i++) {
        EDoc eDoc = privatedocs.get(i);
        List<String> providerList = new ArrayList<String>();
        String createrId = eDoc.getCreatorId();
        if (providerDocs.containsKey(createrId)) {
            List<EDoc> EDocs = new ArrayList<EDoc>();
            EDocs = providerDocs.get(createrId);
            EDocs.add(eDoc);
            providerDocs.put(createrId, EDocs);
        }
        String docId = eDoc.getDocId();
        providerList.add(createrId);

        List<ProviderInboxItem> routeList = providerInboxRoutingDAO
                .getProvidersWithRoutingForDocument(LabResultData.DOCUMENT, docId);
        for (ProviderInboxItem pii : routeList) {
            String routingPId = pii.getProviderNo();

            if (!routingPId.equals(createrId) && providerDocs.containsKey(routingPId)) {
                List<EDoc> EDocs = new ArrayList<EDoc>();
                EDocs = providerDocs.get(routingPId);
                EDocs.add(eDoc);
                providerDocs.put(routingPId, EDocs);
            }
        }
    }
    // remove providers which has no docs linked to
    Enumeration<String> keys = providerDocs.keys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();

        List<EDoc> EDocs = new ArrayList<EDoc>();
        EDocs = providerDocs.get(key);
        if (EDocs == null || EDocs.size() == 0) {
            providerDocs.remove(key);

        }
    }

    request.getSession().setAttribute("providerDocs", providerDocs);
}