List of usage examples for java.util ArrayList clear
public void clear()
From source file:com.jp.miaulavirtual.DisplayMessageActivity.java
@SuppressLint("NewApi") @Override//w w w. ja va 2s. c o m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_message); Log.d("Lifecycle8", "In onCreate()"); // Make sure we're running on Honeycomb or higher to use ActionBar APIs // creating connection detector class instance cd = new ConnectionDetector(getApplicationContext()); // general context mycontext = this; // Preferences SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mycontext); // panel panel = prefs.getString("panel", "2"); // Get the onRetainNonConfigurationInstance() final ArrayList<Object[]> passData = (ArrayList<Object[]>) getLastNonConfigurationInstance(); try { if (passData != null) { // onUrl and onName to ArrayList onData = new ArrayList<String[]>(Arrays.asList((String[][]) passData.get(3))); // hierarchical urls passData.remove(3); // cookies to Map cookies = new HashMap<String, String>(); for (int i = 0; i < passData.get(3).length; i++) { cookies.put(passData.get(3)[i].toString(), passData.get(4)[i].toString()); } scookie = cookies.toString(); // IMPORTANT! passData.remove(3); passData.remove(3); // names int length = passData.get(0).length; names = new String[length]; System.arraycopy(passData.get(0), 0, names, 0, length); passData.remove(0); // urls length = passData.get(0).length; urls = new String[length]; System.arraycopy(passData.get(0), 0, urls, 0, length); passData.remove(0); // types length = passData.get(0).length; types = new String[length]; System.arraycopy(passData.get(0), 0, types, 0, length); passData.clear(); // Update de subtitle headerTitle = (TextView) findViewById(R.id.LblSubTitulo); // Ttulo Header headerTitle.setTextColor(getResources().getColor(R.color.list_title)); headerTitle.setTypeface(null, 1); headerTitle.setText(onData.get(onData.size() - 1)[1]); // retrieve the same View before change orientation lstDocs = (ListView) findViewById(R.id.LstDocs); // Declaramos la lista lstAdapter = new ListAdapter(this, names, types); lstDocs.setAdapter(lstAdapter); // Declaramos nuestra propia clase adaptador como adaptador } else { // cookies scookie = prefs.getString("cookies", ""); //Existe cookie? if (scookie != "") { cookies = toMap(scookie); //Si existe cookie la pasamos a MAP } String[] theData = new String[2]; theData[0] = "/dotlrn/?page_num=" + panel; theData[1] = "Documentos"; onData.add(theData); // Actualizamos nombre de LblSubTitulo headerTitle = (TextView) findViewById(R.id.LblSubTitulo); // Ttulo Header headerTitle.setTextColor(getResources().getColor(R.color.list_title)); headerTitle.setTypeface(null, 1); headerTitle.setText(theData[1]); //Recibimos primera llamada al crear la Actividad Intent intent = getIntent(); // Datos de usuario user = intent.getStringExtra("user"); pass = intent.getStringExtra("pass"); // Recibimos datos HOME String response = intent.getStringExtra("out"); Document doc = Jsoup.parse(response); Elements elements = null; try { elements = scrap2(doc); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } asigsToArray(elements, true, comunidades); urlsToArray(elements, true, comunidades); typeToArray(elements, true, comunidades, urls.length); // Aadimos el Array con los TYPES al ArrayList - [2] lstDocs = (ListView) findViewById(R.id.LstDocs); // Declaramos la lista lstAdapter = new ListAdapter(this, names, types); lstDocs.setAdapter(lstAdapter); // Declaramos nuestra propia clase adaptador como adaptador } lstDocs.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long id) { //Al clicar X item de la lista isInternetPresent = cd.isConnectingToInternet(); if (isInternetPresent) { if (!(types[position].toString().equals("0")) && !(types[position].toString().equals("1")) && !(types[position].toString().equals("6"))) { clickedPosition = position; Log.d("TIPO", "DOCUMENTO"); // ProgressDialog (salta para mostrar el proceso del archivo descargndose) dialog = new ProgressDialog(mycontext); // Servicio para la descarga del archivo url = urls[clickedPosition].toString(); String url_back = onData.get(onData.size() - 2)[0]; new docDownload(url_back).execute(); } else { if ((onData.get(onData.size() - 1)[0].equalsIgnoreCase(("/dotlrn/?page_num=" + panel))) && !comunidades) { isTheHome = true; } else { isTheHome = false; } //Cuando se hace click en una opcin de la lista, queremos borrar todo mientras carga, includo el ttulo header headerTitle.setText(null); //Copia de FIRST que puede ser borrada lstAdapter.clearData(); // Refrescamos View lstAdapter.notifyDataSetChanged(); lstDocs.setDividerHeight(0); clickedPosition = position; Log.d("URL", onData.get(onData.size() - 1)[0]); url = urls[clickedPosition].toString(); Log.d("URL2", urls[clickedPosition].toString()); new urlConnect().execute(); } } else { Toast.makeText(getBaseContext(), getString(R.string.no_internet), Toast.LENGTH_LONG).show(); } } }); } catch (ArrayIndexOutOfBoundsException e) { TextView tv = (TextView) findViewById(R.id.panel_error); tv.setVisibility(0); setRestrictedOrientation(); Toast.makeText(getBaseContext(), getString(R.string.panel_error2), Toast.LENGTH_LONG).show(); } catch (IndexOutOfBoundsException e) { TextView tv = (TextView) findViewById(R.id.panel_error); tv.setVisibility(0); setRestrictedOrientation(); Toast.makeText(getBaseContext(), getString(R.string.panel_error2), Toast.LENGTH_LONG).show(); } catch (IllegalArgumentException e) { TextView tv = (TextView) findViewById(R.id.panel_error); tv.setVisibility(0); setRestrictedOrientation(); Toast.makeText(getBaseContext(), getString(R.string.panel_error2), Toast.LENGTH_LONG).show(); } }
From source file:com.android.contacts.ContactSaveService.java
private void joinSeveralContacts(Intent intent) { final long[] contactIds = intent.getLongArrayExtra(EXTRA_CONTACT_IDS); final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_RESULT_RECEIVER); // Load raw contact IDs for all contacts involved. final long rawContactIds[] = getRawContactIdsForAggregation(contactIds); final long[][] separatedRawContactIds = getSeparatedRawContactIds(contactIds); if (rawContactIds == null) { Log.e(TAG, "Invalid arguments for joinSeveralContacts request"); if (receiver != null) { receiver.send(BAD_ARGUMENTS, new Bundle()); }/* w w w .j ava 2 s. c o m*/ return; } // For each pair of raw contacts, insert an aggregation exception final ContentResolver resolver = getContentResolver(); // The maximum number of operations per batch (aka yield point) is 500. See b/22480225 final int batchSize = MAX_CONTACTS_PROVIDER_BATCH_SIZE; final ArrayList<ContentProviderOperation> operations = new ArrayList<>(batchSize); for (int i = 0; i < rawContactIds.length; i++) { for (int j = 0; j < rawContactIds.length; j++) { if (i != j) { buildJoinContactDiff(operations, rawContactIds[i], rawContactIds[j]); } // Before we get to 500 we need to flush the operations list if (operations.size() > 0 && operations.size() % batchSize == 0) { if (!applyOperations(resolver, operations)) { if (receiver != null) { receiver.send(CP2_ERROR, new Bundle()); } return; } operations.clear(); } } } if (operations.size() > 0 && !applyOperations(resolver, operations)) { if (receiver != null) { receiver.send(CP2_ERROR, new Bundle()); } return; } final String name = queryNameOfLinkedContacts(contactIds); if (name != null) { if (receiver != null) { final Bundle result = new Bundle(); result.putSerializable(EXTRA_RAW_CONTACT_IDS, separatedRawContactIds); result.putString(EXTRA_DISPLAY_NAME, name); receiver.send(CONTACTS_LINKED, result); } else { if (TextUtils.isEmpty(name)) { showToast(R.string.contactsJoinedMessage); } else { showToast(R.string.contactsJoinedNamedMessage, name); } } LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(BROADCAST_LINK_COMPLETE)); } else { if (receiver != null) { receiver.send(CP2_ERROR, new Bundle()); } showToast(R.string.contactJoinErrorToast); } }
From source file:com.mirth.connect.model.util.ImportConverter.java
/** Convert soap connector and destination settings */ private static void convertSoapConnectorFor2_0(Document document, Element connectorRoot) throws Exception { // convert SOAP reader and SOAP writer to the new formats Node transportNode = getConnectorTransportNode(connectorRoot); String transportNameText = transportNode.getTextContent(); String attribute = ""; String value = ""; Element propertiesElement = getPropertiesElement(connectorRoot); // Default Properties Map<String, String> propertyDefaults = new HashMap<String, String>(); // Properties to be added if missing, or reset if present Map<String, String> propertyChanges = new HashMap<String, String>(); // logic to deal with SOAP listener settings if (transportNameText.equals("SOAP Listener")) { NodeList properties = connectorRoot.getElementsByTagName("property"); // set defaults propertyDefaults.put("DataType", "Web Service Listener"); propertyDefaults.put("host", "0.0.0.0"); propertyDefaults.put("port", "8081"); propertyDefaults.put("receiverClassName", "com.mirth.connect.connectors.ws.DefaultAcceptMessage"); propertyDefaults.put("receiverServiceName", "Mirth"); propertyDefaults.put("receiverResponseValue", "None"); ObjectXMLSerializer serializer = ObjectXMLSerializer.getInstance(); propertyDefaults.put("receiverUsernames", serializer.serialize(new ArrayList<String>())); propertyDefaults.put("receiverPasswords", serializer.serialize(new ArrayList<String>())); // rename properties for (int i = 0; i < properties.getLength(); i++) { // get the current attribute and current value attribute = properties.item(i).getAttributes().item(0).getTextContent(); value = properties.item(i).getTextContent(); // Now rename attributes if (attribute.equals("externalAddress")) { propertyChanges.put("host", value); }/*from w w w. j a v a 2 s.c o m*/ if (attribute.equals("responseValue")) { propertyChanges.put("receiverResponseValue", value); } if (attribute.equals("serviceName")) { propertyChanges.put("receiverServiceName", value); } } // set changes propertyChanges.put("DataType", "Web Service Listener"); // set new name of transport node transportNode.setTextContent("Web Service Listener"); // update properties updateProperties(document, propertiesElement, propertyDefaults, propertyChanges); } else if (transportNameText.equals("SOAP Sender")) { // get properties NodeList properties = connectorRoot.getElementsByTagName("property"); // disable connector document.getElementsByTagName("enabled").item(0).setTextContent("false"); // set defaults propertyDefaults.put("DataType", "Web Service Sender"); propertyDefaults.put("host", ""); propertyDefaults.put("dispatcherWsdlCacheId", ""); propertyDefaults.put("dispatcherWsdlUrl", ""); propertyDefaults.put("dispatcherService", ""); propertyDefaults.put("dispatcherPort", ""); propertyDefaults.put("dispatcherOperation", "Press Get Operations"); propertyDefaults.put("dispatcherUseAuthentication", "0"); propertyDefaults.put("dispatcherUsername", ""); propertyDefaults.put("dispatcherPassword", ""); propertyDefaults.put("dispatcherEnvelope", ""); propertyDefaults.put("dispatcherOneWay", "0"); propertyDefaults.put("dispatcherUseMtom", "0"); propertyDefaults.put("dispatcherReplyChannelId", "sink"); ObjectXMLSerializer serializer = ObjectXMLSerializer.getInstance(); ArrayList<String> defaultOperations = new ArrayList<String>(); defaultOperations.add("Press Get Operations"); propertyDefaults.put("dispatcherWsdlOperations", serializer.serialize(defaultOperations)); propertyDefaults.put("dispatcherAttachmentNames", serializer.serialize(new ArrayList<String>())); propertyDefaults.put("dispatcherAttachmentContents", serializer.serialize(new ArrayList<String>())); propertyDefaults.put("dispatcherAttachmentTypes", serializer.serialize(new ArrayList<String>())); // Add new queue property propertyDefaults.put("queuePollInterval", "200"); for (int i = 0; i < properties.getLength(); i++) { // get the current attribute and current value attribute = properties.item(i).getAttributes().item(0).getTextContent(); value = properties.item(i).getTextContent(); // Now rename attributes if (attribute.equals("attachmentNames")) { propertyChanges.put("dispatcherAttachmentNames", value); if (StringUtils.isNotBlank(value) && !value.trim().equals("<list/>")) { propertyChanges.put("dispatcherUseMtom", "1"); } } if (attribute.equals("wsdlUrl")) { propertyChanges.put("dispatcherWsdlUrl", value); } if (attribute.equals("soapActionURI")) { propertyChanges.put("dispatcherSoapAction", value); } if (attribute.equals("method")) { propertyChanges.put("dispatcherOperation", value); if (StringUtils.isNotBlank(value)) { defaultOperations.clear(); defaultOperations.add(value); propertyChanges.put("dispatcherWsdlOperations", serializer.serialize(defaultOperations)); } } if (attribute.equals("replyChannelId")) { propertyChanges.put("dispatcherReplyChannelId", value); } if (attribute.equals("attachmentContents")) { propertyChanges.put("dispatcherAttachmentContents", value); } if (attribute.equals("soapEnvelope")) { propertyChanges.put("dispatcherEnvelope", value); } if (attribute.equals("attachmentTypes")) { propertyChanges.put("dispatcherAttachmentTypes", value); } } propertyChanges.put("DataType", "Web Service Sender"); // set new name of transport node transportNode.setTextContent("Web Service Sender"); updateProperties(document, propertiesElement, propertyDefaults, propertyChanges); } }
From source file:op.care.values.PnlValues.java
private JPanel getMenu(final ResValue resValue) { final ResValueTypes vtype = resValue.getType(); JPanel pnlMenu = new JPanel(new VerticalLayout()); boolean doesNotBelongToResInfos = ResInfoTools.getInfosFor(resValue).isEmpty(); if (doesNotBelongToResInfos && OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { /***//from w ww . j a v a 2s . c o m * _____ _ _ _ * | ____|__| (_) |_ * | _| / _` | | __| * | |__| (_| | | |_ * |_____\__,_|_|\__| * */ final JButton btnEdit = GUITools.createHyperlinkButton("nursingrecords.vitalparameters.btnEdit.tooltip", SYSConst.icon22edit3, null); btnEdit.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEdit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgValue(resValue.clone(), DlgValue.MODE_EDIT, new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); final ResValue newValue = em.merge((ResValue) o); ResValue oldValue = em.merge(resValue); em.lock(oldValue, LockModeType.OPTIMISTIC); newValue.setReplacementFor(oldValue); for (SYSVAL2FILE oldAssignment : oldValue.getAttachedFilesConnections()) { em.remove(oldAssignment); } oldValue.getAttachedFilesConnections().clear(); for (SYSVAL2PROCESS oldAssignment : oldValue.getAttachedProcessConnections()) { em.remove(oldAssignment); } oldValue.getAttachedProcessConnections().clear(); oldValue.setEditedBy(em.merge(OPDE.getLogin().getUser())); oldValue.setEditDate(new Date()); oldValue.setReplacedBy(newValue); em.getTransaction().commit(); DateTime dt = new DateTime(newValue.getPit()); final String keyType = vtype.getID() + ".xtypes"; final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(oldValue); mapType2Values.get(key).add(newValue); Collections.sort(mapType2Values.get(key)); } createCP4Year(vtype, dt.getYear()); try { synchronized (cpMap) { cpMap.get(keyType).setCollapsed(false); cpMap.get(key).setCollapsed(false); } } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnEdit.setEnabled(!resValue.isObsolete()); pnlMenu.add(btnEdit); /*** * ____ _ _ * | _ \ ___| | ___| |_ ___ * | | | |/ _ \ |/ _ \ __/ _ \ * | |_| | __/ | __/ || __/ * |____/ \___|_|\___|\__\___| * */ final JButton btnDelete = GUITools.createHyperlinkButton( "nursingrecords.vitalparameters.btnDelete.tooltip", SYSConst.icon22delete, null); btnDelete.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDelete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo(SYSTools.xx("misc.questions.delete1") + "<br/><i>" + DateFormat.getDateTimeInstance().format(resValue.getPit()) + "</i><br/>" + SYSTools.xx("misc.questions.delete2"), SYSConst.icon48delete, new Closure() { @Override public void execute(Object o) { if (o.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); ResValue myValue = em.merge(resValue); myValue.setDeletedBy(em.merge(OPDE.getLogin().getUser())); for (SYSVAL2FILE file : myValue.getAttachedFilesConnections()) { em.remove(file); } myValue.getAttachedFilesConnections().clear(); // Vorgangszuordnungen entfernen for (SYSVAL2PROCESS connObj : myValue.getAttachedProcessConnections()) { em.remove(connObj); } myValue.getAttachedProcessConnections().clear(); myValue.getAttachedProcesses().clear(); em.getTransaction().commit(); DateTime dt = new DateTime(myValue.getPit()); final String keyType = vtype.getID() + ".xtypes"; final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(myValue); Collections.sort(mapType2Values.get(key)); } createCP4Year(vtype, dt.getYear()); try { synchronized (cpMap) { cpMap.get(keyType).setCollapsed(false); cpMap.get(key).setCollapsed(false); } } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnDelete.setEnabled(!resValue.isObsolete()); pnlMenu.add(btnDelete); pnlMenu.add(new JSeparator()); /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = GUITools.createHyperlinkButton("misc.btnfiles.tooltip", SYSConst.icon22attach, null); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgFiles(resValue, new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final ResValue myValue = em.find(ResValue.class, resValue.getID()); em.close(); DateTime dt = new DateTime(myValue.getPit()); final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(myValue); Collections.sort(mapType2Values.get(key)); } buildPanel(); } }); } }); btnFiles.setEnabled(!resValue.isObsolete() && OPDE.isFTPworking()); pnlMenu.add(btnFiles); /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = GUITools.createHyperlinkButton("misc.btnprocess.tooltip", SYSConst.icon22link, null); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(resValue, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); ResValue myValue = em.merge(resValue); em.lock(myValue, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSVAL2PROCESS> attached = new ArrayList<SYSVAL2PROCESS>( resValue.getAttachedProcessConnections()); for (SYSVAL2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections().remove(linkObject); linkObject.getResValue().getAttachedProcessConnections().remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess.getElements(); if (!listElements.contains(myValue)) { QProcess myQProcess = em.merge(qProcess); SYSVAL2PROCESS myLinkObject = em .merge(new SYSVAL2PROCESS(myQProcess, myValue)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedResValueConnections().add(myLinkObject); myValue.getAttachedProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); DateTime dt = new DateTime(myValue.getPit()); final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(myValue); Collections.sort(mapType2Values.get(key)); } createCP4Year(vtype, dt.getYear()); buildPanel(); //GUITools.flashBackground(contentmap.get(keyMonth), Color.YELLOW, 2); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); btnProcess.setEnabled(!resValue.isObsolete()); pnlMenu.add(btnProcess); } return pnlMenu; }
From source file:com.ubercab.client.feature.notification.handler.TripNotificationHandler.java
private boolean populateNotification(NotificationCompat.Builder paramBuilder, TripNotificationData paramTripNotificationData) { ArrayList localArrayList = new ArrayList(); String str1 = getContentText(paramTripNotificationData, false); String str2 = getContentText(paramTripNotificationData, true); Context localContext = getContext(); int i = paramTripNotificationData.getMessageIdentifier(); String str3 = paramTripNotificationData.getTripStatus(); int j = -1; switch (str3.hashCode()) { default:// www. j a v a 2 s .com case 1065961768: case -2146525273: case -734206867: case -1325796731: case 2130210069: } while (true) switch (j) { default: return false; if (str3.equals("dispatching")) { j = 0; continue; if (str3.equals("accepted")) { j = 1; continue; if (str3.equals("arrived")) { j = 2; continue; if (str3.equals("on_trip")) { j = 3; continue; if (str3.equals("redispatching")) j = 4; } } } } break; case 0: case 1: case 2: case 3: case 4: } String str7 = localContext.getString(2131558959); localArrayList.add(str7); paramBuilder.setLargeIcon(this.mPainter.loadMonoBitmap( paramTripNotificationData.getVehicleViewMonoImageUrl(), this.mPainter.getIconSizeLarge(), true)); paramBuilder.setContentTitle(str7); paramBuilder.setProgress(0, 0, true); addActionCancel(paramBuilder, i); if (paramTripNotificationData.getSource() == NotificationData.Source.PING) localArrayList.clear(); boolean bool = this.mPreferences.isFlagNotificationsClientsEnabled(); if (bool) { List localList = paramTripNotificationData.getAcceptedFareSplitClientsSince(this.mLastData); if ((localList != null) && (!localList.isEmpty())) localArrayList.add(localContext.getString(2131558965, new Object[] { Joiner.on(", ").join(Iterables.transform(localList, new Function() { public String apply( TripNotificationData.FareSplitClient paramAnonymousFareSplitClient) { return paramAnonymousFareSplitClient.getName(); } })) })); } if (!localArrayList.isEmpty()) paramBuilder.setTicker(Joiner.on("\n").join(localArrayList)); int k; if ((str3.equals("accepted")) || (str3.equals("arrived"))) { k = 1; label435: if ((!bool) || (!paramTripNotificationData.hasFareSplit()) || (!paramTripNotificationData.isMaster())) break label765; paramBuilder.setContentText(getContentTextFareSplit(paramTripNotificationData)); paramBuilder.setStyle(buildStyleInbox(paramBuilder, paramTripNotificationData, str2)); } while (true) { return true; String str6 = localContext.getString(2131558952); if (paramTripNotificationData.getSurgeMultiplier() > 1.0F) { Object[] arrayOfObject2 = new Object[1]; arrayOfObject2[0] = Float.valueOf(paramTripNotificationData.getSurgeMultiplier()); localArrayList.add(localContext.getString(2131558953, arrayOfObject2)); } while (true) { paramBuilder.setLargeIcon(this.mPainter.drawEtaBitmap(paramTripNotificationData.getTripEta())); paramBuilder.setContentTitle(str6); addTripActions(paramBuilder, paramTripNotificationData, i); break; localArrayList.add(str6); } String str5 = localContext.getString(2131558954); localArrayList.add(str5); paramBuilder.setLargeIcon(this.mPainter.drawEtaBitmap(paramTripNotificationData.getTripEta())); paramBuilder.setContentTitle(str5); addTripActions(paramBuilder, paramTripNotificationData, i); break; paramBuilder.setContentTitle(localContext.getString(2131558964)); addTripActions(paramBuilder, paramTripNotificationData, i); break; Object[] arrayOfObject1 = new Object[1]; arrayOfObject1[0] = paramTripNotificationData.getDriverName(); String str4 = localContext.getString(2131558971, arrayOfObject1); localArrayList.add(localContext.getString(2131558970, new Object[] { str4, str1 })); paramBuilder.setLargeIcon( this.mPainter.loadMonoBitmap(paramTripNotificationData.getVehicleViewMonoImageUrl(), this.mPainter.getIconSizeLarge(), true)); paramBuilder.setContentTitle(str4); paramBuilder.setProgress(0, 0, true); addActionCancel(paramBuilder, i); break; k = 0; break label435; label765: if (k != 0) { paramBuilder.setContentText(str1); paramBuilder.setStyle(buildStyleBigPicture(paramBuilder, paramTripNotificationData, str2)); } else { paramBuilder.setContentText(str1); } } }
From source file:com.clustercontrol.calendar.util.CalendarUtil.java
/** * ?????CalendarDetailInfo??retDetailList???<br> * ??true???false???<br>//from w ww.j a v a 2 s .com * * @param info * @param date * @return */ public static boolean getCalendarRunDetailInfo(CalendarInfo info, Date date, ArrayList<CalendarDetailInfo> retDetailList) { if (info == null) { return true; // ????????true } m_log.trace("Valid_START_Time : " + new Date(info.getValidTimeFrom())); m_log.trace("Valid_END_Time : " + new Date(info.getValidTimeTo())); m_log.trace("This_Time : " + date); Long timeFrom = info.getValidTimeFrom(); Long timeTo = info.getValidTimeTo(); // ???false if (date.getTime() < timeFrom || timeTo < date.getTime()) { return false; } for (CalendarDetailInfo detailInfo3 : info.getCalendarDetailList()) { // ???hit?????? if (isRunByDetailDateTime(detailInfo3, date)) { m_log.trace("???hit?? description:" + detailInfo3.getDescription() + ", operationFlg:" + detailInfo3.isOperateFlg()); m_log.trace("CalendarDetailInfo.toString = " + detailInfo3.toString()); retDetailList.add(detailInfo3); if (detailInfo3.isOperateFlg()) { return true; } else { return false; } } if (detailInfo3.isSubstituteFlg() && detailInfo3.isOperateFlg()) { m_log.trace("????? description:" + detailInfo3.getDescription()); boolean findhikadou = false; for (CalendarDetailInfo detailInfo : info.getCalendarDetailList()) { if (!detailInfo.isSubstituteFlg()) { continue; } for (int limit = 1; limit <= detailInfo.getSubstituteLimit(); limit++) { Date substituteDate = new Date(date.getTime() - (parseDate(detailInfo.getSubstituteTime()) + HinemosTime.getTimeZoneOffset()) * limit); m_log.trace("SubstituteDate:" + substituteDate + ", description:" + detailInfo.getDescription() + ", limit:" + limit); for (CalendarDetailInfo detailInfo2 : info.getCalendarDetailList()) { m_log.trace("CalendarDetailInfo.toString = " + detailInfo2.toString()); if (detailInfo.equals(detailInfo2)) { if (!findhikadou) { m_log.trace( "????????????return false."); return false; } else { if (!isRunByDetailDateTime(detailInfo2, substituteDate)) { m_log.trace( "??????????????????break."); retDetailList.clear(); findhikadou = false; break; } else { if (substituteDate.getTime() < timeFrom || timeTo < substituteDate.getTime()) { m_log.trace( "??????hit????? return false."); return false; } m_log.trace( "??????hit???? return true."); retDetailList.add(detailInfo2); return true; } } } if (isRunByDetailDateTime(detailInfo2, substituteDate) && !detailInfo2.isOperateFlg()) { m_log.trace( "??????????...?"); findhikadou = true; } } } } } } m_log.trace("?hit????? return false. calendarId:" + info.getCalendarId()); return false; }
From source file:op.care.values.PnlValues.java
private JPanel createContentPanel4Year(final ResValueTypes vtype, final int year) { final String keyYears = vtype.getID() + ".xtypes." + Integer.toString(year) + ".year"; java.util.List<ResValue> myValues; synchronized (mapType2Values) { if (!mapType2Values.containsKey(keyYears)) { mapType2Values.put(keyYears, ResValueTools.getResValues(resident, vtype, year)); }/* w w w .j a va 2 s. c o m*/ if (mapType2Values.get(keyYears).isEmpty()) { JLabel lbl = new JLabel(SYSTools.xx("misc.msg.novalue")); JPanel pnl = new JPanel(); pnl.add(lbl); return pnl; } myValues = mapType2Values.get(keyYears); } JPanel pnlYear = new JPanel(new VerticalLayout()); pnlYear.setOpaque(false); for (final ResValue resValue : myValues) { String title = "<html><table border=\"0\">" + "<tr>" + "<td width=\"200\" align=\"left\">" + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT).format(resValue.getPit()) + " [" + resValue.getID() + "]</td>" + "<td width=\"340\" align=\"left\">" + ResValueTools.getValueAsHTML(resValue) + "</td>" + "<td width=\"200\" align=\"left\">" + resValue.getUser().getFullname() + "</td>" + "</tr>" + "</table>" + "</html>"; final DefaultCPTitle pnlTitle = new DefaultCPTitle(title, null); pnlTitle.getMain().setBackground(GUITools.blend(vtype.getColor(), Color.WHITE, 0.1f)); pnlTitle.getMain().setOpaque(true); if (resValue.isObsolete()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22eraser)); } if (resValue.isReplacement()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22edited)); } if (!resValue.getText().trim().isEmpty()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22info)); } if (pnlTitle.getAdditionalIconPanel().getComponentCount() > 0) { pnlTitle.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { GUITools.showPopup( GUITools.getHTMLPopup(pnlTitle.getButton(), ResValueTools.getInfoAsHTML(resValue)), SwingConstants.NORTH); } }); } if (!resValue.getAttachedFilesConnections().isEmpty()) { /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = new JButton( Integer.toString(resValue.getAttachedFilesConnections().size()), SYSConst.icon22greenStar); btnFiles.setToolTipText(SYSTools.xx("misc.btnfiles.tooltip")); btnFiles.setForeground(Color.BLUE); btnFiles.setHorizontalTextPosition(SwingUtilities.CENTER); btnFiles.setFont(SYSConst.ARIAL18BOLD); btnFiles.setPressedIcon(SYSConst.icon22Pressed); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.setAlignmentY(Component.TOP_ALIGNMENT); btnFiles.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnFiles.setContentAreaFilled(false); btnFiles.setBorder(null); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgFiles(resValue, new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final ResValue myValue = em.find(ResValue.class, resValue.getID()); em.close(); synchronized (mapType2Values) { mapType2Values.get(keyYears).remove(resValue); mapType2Values.get(keyYears).add(myValue); Collections.sort(mapType2Values.get(keyYears)); } createCP4Year(vtype, year); buildPanel(); } }); } }); btnFiles.setEnabled(OPDE.isFTPworking()); pnlTitle.getRight().add(btnFiles); } if (!resValue.getAttachedProcessConnections().isEmpty()) { /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = new JButton( Integer.toString(resValue.getAttachedProcessConnections().size()), SYSConst.icon22redStar); btnProcess.setToolTipText(SYSTools.xx("misc.btnprocess.tooltip")); btnProcess.setForeground(Color.YELLOW); btnProcess.setHorizontalTextPosition(SwingUtilities.CENTER); btnProcess.setFont(SYSConst.ARIAL18BOLD); btnProcess.setPressedIcon(SYSConst.icon22Pressed); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.setAlignmentY(Component.TOP_ALIGNMENT); btnProcess.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnProcess.setContentAreaFilled(false); btnProcess.setBorder(null); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(resValue, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); ResValue myValue = em.merge(resValue); em.lock(myValue, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSVAL2PROCESS> attached = new ArrayList<SYSVAL2PROCESS>( resValue.getAttachedProcessConnections()); for (SYSVAL2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections() .remove(linkObject); linkObject.getResValue().getAttachedProcessConnections() .remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess.getElements(); if (!listElements.contains(myValue)) { QProcess myQProcess = em.merge(qProcess); SYSVAL2PROCESS myLinkObject = em .merge(new SYSVAL2PROCESS(myQProcess, myValue)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedResValueConnections().add(myLinkObject); myValue.getAttachedProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); synchronized (mapType2Values) { mapType2Values.get(keyYears).remove(resValue); mapType2Values.get(keyYears).add(myValue); Collections.sort(mapType2Values.get(keyYears)); } createCP4Year(vtype, year); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); btnProcess.setEnabled(OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)); pnlTitle.getRight().add(btnProcess); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ final JButton btnMenu = new JButton(SYSConst.icon22menu); btnMenu.setPressedIcon(SYSConst.icon22Pressed); btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMenu.setAlignmentY(Component.TOP_ALIGNMENT); btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMenu.setContentAreaFilled(false); btnMenu.setBorder(null); btnMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnMenu); popup.removeExcludedComponent(btnMenu); JPanel pnl = getMenu(resValue); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnMenu.setEnabled(!resValue.isObsolete()); pnlTitle.getRight().add(btnMenu); pnlYear.add(pnlTitle.getMain()); synchronized (linemap) { linemap.put(resValue, pnlTitle.getMain()); } } return pnlYear; }
From source file:exm.stc.frontend.ASTWalker.java
/** * * @param context/*from w w w. ja v a2 s . co m*/ * @param branchVUs * The variable usage info for all branches * @param writtenVars * All vars that might be written are added here * @throws UserException * @throws UndefinedTypeException */ private void summariseBranchVariableUsage(Context context, List<VariableUsageInfo> branchVUs, List<Var> writtenVars) throws UndefinedTypeException, UserException { for (Var v : context.getVisibleVariables()) { // see if it is an array that might be modified if (Types.isArray(v)) { for (VariableUsageInfo bvu : branchVUs) { VInfo vi = bvu.lookupVariableInfo(v.name()); if (vi != null && vi.isAssigned() != Ternary.FALSE) { writtenVars.add(v); break; } } } else if (Types.isStruct(v)) { // Need to find arrays inside structs ArrayList<Pair<Var, VInfo>> arrs = new ArrayList<Pair<Var, VInfo>>(); // This procedure might add the same array multiple times, // so use a set to avoid duplicates HashSet<Var> alreadyFound = new HashSet<Var>(); for (VariableUsageInfo bvu : branchVUs) { arrs.clear(); VInfo vi = bvu.lookupVariableInfo(v.name()); if (vi != null) { exprWalker.findArraysInStruct(context, v, vi, arrs); for (Pair<Var, VInfo> p : arrs) { if (p.val2.isAssigned() != Ternary.FALSE) { alreadyFound.add(p.val1); } } } } writtenVars.addAll(alreadyFound); } } }
From source file:gdsc.smlm.ij.plugins.PeakFit.java
/** * Load the selected results from memory. All multiple frame results are added directly to the results. All single * frame// w w w . j a v a2 s .com * results are added to a list of candidate maxima per frame and fitted using the configured parameters. */ private void runMaximaFitting() { MemoryPeakResults results = ResultsManager.loadInputResults(inputOption, false); if (results == null || results.size() == 0) { log("No results for maxima fitting"); return; } // No check for imageSource since this has been check in the calling method int totalFrames = source.getFrames(); // Store the indices of each new time-frame results.sort(); List<PeakResult> candidateMaxima = results.getResults(); // Use the FitEngine to allow multi-threading. FitEngine engine = createFitEngine(FastMath.min(totalFrames, Prefs.getThreads())); final int step = (totalFrames > 400) ? totalFrames / 200 : 2; boolean shutdown = false; int slice = candidateMaxima.get(0).peak; ArrayList<PeakResult> sliceCandidates = new ArrayList<PeakResult>(); Iterator<PeakResult> iter = candidateMaxima.iterator(); while (iter.hasNext()) { PeakResult r = iter.next(); if (slice != r.peak) { if (escapePressed()) { shutdown = true; break; } if (slice % step == 0) { IJ.showProgress(slice, totalFrames); IJ.showStatus("Slice: " + slice + " / " + totalFrames); } // Process results if (!processResults(engine, sliceCandidates, slice)) break; sliceCandidates.clear(); } slice = r.peak; sliceCandidates.add(r); } // Process final results if (!shutdown) processResults(engine, sliceCandidates, slice); engine.end(shutdown); time = engine.getTime(); showResults(); source.close(); }
From source file:com.portfolioeffect.quant.client.portfolio.Portfolio.java
private MethodResult computeBatch(ArrayList<String> batchMetrics) { ArrayList<String> metricsTypeNewList = new ArrayList<String>(); for (String e : batchMetrics) { CacheKey key;//from w w w . j a va2 s. co m try { String metricTypeFull = getMetricTypeList(e); key = new CacheKey(metricTypeFull, ""); } catch (Exception e1) { return processException(e1); } if (portfolioCache.containsKey(key)) continue; else metricsTypeNewList.add(e); } if (metricsTypeNewList.size() == 0) { return new MethodResult(); } batchMetrics.clear(); clientConnection.printProgressBar(0); if (portfolioData.getFromTime().length() == 0 || portfolioData.getToTime().length() == 0) { clientConnection.resetProgressBar(); return new MethodResult("Set time interval first"); } for (int ii = 0; ii < NUMBER_OF_TRIES; ii++) { try { String metricsType = getMetricTypeList(metricsTypeNewList); if (portfolioData.getSymbolNamesList().size() == 0) { clientConnection.resetProgressBar(); return new MethodResult(MessageStrings.EMPTY_PORTFOLIO); } String[] positions = null; { MethodResult result = clientConnection.validateStringRequest(metricsType); if (result.hasError()) { throw new Exception(result.getErrorMessage()); } positions = result.getStringArray("positions"); } MethodResult result = null; ArrayList<String> positionList = new ArrayList<String>(); String indexPosition = ""; if (Arrays.asList(positions).contains("@_ALL_PORTFOLIO_")) { for (String symbol : portfolioData.getSymbolNamesList()) { positionList.add(symbol); } } else { for (int i = 0; i < positions.length; i++) { if (positions[i].equals("@_INDEX_")) { } else { if (!portfolioData.getSymbolNamesList().contains(positions[i])) { clientConnection.resetProgressBar(); return new MethodResult( String.format(MessageStrings.POSITION_NOT_FOUND, positions[i])); } positionList.add(positions[i]); } } } ArrayList<String> positionNames = new ArrayList<String>(); for (String e : positionList) { if (portfolioData.getUserPrice().contains(e)) { positionNames.add(portfolioData.getPortfolioId() + ":" + e + ":" + portfolioData.getPriceID().get(e) + "=" + portfolioData.getPortfolioId() + ":" + e + ":" + portfolioData.getQuantityID().get(e)); } else { positionNames.add("h-" + portfolioData.getPortfolioId() + ":" + e + ":" + portfolioData.getPriceID().get(e) + "=" + portfolioData.getPortfolioId() + ":" + e + ":" + portfolioData.getQuantityID().get(e)); } } ArrayList<String> dataList = new ArrayList<String>(); if (portfolioData.getIndexPrice() == null) { dataList.add("hI-" + portfolioData.getPortfolioId() + ":" + portfolioData.getIndexSymbol() + ":" + portfolioData.getPriceID().get(portfolioData.getIndexSymbol())); indexPosition = portfolioData.getIndexSymbol(); } else { dataList.add("u-" + portfolioData.getPortfolioId() + ":" + "index" + ":" + portfolioData.getPriceID().get(portfolioData.getIndexSymbol())); indexPosition = "index"; } for (String symbol : portfolioData.getSymbolNamesList()) { if (portfolioData.getUserPrice().contains(symbol)) { dataList.add("u-" + portfolioData.getPortfolioId() + ":" + symbol + ":" + portfolioData.getPriceID().get(symbol)); } else { dataList.add("h-" + portfolioData.getPortfolioId() + ":" + symbol + ":" + portfolioData.getPriceID().get(symbol)); } dataList.add("q-" + portfolioData.getPortfolioId() + ":" + symbol + ":" + portfolioData.getQuantityID().get(symbol)); } // ------------------------------ if (indexPosition.length() != 0) { if (portfolioData.getIndexPrice() != null) { indexPosition = portfolioData.getPortfolioId() + ":" + indexPosition + ":" + portfolioData.getPriceID().get(indexPosition) + "=" + portfolioData.getPortfolioId() + ":" + indexPosition + ":" + portfolioData.getQuantityID().get(indexPosition); } else { indexPosition = "hI-" + portfolioData.getPortfolioId() + ":" + indexPosition + ":" + portfolioData.getPriceID().get(indexPosition) + "=" + portfolioData.getPortfolioId() + ":" + indexPosition + ":" + portfolioData.getQuantityID().get(indexPosition); } } for (String e : userData) { dataList.add("u-" + portfolioData.getPortfolioId() + ":" + e + ":" + portfolioData.getPriceID().get(e)); } for (String e : userData) { dataList.add("u-" + portfolioData.getPortfolioId() + ":" + e + ":" + portfolioData.getPriceID().get(e)); positionNames.add( portfolioData.getPortfolioId() + ":" + e + ":" + portfolioData.getPriceID().get(e)); } MethodResult resultTransmit = transmitData(dataList); if (resultTransmit.hasError()) { throw new Exception(resultTransmit.getErrorMessage()); //return new MethodResult(resultTransmit.getErrorMessage()); } if (isDebug) { Console.writeln("\n " + metricsType); Console.writeln(indexPosition); Console.writeln(positionNames + "\n"); } result = clientConnection.estimateTransactional(metricsType, indexPosition, positionNames, ""); if (!result.hasError()) { ArrayCache batchValues[] = ArrayCache.splitBatchDouble(result.getDataArrayCache("value")); for (int k = 0; k < metricsTypeNewList.size(); k++) { String metricTypeFull = getMetricTypeList(metricsTypeNewList.get(k)); CacheKey key = new CacheKey(metricTypeFull, ""); portfolioCache.addMetric(key, batchValues[k]); portfolioCache.addTime(key, ArrayCache.copyArrayCacheLong(result.getDataArrayCache("time"))); cachedValueList.add(key); } metricsTypeNewList.clear(); } else { clientConnection.createCallGroup(1); } return new MethodResult(); } catch (Exception e) { MethodResult result = processException(e); if (result.getErrorMessage().equals("Server too busy, try again later")) continue; return result; } } clientConnection.resetProgressBar(); return new MethodResult(MessageStrings.FAILED_SERVER_TIME_OUT); }