final Project projectCopy = projects.getProject().deepCopy(); if (!projectCopy.dbmses().map(Dbms::getId).allMatch(ids::add)) { final Set<String> duplicates = new HashSet<>(); ids.clear(); projectCopy.dbmses() .map(Dbms::getId) .forEach(s -> { final Dbms dbmsCopy = projectCopy.dbmses() .filter(d -> d.getId().equals(dbms.getId())) .findAny().orElseThrow(() -> new SpeedmentException(
ImmutableProject(Map<String, Object> project) { super(project); final Project prototype = new ProjectImpl(project); this.enabled = prototype.isEnabled(); this.id = prototype.getId(); this.name = prototype.getName(); this.companyName = prototype.getCompanyName(); this.packageName = prototype.getPackageName(); this.packageLocation = prototype.getPackageLocation(); this.configPath = prototype.getConfigPath(); this.dbmses = unmodifiableList(super.children(DBMSES, ImmutableDbms::new).collect(toList())); this.tablesByName = MapStream.fromValues( DocumentDbUtil.traverseOver(this, ImmutableTable.class), table -> DocumentUtil.relativeName(table, Dbms.class, DATABASE_NAME) ).toMap(); }
public static void report(final InfoComponent info, final ProjectComponent projects, final Event event) { requireNonNull(info); requireNonNull(projects); requireNonNull(event); if (TestSettings.isTestMode()) { return; } final Project project = projects.getProject(); final Map<String, Object> ping = new HashMap<>(); ping.put("userId", InternalEmailUtil.getUserId().toString()); ping.put("appId", project.getAppId()); ping.put("eventType", event.eventName); ping.put("productName", info.getTitle()); ping.put("productVersion", info.getImplementationVersion()); ping.put("databases", project.dbmses() .map(Dbms::getTypeName) .distinct() .collect(toList()) ); ping.put("emailAddress", InternalEmailUtil.getEmail()); ping.put("computerName", HOST_NAME.getOrCompute(Statistics::getComputerName)); ping.put("dateStarted", STARTED.getOrCompute( () -> Instant.now(Clock.system(ZoneId.of("UTC"))).getEpochSecond() )); sendPostRequest(PING_URL, Json.toJson(ping)); }
public void clearTablesAndSaveToFile() { final ProjectMutator<? extends Project> projectMutator = Project.deepCopy(DocumentTranscoder.load( currentlyOpenFile.toPath(), this::fromJson ).mutator(); project.dbmses().forEach(dbms -> { LOGGER.info("dbms: " + dbms.getName()); dbms.schemas().forEach(schema -> {
/** * Returns {@code true} if the two specified documents represents the same * element in the database. Two documents are considered same if they have * the same name and type and their parents are considered same. * * @param first the first document * @param second the second document * @return {@code true} if same, else {@code false} */ public static boolean isSame(Project first, Project second) { return first.getId().equals(second.getId()); }
/** * Returns the default package name where the document would be located if * the user has not specified a custom package in the config file. * * @return the default package name */ public String defaultPackageName() { final Supplier<String> defaultProjectPackage = () -> DEFAULT_PACKAGE_NAME + namer().javaPackageName(projectOrThrow().getCompanyName()) + "." + namer().javaPackageName(projectOrThrow().getName()); if (document() instanceof Project) { return defaultProjectPackage.get(); } else { return projectOrThrow().getPackageName() .orElseGet(defaultProjectPackage) + "." + DocumentUtil.relativeName( document(), Dbms.class, JAVA_NAME, namer()::javaPackageName ); } }
@Override public Path packageLocation() { final Project project = projectComponent.getProject(); return Paths.get("", project.getPackageLocation().split("/")); } }
public static ImmutableProject wrap(Project project) { return new ImmutableProject(project.getData()); } }
/** * Returns the name of the specified project formatted as a java type. * <p> * Example: * <ul> * <li>{@code EmployeesSchema} * <li>{@code UserTable} * <li>{@code Firstname} * </ul> * * @param project the document to retrieve the name from * @return the project name as a type */ public String typeName(Project project) { return namer().javaTypeName(requireNonNull(project).getName()); }
protected Javadoc getJavaDoc() { final String owner; final String message; if (isInGeneratedPackage()) { owner = infoComponent.getTitle(); message = getGeneratedJavadocMessage(); } else { owner = project().orElseThrow(NoSuchElementException::new).getCompanyName(); message = JAVADOC_MESSAGE; } return Javadoc.of(getJavadocRepresentText() + message) .add(AUTHOR.setValue(owner)); }
public static void report(final InfoComponent info, final ProjectComponent projects, final Event event) { requireNonNull(info); requireNonNull(projects); requireNonNull(event); if (TestSettings.isTestMode()) { return; } final Project project = projects.getProject(); final Map<String, Object> ping = new HashMap<>(); ping.put("userId", InternalEmailUtil.getUserId().toString()); ping.put("appId", project.getAppId()); ping.put("eventType", event.eventName); ping.put("productName", info.getTitle()); ping.put("productVersion", info.getImplementationVersion()); ping.put("databases", project.dbmses() .map(Dbms::getTypeName) .distinct() .collect(toList()) ); ping.put("emailAddress", InternalEmailUtil.getEmail()); ping.put("computerName", HOST_NAME.getOrCompute(Statistics::getComputerName)); ping.put("dateStarted", STARTED.getOrCompute( () -> Instant.now(Clock.system(ZoneId.of("UTC"))).getEpochSecond() )); sendPostRequest(PING_URL, Json.toJson(ping)); }
@Override protected String getJavadocRepresentText() { return "A generated base {@link " + AbstractApplicationBuilder.class.getName() + "} class for the {@link " + Project.class.getName() + "} named " + getSupport().projectOrThrow().getId() + "."; }
@Override public Path packageLocation() { final Project project = projectComponent.getProject(); return baseDir().resolve(project.getPackageLocation()); }
/** * Returns a JSON representation of the specified project node. * * @param project the project * @param encoder the encoder to use * @return the JSON representation * * @throws SpeedmentConfigException if the inputed object is not valid */ public static String save(Project project, Encoder encoder) throws SpeedmentConfigException { if (project == null) { return "null"; } else { try { final Map<String, Object> root = new LinkedHashMap<>(); root.put(ROOT, project.getData()); return encoder.encode(root); } catch (final IllegalArgumentException ex) { throw new SpeedmentConfigException(ex); } } }
final Project projectCopy = projects.getProject().deepCopy(); if (!projectCopy.dbmses().map(Dbms::getId).allMatch(ids::add)) { final Set<String> duplicates = new HashSet<>(); ids.clear(); projectCopy.dbmses() .map(Dbms::getId) .forEach(s -> { final Dbms dbmsCopy = projectCopy.dbmses() .filter(d -> d.getId().equals(dbms.getId())) .findAny().orElseThrow(() -> new SpeedmentException(
@Override protected String getJavadocRepresentText() { return "The generated {@link " + AbstractApplicationBuilder.class.getName() + "} implementation class for the {@link " + Project.class.getName() + "} named " + getSupport().projectOrThrow().getId() + "."; }