use of com.intellij.internal.statistic.beans.GroupDescriptor in project intellij-community by JetBrains.
the class StatisticsUploadAssistantTest method createDescriptors.
protected static Map<GroupDescriptor, Set<UsageDescriptor>> createDescriptors(String... strs) {
Map<GroupDescriptor, Set<UsageDescriptor>> set = new LinkedHashMap<>();
for (String str : strs) {
final List<String> list = StringUtil.split(str, ":");
final GroupDescriptor g = GroupDescriptor.create(list.get(0));
if (!set.containsKey(g)) {
set.put(g, new LinkedHashSet<>());
}
set.get(g).add(createDescriptor(list.get(1), Integer.parseInt(list.get(2))));
}
return set;
}
use of com.intellij.internal.statistic.beans.GroupDescriptor in project intellij-community by JetBrains.
the class StatisticsUploadAssistantTest method assertMapEquals.
private static <T extends UsageDescriptor> void assertMapEquals(@NotNull Map<GroupDescriptor, Set<T>> expected, @NotNull Map<GroupDescriptor, Set<UsageDescriptor>> actual) {
assertEquals(expected.size(), actual.size());
for (Map.Entry<GroupDescriptor, Set<T>> expectedEntry : expected.entrySet()) {
final GroupDescriptor expectedGroupDescriptor = expectedEntry.getKey();
assertTrue(actual.containsKey(expectedGroupDescriptor));
assertSetEquals(expectedEntry.getValue(), actual.get(expectedEntry.getKey()));
}
}
use of com.intellij.internal.statistic.beans.GroupDescriptor in project intellij-community by JetBrains.
the class StatisticsUploadAssistantTest method createPatchDescriptor.
private static void createPatchDescriptor(Map<GroupDescriptor, Set<PatchedUsage>> patchedUsages, String groupId, double priority, String key, int i) {
final GroupDescriptor groupDescriptor = GroupDescriptor.create(groupId, priority);
if (!patchedUsages.containsKey(groupDescriptor)) {
patchedUsages.put(groupDescriptor, new LinkedHashSet<>());
}
patchedUsages.get(groupDescriptor).add(new PatchedUsage(key, i));
}
use of com.intellij.internal.statistic.beans.GroupDescriptor in project intellij-community by JetBrains.
the class ApplicationStatisticsPersistenceComponent method getState.
@Override
public Element getState() {
Element element = new Element("state");
for (Map.Entry<GroupDescriptor, Map<String, CollectedUsages>> appData : getApplicationData().entrySet()) {
Element groupElement = new Element(GROUP_TAG);
groupElement.setAttribute(GROUP_NAME_ATTR, appData.getKey().getId());
boolean isEmptyGroup = true;
for (Map.Entry<String, CollectedUsages> projectData : appData.getValue().entrySet()) {
Element projectElement = new Element(PROJECT_TAG);
projectElement.setAttribute(PROJECT_ID_ATTR, projectData.getKey());
final CollectedUsages projectDataValue = projectData.getValue();
if (!projectDataValue.usages.isEmpty()) {
projectElement.setAttribute(VALUES_ATTR, joinUsages(projectDataValue.usages));
projectElement.setAttribute(COLLECTION_TIME_TAG, String.valueOf(projectDataValue.collectionTime));
groupElement.addContent(projectElement);
isEmptyGroup = false;
}
}
if (!isEmptyGroup) {
element.addContent(groupElement);
}
}
return element;
}
use of com.intellij.internal.statistic.beans.GroupDescriptor in project intellij-community by JetBrains.
the class ApplicationStatisticsPersistenceComponent method loadState.
@Override
public void loadState(Element element) {
for (Element groupElement : element.getChildren(GROUP_TAG)) {
GroupDescriptor groupDescriptor = GroupDescriptor.create(groupElement.getAttributeValue(GROUP_NAME_ATTR));
List<Element> projectsList = groupElement.getChildren(PROJECT_TAG);
for (Element projectElement : projectsList) {
String projectId = projectElement.getAttributeValue(PROJECT_ID_ATTR);
String frameworks = projectElement.getAttributeValue(VALUES_ATTR);
if (!StringUtil.isEmptyOrSpaces(projectId) && !StringUtil.isEmptyOrSpaces(frameworks)) {
Set<UsageDescriptor> frameworkDescriptors = new THashSet<>();
for (String key : StringUtil.split(frameworks, TOKENIZER)) {
UsageDescriptor descriptor = getUsageDescriptor(key);
if (descriptor != null) {
frameworkDescriptors.add(descriptor);
}
}
long collectionTime;
try {
collectionTime = Long.valueOf(projectElement.getAttributeValue(COLLECTION_TIME_TAG));
} catch (NumberFormatException ignored) {
collectionTime = 0;
}
getApplicationData(groupDescriptor).put(projectId, new CollectedUsages(frameworkDescriptors, collectionTime));
}
}
}
}
Aggregations