List of usage examples for com.google.gwt.dev.util.collect HashSet HashSet
public HashSet()
From source file:com.google.gwt.dev.javac.testing.GeneratorContextBuilder.java
License:Apache License
/** * Creates a new {@link GeneratorContextBuilder} that is pre-populated with a * number of basic types provided by/* w w w .j av a2 s . co m*/ * {@link JavaResourceBase#getStandardResources()}. * * @return pre-populated context builder */ public static GeneratorContextBuilder newCoreBasedBuilder() { Set<Resource> resources = new HashSet<Resource>(); resources.addAll(Arrays.asList(JavaResourceBase.getStandardResources())); return new GeneratorContextBuilder(resources); }
From source file:com.google.gwt.dev.javac.testing.GeneratorContextBuilder.java
License:Apache License
/** * Creates a new empty {@link GeneratorContextBuilder}. Note that this * builder does <b>not</b> contain any base java types. * * @return empty context builder/*ww w .j a v a 2 s . c o m*/ */ public static GeneratorContextBuilder newEmptyBuilder() { return new GeneratorContextBuilder(new HashSet<Resource>()); }
From source file:net.cbtltd.rest.lodgix.A_Handler.java
License:Open Source License
@Override public void readProducts() { String message = "readProducts Lodgix (PartyId: " + this.getAltpartyid() + ")"; LOG.debug(message);//from ww w. j ava2 s . com Date version = new Date(); StringBuilder sbNotKnowLocation = new StringBuilder(); final SqlSession sqlSession = RazorServer.openSession(); try { // FeedParser<AdvertiserListingIndex.Advertiser, Listing> parser = FeedParserFactory.getFactoryInstance().createContentIndexedFeedParser(ALL_PRODUCTS_URL); Party party = sqlSession.getMapper(PartyMapper.class).read(this.getAltpartyid()); String advertiserIdForThisPM = party.getAltid(); ListingContentIndex content = CommonUtils.unmarshall(new URL(PRODUCTS_URL), ListingContentIndex.class); for (AdvertiserListingIndex.Advertiser advertiser : content.getAdvertisers().getAdvertiser()) { String advertiserIdCurrent = advertiser.getAssignedId(); if (!advertiserIdForThisPM.equalsIgnoreCase(advertiserIdCurrent)) { continue; } for (ListingContentIndexEntry contentIndex : advertiser.getListingContentIndexEntry()) { Listing propertyListing = CommonUtils.unmarshall(new URL(contentIndex.getListingUrl()), Listing.class); String altId = propertyListing.getExternalId(); LOG.debug("Current AltId=" + altId); Address propertyAddress = propertyListing.getLocation().getAddress(); String countryISO = propertyAddress.getCountry().value(); String state = propertyAddress.getStateOrProvince(); String city = propertyAddress.getCity(); Double latitude = propertyListing.getLocation().getGeoCode().getLatLng().getLatitude() .doubleValue(); Double longitude = propertyListing.getLocation().getGeoCode().getLatLng().getLongitude() .doubleValue(); Location location = null; if (latitude != null && longitude != null) { location = PartnerService.getLocation(sqlSession, city, state, countryISO, latitude, longitude); } else { location = PartnerService.getLocation(sqlSession, city, state, countryISO); } if (location == null) { sbNotKnowLocation.append("\n") .append("Lodgix property: " + altId + " country: " + countryISO + " city: " + city); } Product product = PartnerService.getProduct(sqlSession, getAltpartyid(), altId, true); if (product == null) { continue; } ArrayList<String> attributes = new ArrayList<String>(); if (propertyListing.getUnits().getUnit().size() > 0) { UnitWSD propertyUnit = propertyListing.getUnits().getUnit().get(0); product.setPerson(propertyUnit.getMaxSleep()); product.setCurrency(propertyUnit.getUnitMonetaryInformation().getCurrency()); attributes.add(propertyUnit.getPropertyType().getCode()); // addType(attributes, propertyUnit.getPropertyType().name()); int numberOfBathrooms = 0; if (propertyUnit.getBathrooms().getBathroom() != null) { numberOfBathrooms = propertyUnit.getBathrooms().getBathroom().size(); for (Bathroom currentBathroom : propertyUnit.getBathrooms().getBathroom()) { attributes.add(currentBathroom.getRoomSubType().getCode()); } } product.setBathroom(numberOfBathrooms); int numberOfBedrooms = 0; if (propertyUnit.getBedrooms().getBedroom() != null) { numberOfBedrooms = propertyUnit.getBedrooms().getBedroom().size(); for (Bedroom currentBedroom : propertyUnit.getBedrooms().getBedroom()) { attributes.add(currentBedroom.getRoomSubType().getCode()); } } product.setRoom(numberOfBedrooms); //this are unit features if (propertyUnit.getFeatureValues() != null && propertyUnit.getFeatureValues().getFeatureValue() != null) { for (UnitFeatureValue feature : propertyUnit.getFeatureValues().getFeatureValue()) { attributes.add(feature.getUnitFeatureName().getCode()); } } } String propertyName = ""; for (net.cbtltd.rest.homeaway.feedparser.domain.Text propertyNameText : propertyListing .getAdContent().getPropertyName().getTexts().getText()) { if (propertyNameText.getLocale().equalsIgnoreCase(LOCALE_LANGUAGE)) { propertyName = propertyNameText.getTextValue(); break; } } if (propertyName.equalsIgnoreCase("")) { System.out.println("WARNING: There is no property name on english."); for (net.cbtltd.rest.homeaway.feedparser.domain.Text propertyHedlineText : propertyListing .getAdContent().getHeadline().getTexts().getText()) { if (propertyHedlineText.getLocale().equalsIgnoreCase(LOCALE_LANGUAGE)) { propertyName = propertyHedlineText.getTextValue(); break; } } } product.setName(propertyName); product.setAltSupplierId(getAltpartyid()); product.setSupplierid(getAltpartyid()); product.setCommission(getCommission()); product.setDiscount(getDiscount()); product.setRank(0.0); product.setAltitude(0.0); product.setLatitude(latitude); product.setLongitude(longitude); product.setWebaddress(getWebaddress()); product.setCommission(getCommission()); product.setDiscount(getDiscount()); product.setRating(5); product.setChild(0); product.setInfant(0); product.setToilet(0); product.setQuantity(1); product.setUnit(Unit.DAY); product.setSecuritydeposit(Product.DEFAULT_SECUIRTY_DEPOSIT); product.setCleaningfee(Product.DEFAULT_CLEANING_FEE); // this 2 fields we need for creating getting quotes //web address field is not used, so we can use this field too product.setCode(advertiserIdCurrent); product.setWebaddress(contentIndex.getListingUrl()); product.setVersion(version); StringBuilder address = new StringBuilder(); if (!checkIfValueNullOrEmpty(propertyAddress.getAddressLine1())) { address.append(propertyAddress.getAddressLine1()).append("\n"); } if (!checkIfValueNullOrEmpty(propertyAddress.getAddressLine2())) { address.append(propertyAddress.getAddressLine2()).append("\n"); } if (!checkIfValueNullOrEmpty(city)) { address.append(city).append("\n"); } if (!checkIfValueNullOrEmpty(state)) { address.append(state).append("\n"); } if (!checkIfValueNullOrEmpty(countryISO)) { address.append(countryISO).append("\n"); } product.setPhysicaladdress(address.toString()); // TODO check this setting state if (location != null && propertyListing.isActive()) { product.setLocationid(location.getId()); product.setState(Product.CREATED); } else { product.setState(Product.SUSPENDED); } sqlSession.getMapper(ProductMapper.class).update(product); //this are property features if (propertyListing.getFeatureValues() != null && propertyListing.getFeatureValues().getFeatureValue() != null) { for (ListingFeatureValue feature : propertyListing.getFeatureValues().getFeatureValue()) { attributes.add(feature.getListingFeatureName().getCode()); } } String descriptionProperty = ""; for (net.cbtltd.rest.homeaway.feedparser.domain.Text descriptionText : propertyListing .getAdContent().getDescription().getTexts().getText()) { if (descriptionText.getLocale().equalsIgnoreCase(LOCALE_LANGUAGE)) { descriptionProperty = descriptionText.getTextValue(); break; } } StringBuilder description = new StringBuilder(); description.append(descriptionProperty); product.setPublicText(new Text(product.getPublicId(), product.getName(), Text.Type.HTML, new Date(), description.toString(), Language.EN)); //removing duplicate values from attributes HashSet<String> attributeHashSet = new HashSet<String>(); attributeHashSet.addAll(attributes); attributes.clear(); attributes.addAll(attributeHashSet); TextService.update(sqlSession, product.getTexts()); RelationService.replace(sqlSession, Relation.PRODUCT_VALUE, product.getId(), product.getValues()); RelationService.create(sqlSession, Relation.PRODUCT_ATTRIBUTE, product.getId(), attributes); RelationService.removeDeprecatedData(sqlSession, Relation.PRODUCT_ATTRIBUTE, product.getId(), attributes); sqlSession.commit(); } //canceling not updated products Product action = new Product(); action.setAltpartyid(getAltpartyid()); action.setState(Product.CREATED); action.setVersion(version); sqlSession.getMapper(ProductMapper.class).cancelversion(action); sqlSession.commit(); } } catch (Throwable x) { sqlSession.rollback(); LOG.error(x.getMessage()); x.printStackTrace(); } finally { sqlSession.close(); } MonitorService.monitor(message, version); }
From source file:net.opentsdb.tools.CliDownsample.java
License:Open Source License
private static Set<String> getTagsFromDatapoints(DataPoints[] dataPoints) { Set<String> tags = new HashSet<String>(); for (DataPoints datapoint : dataPoints) { Map<String, String> dpTags = new HashMap<String, String>(); dpTags = datapoint.getTags();/*from www .ja v a 2 s . co m*/ tags.addAll(datapoint.getAggregatedTags()); tags.addAll(dpTags.keySet()); } return tags; }
From source file:org.cruxframework.crux.smartfaces.rebind.grid.DataGridFactory.java
License:Apache License
protected String createColumnByProperty(SourcePrinter out, WidgetCreatorContext context, JSONObject columnElement, JClassType dataObject) { String columnVar = createVariableName("column"); String key = columnElement.optString("key"); boolean detail = isDetailColumn(columnElement); String tooltip = columnElement.optString("tooltip"); String dataObjectName = dataObject.getParameterizedQualifiedSourceName(); String widgetClassName = Label.class.getCanonicalName(); String bindingContextVariable = createVariableName("context"); Set<String> converterDeclarations = new HashSet<String>(); HasDataProviderDataBindingProcessor dataBindingProcessor = createDataBindingProcessor(context, dataObject, bindingContextVariable);/*from ww w .ja v a 2 s . co m*/ String dataObjectVariable = dataBindingProcessor.getCollectionDataObjectVariable(); String dataObjectAlias = getDataObjectAlias(dataObject); String propertyAttr = columnElement.optString("property"); if (StringUtils.isEmpty(propertyAttr)) { throw new CruxGeneratorException("There is no expression bound to this column. " + "Use property attribute or a widget tag on your column. Grid [" + context.getWidgetId() + "]. View [" + getView().getId() + "]."); } String resultVariable = createVariableName("result"); StringBuilder valueExpression = new StringBuilder(); JType valueType = getDataBindingReadExpression(resultVariable, dataObjectAlias, bindingContextVariable, propertyAttr, converterDeclarations, Label.class.getCanonicalName(), "text", dataBindingProcessor, valueExpression); String factoryClassName = GridDataFactory.class.getCanonicalName() + "<" + dataObjectName + ">"; String columnClassName = Column.class.getCanonicalName() + "<" + dataObjectName + ", " + widgetClassName + ">"; out.println(columnClassName + " " + columnVar + " = " + context.getWidget() + ".newColumn(new " + factoryClassName + "(){"); generateBindingContextDeclaration(out, bindingContextVariable, getViewVariable()); boolean hasTooltip = createGetTooltipMethod(out, dataBindingProcessor, converterDeclarations, tooltip, dataObjectName, dataObjectAlias); out.println("public " + widgetClassName + " createData(" + dataObjectName + " " + dataObjectVariable + ", final int rowIndex){"); for (String converterDecl : converterDeclarations) { out.println(converterDecl); } out.println(valueType.getParameterizedQualifiedSourceName() + " " + resultVariable + ";"); out.println(valueExpression + ";"); boolean isStringType = valueType.getQualifiedSourceName().equals(String.class.getCanonicalName()); if (hasTooltip) { String widgetVar = createVariableName("widget"); out.println(widgetClassName + " " + widgetVar + " = new " + widgetClassName + "(" + (!isStringType ? "\"\"+" + resultVariable : resultVariable) + ");"); out.println(widgetVar + ".setTitle(getTooltip(" + dataObjectVariable + "));"); out.println("return " + widgetVar + ";"); } else { out.println("return new " + widgetClassName + "(" + (!isStringType ? "\"\"+" + resultVariable : resultVariable) + ");"); } out.println("}"); out.println("}, " + EscapeUtils.quote(key) + ", " + detail + ");"); return columnVar; }
From source file:org.cruxframework.crux.smartfaces.rebind.grid.DataGridFactory.java
License:Apache License
protected void createColumnComparator(SourcePrinter out, WidgetCreatorContext context, JSONObject columnElement, String columnVar, JClassType dataObject) { String sortable = columnElement.optString("sortable"); if (!StringUtils.isEmpty(sortable) && Boolean.parseBoolean(sortable)) { String propertyAttr = columnElement.optString("property"); if (!StringUtils.isEmpty(propertyAttr)) { String dataObjectName = dataObject.getParameterizedQualifiedSourceName(); String bindingContextVariable = createVariableName("context"); HasDataProviderDataBindingProcessor dataBindingProcessor = createDataBindingProcessor(context, dataObject, bindingContextVariable); Set<String> converterDeclarations = new HashSet<String>(); String resultVariable = createVariableName("result"); String dataObjectAlias = getDataObjectAlias(dataObject); StringBuilder valueExpression = new StringBuilder(); JType bindingType = getDataBindingReadExpression(resultVariable, dataObjectAlias, bindingContextVariable, propertyAttr, converterDeclarations, Label.class.getCanonicalName(), "text", dataBindingProcessor, valueExpression); if (bindingType != null) { String typeName = bindingType.getParameterizedQualifiedSourceName(); JClassType comparableType = getContext().getGeneratorContext().getTypeOracle() .findType(Comparable.class.getCanonicalName()); JPrimitiveType primitive = bindingType.isPrimitive(); if (primitive != null || bindingType.isClassOrInterface().isAssignableTo(comparableType)) { out.println(columnVar + ".setComparator(new " + Comparator.class.getCanonicalName() + "<" + dataObjectName + ">(){"); generateBindingContextDeclaration(out, bindingContextVariable, getViewVariable()); for (String converterDecl : converterDeclarations) { out.println(converterDecl); }//w ww . j av a 2s .co m String dataObjectVariable = dataBindingProcessor.getCollectionDataObjectVariable(); out.println("public " + typeName + " getValue(" + dataObjectName + " " + dataObjectVariable + ") {"); out.println(typeName + " " + resultVariable + ";"); out.println(valueExpression + ";"); out.println("return " + resultVariable + ";"); out.println("}"); out.println("public int compare(" + dataObjectName + " o1, " + dataObjectName + " o2) {"); out.println(typeName + " v1 = getValue(o1);"); out.println(typeName + " v2 = getValue(o2);"); if (primitive != null) { if (primitive == JPrimitiveType.BOOLEAN) { out.println("return (v1 == v2 ? 0 : (v1? 1 : -1));"); } else { out.println("return (v1 == v2 ? 0 : (v1 < v2 ? -1 : 1));"); } } else { out.println("if (v1==v2 || (v1==null && v2==null)) return 0;"); out.println("if (v1==null) return -1;"); out.println("if (v2==null) return 1;"); out.println("return v1.compareTo(v2);"); out.println("}"); out.println("});"); } } } } out.println(columnVar + ".setSortable(" + sortable + ");"); } }
From source file:org.cruxframework.crux.smartfaces.rebind.grid.DataGridFactory.java
License:Apache License
protected void createColumnEditor(SourcePrinter out, WidgetCreatorContext context, JSONObject columnElement, String columnVar, JClassType dataObject) { JSONObject editorTag = getChildTag(columnElement, "editor", context.getWidgetId()); if (editorTag != null) { JSONObject child = ensureFirstChild(editorTag, true, context.getWidgetId()); if (child != null) { Set<String> converterDeclarations = new HashSet<String>(); String bindingContextVariable = createVariableName("context"); HasDataProviderDataBindingProcessor dataBindingProcessor = createDataBindingProcessor(context, dataObject, bindingContextVariable); String propertyValue = editorTag.optString("property"); if (StringUtils.isEmpty(propertyValue)) { propertyValue = columnElement.optString("property"); }// w ww . jav a 2s . c o m if (StringUtils.isEmpty(propertyValue)) { throw new CruxGeneratorException("Column Editor needs the property attribute defined. Grid [" + context.getWidgetId() + "]. View [" + getView().getId() + "]"); } PropertyBindInfo binding = getObjectDataBinding(propertyValue, null, null, true, dataBindingProcessor); if (binding != null) { String dataObjectVariable = dataBindingProcessor.getCollectionDataObjectVariable(); String newValueVariable = createVariableName("newValue"); String expression = binding.getDataObjectWriteExpression(dataObjectVariable, newValueVariable); String converterDeclaration = binding.getConverterDeclaration(); if (converterDeclaration != null) { converterDeclarations.add(converterDeclaration); } String typeName = binding.getType().getParameterizedQualifiedSourceName(); boolean autoRefreshRow = editorTag.optBoolean("autoRefreshRow", false); String dataObjectType = dataObject.getParameterizedQualifiedSourceName(); out.println(columnVar + ".setCellEditor(new " + CellEditor.class.getCanonicalName() + "<" + dataObjectType + ", " + typeName + ">(" + autoRefreshRow + ") {"); generateBindingContextDeclaration(out, bindingContextVariable, getViewVariable()); out.println("public void setProperty(" + dataObjectType + " " + dataObjectVariable + ", " + typeName + " " + newValueVariable + "){"); out.println(expression); out.println("}"); String childName = getChildName(child); if (childName.equals("widget")) { Set<String> converters = generateWidgetCreationForCellByTemplate(out, context, child, dataObject, bindingContextVariable, dataBindingProcessor); converterDeclarations.addAll(converters); } else if (childName.equals("widgetFactory")) { generateWidgetCreationForCellOnController(out, context, child, dataObject); } else { throw new CruxGeneratorException( "Invalid child tag for editor on widget [" + context.getWidgetId() + "], " + "View [" + getView().getId() + "]. Please revalidade your XML file."); } for (String converterDecl : converterDeclarations) { out.println(converterDecl); } out.println("});"); } } } }
From source file:org.jboss.errai.offline.linker.DefaultCacheManifestLinker.java
License:Apache License
/** * Emits the cache manifest file for the user agent represented by the * provided artifacts.//from w ww . java 2s . c o m * * @param userAgent * the user agent name * @param artifacts * the user agent specific cache manifest artifacts * @param globalArtifacts * all artifacts known to this linker * @param logger * the tree logger to record to * @return a synthetic artifact representing the cache manifest file for the * user agent * * @throws UnableToCompleteException */ private Artifact<?> emitUserAgentCacheManifestFile(String userAgent, Collection<PermutationCacheManifestArtifact> artifacts, ArtifactSet globalArtifacts, TreeLogger logger) throws UnableToCompleteException { // Add static external resources final StringBuilder staticResoucesSb = new StringBuilder(); final String[] cacheExtraFiles = getCacheExtraFiles(); for (int i = 0; i < cacheExtraFiles.length; i++) { staticResoucesSb.append(cacheExtraFiles[i]); staticResoucesSb.append("\n"); } // Add generated resources final Set<String> cacheableGeneratedResources = new HashSet<String>(); // Add permutation independent resources if (globalArtifacts != null) { for (final Artifact<?> a : globalArtifacts) { if (a instanceof EmittedArtifact) { final EmittedArtifact ea = (EmittedArtifact) a; final String pathName = ea.getPartialPath(); if (shouldBeCached(pathName) && !isPermutationSpecific(globalArtifacts, pathName)) { cacheableGeneratedResources.add(pathName); } } } } // Add permutation specific resources if (artifacts != null) { for (final PermutationCacheManifestArtifact artifact : artifacts) { for (final String cachedFile : artifact.cachedFiles) { cacheableGeneratedResources.add(cachedFile); } } } // Build manifest final StringBuilder sb = new StringBuilder(); sb.append("CACHE MANIFEST\n"); // we have to generate this unique id because the resources can change but // the hashed cache.html files can remain the same. sb.append("# Unique id #" + (new Date()).getTime() + "." + Math.random() + "\n"); sb.append("\n"); sb.append("CACHE:\n"); sb.append("# Static app files\n"); sb.append(staticResoucesSb.toString()); sb.append("\n# Generated permutation specific app files"); for (final String resource : cacheableGeneratedResources) { sb.append("\n"); sb.append(resource); } sb.append("\n\n"); sb.append("# All other resources require the user to be online.\n"); sb.append("NETWORK:\n"); sb.append("*\n"); // Create the user agent specific manifest as a new artifact and return it return emitString(logger, sb.toString(), userAgent + "." + MANIFEST); }
From source file:org.jboss.errai.offline.linker.DefaultCacheManifestLinker.java
License:Apache License
/** * Checks whether the provided file is specific to a permutation. * // w w w . jav a 2 s . c om * @param artifacts * all artifacts passed to this linker * @param file * the file to check * @return true if the file is specific to a permutation, otherwise false. * */ private boolean isPermutationSpecific(ArtifactSet artifacts, String file) { if (permutationFiles == null) { permutationFiles = new HashSet<String>(); for (final PermutationCacheManifestArtifact pcma : artifacts .find(PermutationCacheManifestArtifact.class)) { permutationFiles.addAll(pcma.cachedFiles); } } return permutationFiles.contains(file); }
From source file:org.jrydberg.bindings.rebind.DataBindingGenerator.java
License:Apache License
private Set<Binding> findBindings(JClassType type) { Set<Binding> types = new HashSet<Binding>(); JMethod[] methods = type.getOverridableMethods(); for (JMethod method : methods) { if (!method.isPublic() || method.isStatic()) { continue; }/*from w w w . j a va 2s . c o m*/ JType propertyType = method.getReturnType(); assert propertyType != null; JParameterizedType isParameterized = propertyType.isParameterized(); if (isParameterized != null) { JClassType enclosingType = isParameterized.getBaseType(); if (enclosingType.getQualifiedSourceName().equals(PROPERTY_CLASS_NAME)) { JClassType[] argTypes = isParameterized.getTypeArgs(); if (argTypes.length == 1) { types.add(new Binding(method.getName(), argTypes[0], false)); } } } JClassType isInterface = propertyType.isInterface(); if (isInterface != null) { JClassType[] interfaces = isInterface.getImplementedInterfaces(); if (interfaces.length != 1) { continue; } JClassType dataBindingInterface = interfaces[0]; if (dataBindingInterface.getQualifiedSourceName().equals(DATA_BINDING_CLASS_NAME)) { JParameterizedType bindingParameters = dataBindingInterface.isParameterized(); JClassType[] argTypes = bindingParameters.getTypeArgs(); if (argTypes.length != 1) { continue; } Binding binding = new Binding(method.getName(), isInterface, true); binding.parameterType = argTypes[0]; types.add(binding); } } } return types; }