repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/snapshotgenerator/UniqueConstraintSnapshotGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import liquibase.database.Database; import liquibase.exception.DatabaseException; import liquibase.ext.spanner.ICloudSpanner; import liquibase.snapshot.CachedRow; import liquibase.snapshot.DatabaseSnapshot; import liquibase.snapshot.SnapshotGenerator; import liquibase.snapshot.jvm.UniqueConstraintSnapshotGenerator; import liquibase.structure.DatabaseObject; import liquibase.structure.core.Schema; import liquibase.structure.core.Table;
/** * Copyright 2021 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.snapshotgenerator; public class UniqueConstraintSnapshotGeneratorSpanner extends UniqueConstraintSnapshotGenerator { public UniqueConstraintSnapshotGeneratorSpanner() { } /* * This generator will be in all chains relating to CloudSpanner, whether or not * the objectType is UniqueConstraint. */ @Override public int getPriority(Class<? extends DatabaseObject> objectType, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/snapshotgenerator/UniqueConstraintSnapshotGeneratorSpanner.java import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import liquibase.database.Database; import liquibase.exception.DatabaseException; import liquibase.ext.spanner.ICloudSpanner; import liquibase.snapshot.CachedRow; import liquibase.snapshot.DatabaseSnapshot; import liquibase.snapshot.SnapshotGenerator; import liquibase.snapshot.jvm.UniqueConstraintSnapshotGenerator; import liquibase.structure.DatabaseObject; import liquibase.structure.core.Schema; import liquibase.structure.core.Table; /** * Copyright 2021 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.snapshotgenerator; public class UniqueConstraintSnapshotGeneratorSpanner extends UniqueConstraintSnapshotGenerator { public UniqueConstraintSnapshotGeneratorSpanner() { } /* * This generator will be in all chains relating to CloudSpanner, whether or not * the objectType is UniqueConstraint. */ @Override public int getPriority(Class<? extends DatabaseObject> objectType, Database database) {
if (database instanceof ICloudSpanner) {
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/datatype/IntTypeSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.IntType; import liquibase.ext.spanner.ICloudSpanner; import liquibase.database.Database;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.datatype; public class IntTypeSpanner extends IntType { @Override public boolean supports(Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/datatype/IntTypeSpanner.java import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.IntType; import liquibase.ext.spanner.ICloudSpanner; import liquibase.database.Database; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.datatype; public class IntTypeSpanner extends IntType { @Override public boolean supports(Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/datatype/ArrayOfStringSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.datatype.DataTypeInfo; import liquibase.datatype.DatabaseDataType; import liquibase.datatype.LiquibaseDataType; import liquibase.datatype.core.UnknownType; import liquibase.ext.spanner.ICloudSpanner;
/** * Copyright 2021 Google LLC * * <p> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * <p> * https://www.apache.org/licenses/LICENSE-2.0 * * <p> * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package liquibase.ext.spanner.datatype; /** * ARRAY<STRING(len)> needs special handling because it contains a length parameter that is not at * the end of the type definition. */ @DataTypeInfo(name = "array<string>", aliases = {"java.sql.Types.ARRAY", "java.lang.String[]"}, minParameters = 1, maxParameters = 1, priority = LiquibaseDataType.PRIORITY_DATABASE) public class ArrayOfStringSpanner extends UnknownType { public ArrayOfStringSpanner() { super("ARRAY<STRING>", 1, 1); } @Override public boolean supports(Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/datatype/ArrayOfStringSpanner.java import liquibase.database.Database; import liquibase.datatype.DataTypeInfo; import liquibase.datatype.DatabaseDataType; import liquibase.datatype.LiquibaseDataType; import liquibase.datatype.core.UnknownType; import liquibase.ext.spanner.ICloudSpanner; /** * Copyright 2021 Google LLC * * <p> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * <p> * https://www.apache.org/licenses/LICENSE-2.0 * * <p> * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package liquibase.ext.spanner.datatype; /** * ARRAY<STRING(len)> needs special handling because it contains a length parameter that is not at * the end of the type definition. */ @DataTypeInfo(name = "array<string>", aliases = {"java.sql.Types.ARRAY", "java.lang.String[]"}, minParameters = 1, maxParameters = 1, priority = LiquibaseDataType.PRIORITY_DATABASE) public class ArrayOfStringSpanner extends UnknownType { public ArrayOfStringSpanner() { super("ARRAY<STRING>", 1, 1); } @Override public boolean supports(Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/datatype/BoolTypeSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.BooleanType; import liquibase.ext.spanner.ICloudSpanner; import liquibase.database.Database;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.datatype; public class BoolTypeSpanner extends BooleanType { private static final DatabaseDataType BOOL = new DatabaseDataType("BOOL"); @Override public boolean supports(Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/datatype/BoolTypeSpanner.java import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.BooleanType; import liquibase.ext.spanner.ICloudSpanner; import liquibase.database.Database; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.datatype; public class BoolTypeSpanner extends BooleanType { private static final DatabaseDataType BOOL = new DatabaseDataType("BOOL"); @Override public boolean supports(Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/RenameViewGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.RenameViewGenerator; import liquibase.statement.core.RenameViewStatement;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class RenameViewGeneratorSpanner extends RenameViewGenerator { static final String RENAME_VIEW_VALIDATION_ERROR = "Cloud Spanner does not support renaming views"; @Override public ValidationErrors validate( RenameViewStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(RENAME_VIEW_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(RenameViewStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/RenameViewGeneratorSpanner.java import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.RenameViewGenerator; import liquibase.statement.core.RenameViewStatement; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class RenameViewGeneratorSpanner extends RenameViewGenerator { static final String RENAME_VIEW_VALIDATION_ERROR = "Cloud Spanner does not support renaming views"; @Override public ValidationErrors validate( RenameViewStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(RENAME_VIEW_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(RenameViewStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/datatype/NumberTypeSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.NumberType; import liquibase.ext.spanner.ICloudSpanner;
package liquibase.ext.spanner.datatype; public class NumberTypeSpanner extends NumberType { private static final DatabaseDataType NUMERIC = new DatabaseDataType("NUMERIC"); @Override public boolean supports(Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/datatype/NumberTypeSpanner.java import liquibase.database.Database; import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.NumberType; import liquibase.ext.spanner.ICloudSpanner; package liquibase.ext.spanner.datatype; public class NumberTypeSpanner extends NumberType { private static final DatabaseDataType NUMERIC = new DatabaseDataType("NUMERIC"); @Override public boolean supports(Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/datatype/FloatTypeSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.FloatType; import liquibase.ext.spanner.ICloudSpanner;
package liquibase.ext.spanner.datatype; public class FloatTypeSpanner extends FloatType { private static final DatabaseDataType FLOAT64 = new DatabaseDataType("FLOAT64"); @Override public boolean supports(Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/datatype/FloatTypeSpanner.java import liquibase.database.Database; import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.FloatType; import liquibase.ext.spanner.ICloudSpanner; package liquibase.ext.spanner.datatype; public class FloatTypeSpanner extends FloatType { private static final DatabaseDataType FLOAT64 = new DatabaseDataType("FLOAT64"); @Override public boolean supports(Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/DropProcedureGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.DropProcedureGenerator; import liquibase.statement.core.DropProcedureStatement;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class DropProcedureGeneratorSpanner extends DropProcedureGenerator { static final String DROP_PROCEDURE_VALIDATION_ERROR = "Cloud Spanner does not support dropping procedures"; @Override public ValidationErrors validate( DropProcedureStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(DROP_PROCEDURE_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(DropProcedureStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/DropProcedureGeneratorSpanner.java import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.DropProcedureGenerator; import liquibase.statement.core.DropProcedureStatement; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class DropProcedureGeneratorSpanner extends DropProcedureGenerator { static final String DROP_PROCEDURE_VALIDATION_ERROR = "Cloud Spanner does not support dropping procedures"; @Override public ValidationErrors validate( DropProcedureStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(DROP_PROCEDURE_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(DropProcedureStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/change/AddLookupTableChangeSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.change.core.AddForeignKeyConstraintChange; import liquibase.change.core.AddLookupTableChange; import liquibase.database.Database; import liquibase.ext.spanner.ICloudSpanner; import liquibase.statement.SqlStatement; import liquibase.statement.core.RawSqlStatement; import liquibase.structure.core.Column;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.change; @DatabaseChange( name = "addLookupTable", description = "Creates a lookup table containing values stored in a column and creates a foreign key to the new table.", priority = ChangeMetaData.PRIORITY_DATABASE, appliesTo = "column") public class AddLookupTableChangeSpanner extends AddLookupTableChange { @Override public boolean supports(Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/change/AddLookupTableChangeSpanner.java import java.util.ArrayList; import java.util.Arrays; import java.util.List; import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.change.core.AddForeignKeyConstraintChange; import liquibase.change.core.AddLookupTableChange; import liquibase.database.Database; import liquibase.ext.spanner.ICloudSpanner; import liquibase.statement.SqlStatement; import liquibase.statement.core.RawSqlStatement; import liquibase.structure.core.Column; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.change; @DatabaseChange( name = "addLookupTable", description = "Creates a lookup table containing values stored in a column and creates a foreign key to the new table.", priority = ChangeMetaData.PRIORITY_DATABASE, appliesTo = "column") public class AddLookupTableChangeSpanner extends AddLookupTableChange { @Override public boolean supports(Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/AddColumnGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.core.AddColumnGenerator; import liquibase.statement.core.AddColumnStatement; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy;
/** * Copyright 2021 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class AddColumnGeneratorSpanner extends AddColumnGenerator { @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(AddColumnStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/AddColumnGeneratorSpanner.java import liquibase.database.Database; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.core.AddColumnGenerator; import liquibase.statement.core.AddColumnStatement; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; /** * Copyright 2021 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class AddColumnGeneratorSpanner extends AddColumnGenerator { @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(AddColumnStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/CreateSequenceGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.CreateSequenceGenerator; import liquibase.statement.core.CreateSequenceStatement;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class CreateSequenceGeneratorSpanner extends CreateSequenceGenerator { static final String CREATE_SEQUENCE_VALIDATION_ERROR = "Cloud Spanner does not support creating sequences"; @Override public ValidationErrors validate( CreateSequenceStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(CREATE_SEQUENCE_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(CreateSequenceStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/CreateSequenceGeneratorSpanner.java import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.CreateSequenceGenerator; import liquibase.statement.core.CreateSequenceStatement; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class CreateSequenceGeneratorSpanner extends CreateSequenceGenerator { static final String CREATE_SEQUENCE_VALIDATION_ERROR = "Cloud Spanner does not support creating sequences"; @Override public ValidationErrors validate( CreateSequenceStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(CREATE_SEQUENCE_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(CreateSequenceStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/datatype/ArrayOfBytesSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.datatype.DataTypeInfo; import liquibase.datatype.DatabaseDataType; import liquibase.datatype.LiquibaseDataType; import liquibase.datatype.core.UnknownType; import liquibase.ext.spanner.ICloudSpanner;
/** * Copyright 2021 Google LLC * * <p> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * <p> * https://www.apache.org/licenses/LICENSE-2.0 * * <p> * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package liquibase.ext.spanner.datatype; /** * ARRAY<BYTES(len)> needs special handling because it contains a length parameter that is not at * the end of the type definition. */ @DataTypeInfo(name = "array<bytes>", aliases = {"java.sql.Types.ARRAY", "java.lang.String[]"}, minParameters = 1, maxParameters = 1, priority = LiquibaseDataType.PRIORITY_DATABASE) public class ArrayOfBytesSpanner extends UnknownType { public ArrayOfBytesSpanner() { super("ARRAY<BYTES>", 1, 1); } @Override public boolean supports(Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/datatype/ArrayOfBytesSpanner.java import liquibase.database.Database; import liquibase.datatype.DataTypeInfo; import liquibase.datatype.DatabaseDataType; import liquibase.datatype.LiquibaseDataType; import liquibase.datatype.core.UnknownType; import liquibase.ext.spanner.ICloudSpanner; /** * Copyright 2021 Google LLC * * <p> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * <p> * https://www.apache.org/licenses/LICENSE-2.0 * * <p> * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package liquibase.ext.spanner.datatype; /** * ARRAY<BYTES(len)> needs special handling because it contains a length parameter that is not at * the end of the type definition. */ @DataTypeInfo(name = "array<bytes>", aliases = {"java.sql.Types.ARRAY", "java.lang.String[]"}, minParameters = 1, maxParameters = 1, priority = LiquibaseDataType.PRIORITY_DATABASE) public class ArrayOfBytesSpanner extends UnknownType { public ArrayOfBytesSpanner() { super("ARRAY<BYTES>", 1, 1); } @Override public boolean supports(Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/RenameTableGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.RenameTableGenerator; import liquibase.statement.core.RenameTableStatement;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class RenameTableGeneratorSpanner extends RenameTableGenerator { static final String RENAME_TABLE_VALIDATION_ERROR = "Cloud Spanner does not support renaming a table"; @Override public ValidationErrors validate( RenameTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(RENAME_TABLE_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(RenameTableStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/RenameTableGeneratorSpanner.java import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.RenameTableGenerator; import liquibase.statement.core.RenameTableStatement; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class RenameTableGeneratorSpanner extends RenameTableGenerator { static final String RENAME_TABLE_VALIDATION_ERROR = "Cloud Spanner does not support renaming a table"; @Override public ValidationErrors validate( RenameTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(RENAME_TABLE_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(RenameTableStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/CreateTableGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.sql.Sql; import liquibase.sql.UnparsedSql; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.CreateTableGenerator; import liquibase.statement.core.CreateTableStatement; import liquibase.structure.DatabaseObject; import liquibase.ext.spanner.ICloudSpanner;
// Move the PRIMARY KEY statement from inside the table creation to outside. StringBuilder buffer = new StringBuilder(", PRIMARY KEY ("); buffer.append( database.escapeColumnNameList( String.join(", ", statement.getPrimaryKeyConstraint().getColumns()))); buffer.append(")"); String pk = buffer.toString(); String sql = res[0].toSql(); sql = sql.replace(pk, ""); // Append PRIMARY KEY (without the leading ,) sql = sql + pk.substring(1); return new Sql[]{ new UnparsedSql( sql, res[0] .getAffectedDatabaseObjects() .toArray(new DatabaseObject[res[0].getAffectedDatabaseObjects().size()])) }; } @Override public int getPriority() { return PRIORITY_DATABASE; } @Override public boolean supports(CreateTableStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/CreateTableGeneratorSpanner.java import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.sql.Sql; import liquibase.sql.UnparsedSql; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.CreateTableGenerator; import liquibase.statement.core.CreateTableStatement; import liquibase.structure.DatabaseObject; import liquibase.ext.spanner.ICloudSpanner; // Move the PRIMARY KEY statement from inside the table creation to outside. StringBuilder buffer = new StringBuilder(", PRIMARY KEY ("); buffer.append( database.escapeColumnNameList( String.join(", ", statement.getPrimaryKeyConstraint().getColumns()))); buffer.append(")"); String pk = buffer.toString(); String sql = res[0].toSql(); sql = sql.replace(pk, ""); // Append PRIMARY KEY (without the leading ,) sql = sql + pk.substring(1); return new Sql[]{ new UnparsedSql( sql, res[0] .getAffectedDatabaseObjects() .toArray(new DatabaseObject[res[0].getAffectedDatabaseObjects().size()])) }; } @Override public int getPriority() { return PRIORITY_DATABASE; } @Override public boolean supports(CreateTableStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/CreateDatabaseChangeLogLockTableGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.sql.Sql; import liquibase.sql.UnparsedSql; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.CreateDatabaseChangeLogLockTableGenerator; import liquibase.statement.core.CreateDatabaseChangeLogLockTableStatement; import liquibase.ext.spanner.ICloudSpanner;
package liquibase.ext.spanner.sqlgenerator; public class CreateDatabaseChangeLogLockTableGeneratorSpanner extends CreateDatabaseChangeLogLockTableGenerator { final String createTableSQL = "" + "CREATE TABLE DATABASECHANGELOGLOCK\n" + "(\n" + " id int64,\n" + " locked bool,\n" + " lockgranted timestamp,\n" + " lockedby string(max),\n" + ") primary key (id)"; @Override public Sql[] generateSql( CreateDatabaseChangeLogLockTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { return new Sql[] {new UnparsedSql(createTableSQL)}; } @Override public int getPriority() { return PRIORITY_DATABASE; } @Override public boolean supports(CreateDatabaseChangeLogLockTableStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/CreateDatabaseChangeLogLockTableGeneratorSpanner.java import liquibase.database.Database; import liquibase.sql.Sql; import liquibase.sql.UnparsedSql; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.CreateDatabaseChangeLogLockTableGenerator; import liquibase.statement.core.CreateDatabaseChangeLogLockTableStatement; import liquibase.ext.spanner.ICloudSpanner; package liquibase.ext.spanner.sqlgenerator; public class CreateDatabaseChangeLogLockTableGeneratorSpanner extends CreateDatabaseChangeLogLockTableGenerator { final String createTableSQL = "" + "CREATE TABLE DATABASECHANGELOGLOCK\n" + "(\n" + " id int64,\n" + " locked bool,\n" + " lockgranted timestamp,\n" + " lockedby string(max),\n" + ") primary key (id)"; @Override public Sql[] generateSql( CreateDatabaseChangeLogLockTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { return new Sql[] {new UnparsedSql(createTableSQL)}; } @Override public int getPriority() { return PRIORITY_DATABASE; } @Override public boolean supports(CreateDatabaseChangeLogLockTableStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/AddDefaultValueGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.AddDefaultValueGenerator; import liquibase.statement.core.AddDefaultValueStatement;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class AddDefaultValueGeneratorSpanner extends AddDefaultValueGenerator { static final String ADD_DEFAULT_VALUE_VALIDATION_ERROR = "Cloud Spanner does not support adding a default value to a column"; @Override public ValidationErrors validate( AddDefaultValueStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(ADD_DEFAULT_VALUE_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(AddDefaultValueStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/AddDefaultValueGeneratorSpanner.java import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.AddDefaultValueGenerator; import liquibase.statement.core.AddDefaultValueStatement; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class AddDefaultValueGeneratorSpanner extends AddDefaultValueGenerator { static final String ADD_DEFAULT_VALUE_VALIDATION_ERROR = "Cloud Spanner does not support adding a default value to a column"; @Override public ValidationErrors validate( AddDefaultValueStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(ADD_DEFAULT_VALUE_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(AddDefaultValueStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/test/java/liquibase/ext/spanner/GenerateSnapshotTest.java
// Path: src/test/java/liquibase/ext/spanner/JdbcMetadataQueries.java // static class ColumnMetaData { // final String table; // final String name; // final int type; // Should be one of java.sql.Types. // final String typeName; // final int size; // final int nullable; // Should be one of java.sql.DatabaseMetaData.columnNullable // // ColumnMetaData(String table, String name, int type, String typeName, int size, int nullable) { // this.table = table; // this.name = name; // this.type = type; // this.typeName = typeName; // this.size = size; // this.nullable = nullable; // } // }
import liquibase.structure.core.Table; import static com.google.common.truth.Truth.assertThat; import com.google.cloud.spanner.MockSpannerServiceImpl.StatementResult; import com.google.cloud.spanner.Statement; import com.google.common.collect.ImmutableList; import java.util.Set; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.parallel.Execution; import org.junit.jupiter.api.parallel.ExecutionMode; import liquibase.CatalogAndSchema; import liquibase.Liquibase; import liquibase.database.Database; import liquibase.ext.spanner.JdbcMetadataQueries.ColumnMetaData; import liquibase.snapshot.DatabaseSnapshot; import liquibase.snapshot.SnapshotControl; import liquibase.snapshot.SnapshotGeneratorFactory;
JdbcMetadataQueries.createGetImportedKeysResultSet(ImmutableList.of()))); mockSpanner.putStatementResult( StatementResult.query( Statement.newBuilder(JdbcMetadataQueries.GET_INDEX_INFO) .bind("p1") .to("") // Catalog .bind("p2") .to("") // Schema .bind("p3") .to("SINGERS") // Table .bind("p4") .to("%") // Index .bind("p5") .to("%") // Unique .build(), JdbcMetadataQueries.createGetIndexInfoResultSet(ImmutableList.of()))); mockSpanner.putStatementResult( StatementResult.query( Statement.newBuilder(JdbcMetadataQueries.GET_COLUMNS) .bind("p1") .to("") // Catalog .bind("p2") .to("") // Schema .bind("p3") .to("%") // Table .bind("p4") .to("%") // Column .build(), JdbcMetadataQueries.createGetColumnsResultSet( ImmutableList.of(
// Path: src/test/java/liquibase/ext/spanner/JdbcMetadataQueries.java // static class ColumnMetaData { // final String table; // final String name; // final int type; // Should be one of java.sql.Types. // final String typeName; // final int size; // final int nullable; // Should be one of java.sql.DatabaseMetaData.columnNullable // // ColumnMetaData(String table, String name, int type, String typeName, int size, int nullable) { // this.table = table; // this.name = name; // this.type = type; // this.typeName = typeName; // this.size = size; // this.nullable = nullable; // } // } // Path: src/test/java/liquibase/ext/spanner/GenerateSnapshotTest.java import liquibase.structure.core.Table; import static com.google.common.truth.Truth.assertThat; import com.google.cloud.spanner.MockSpannerServiceImpl.StatementResult; import com.google.cloud.spanner.Statement; import com.google.common.collect.ImmutableList; import java.util.Set; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.parallel.Execution; import org.junit.jupiter.api.parallel.ExecutionMode; import liquibase.CatalogAndSchema; import liquibase.Liquibase; import liquibase.database.Database; import liquibase.ext.spanner.JdbcMetadataQueries.ColumnMetaData; import liquibase.snapshot.DatabaseSnapshot; import liquibase.snapshot.SnapshotControl; import liquibase.snapshot.SnapshotGeneratorFactory; JdbcMetadataQueries.createGetImportedKeysResultSet(ImmutableList.of()))); mockSpanner.putStatementResult( StatementResult.query( Statement.newBuilder(JdbcMetadataQueries.GET_INDEX_INFO) .bind("p1") .to("") // Catalog .bind("p2") .to("") // Schema .bind("p3") .to("SINGERS") // Table .bind("p4") .to("%") // Index .bind("p5") .to("%") // Unique .build(), JdbcMetadataQueries.createGetIndexInfoResultSet(ImmutableList.of()))); mockSpanner.putStatementResult( StatementResult.query( Statement.newBuilder(JdbcMetadataQueries.GET_COLUMNS) .bind("p1") .to("") // Catalog .bind("p2") .to("") // Schema .bind("p3") .to("%") // Table .bind("p4") .to("%") // Column .build(), JdbcMetadataQueries.createGetColumnsResultSet( ImmutableList.of(
new ColumnMetaData("Singers", "SingerId", java.sql.Types.BIGINT, "INT64", 8, java.sql.DatabaseMetaData.columnNoNulls),
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/CreateDatabaseChangeLogTableGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sql.Sql; import liquibase.sql.UnparsedSql; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.CreateDatabaseChangeLogTableGenerator; import liquibase.statement.core.CreateDatabaseChangeLogTableStatement;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class CreateDatabaseChangeLogTableGeneratorSpanner extends CreateDatabaseChangeLogTableGenerator { final String createTableSql = "" + "CREATE TABLE DATABASECHANGELOG\n" + "(\n" + " id string(MAX) not null,\n" + " author string(MAX) not null,\n" + " filename string(MAX) not null,\n" + " dateExecuted timestamp not null,\n" + " orderExecuted int64 not null,\n" + " execType string(MAX),\n" + " md5sum string(MAX),\n" + " description string(MAX),\n" + " comments string(MAX),\n" + " tag string(MAX),\n" + " liquibase string(MAX),\n" + " contexts string(MAX),\n" + " labels string(MAX),\n" + " deployment_id string(MAX),\n" + ") primary key (id, author, filename);"; @Override public boolean supports(CreateDatabaseChangeLogTableStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/CreateDatabaseChangeLogTableGeneratorSpanner.java import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sql.Sql; import liquibase.sql.UnparsedSql; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.CreateDatabaseChangeLogTableGenerator; import liquibase.statement.core.CreateDatabaseChangeLogTableStatement; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class CreateDatabaseChangeLogTableGeneratorSpanner extends CreateDatabaseChangeLogTableGenerator { final String createTableSql = "" + "CREATE TABLE DATABASECHANGELOG\n" + "(\n" + " id string(MAX) not null,\n" + " author string(MAX) not null,\n" + " filename string(MAX) not null,\n" + " dateExecuted timestamp not null,\n" + " orderExecuted int64 not null,\n" + " execType string(MAX),\n" + " md5sum string(MAX),\n" + " description string(MAX),\n" + " comments string(MAX),\n" + " tag string(MAX),\n" + " liquibase string(MAX),\n" + " contexts string(MAX),\n" + " labels string(MAX),\n" + " deployment_id string(MAX),\n" + ") primary key (id, author, filename);"; @Override public boolean supports(CreateDatabaseChangeLogTableStatement statement, Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/datatype/MediumIntTypeSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.MediumIntType; import liquibase.ext.spanner.ICloudSpanner; import liquibase.database.Database;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.datatype; public class MediumIntTypeSpanner extends MediumIntType { private static final DatabaseDataType INT64 = new DatabaseDataType("INT64"); @Override public boolean supports(Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/datatype/MediumIntTypeSpanner.java import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.MediumIntType; import liquibase.ext.spanner.ICloudSpanner; import liquibase.database.Database; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.datatype; public class MediumIntTypeSpanner extends MediumIntType { private static final DatabaseDataType INT64 = new DatabaseDataType("INT64"); @Override public boolean supports(Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/change/StandardChangeLogHistoryServiceSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.ext.spanner.ICloudSpanner; import liquibase.changelog.StandardChangeLogHistoryService;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.change; public class StandardChangeLogHistoryServiceSpanner extends StandardChangeLogHistoryService { public StandardChangeLogHistoryServiceSpanner() {} @Override public boolean supports(Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/change/StandardChangeLogHistoryServiceSpanner.java import liquibase.database.Database; import liquibase.ext.spanner.ICloudSpanner; import liquibase.changelog.StandardChangeLogHistoryService; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.change; public class StandardChangeLogHistoryServiceSpanner extends StandardChangeLogHistoryService { public StandardChangeLogHistoryServiceSpanner() {} @Override public boolean supports(Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/change/AddColumnChangeSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.change.core.AddColumnChange; import liquibase.database.Database; import liquibase.ext.spanner.ICloudSpanner; import liquibase.statement.SqlStatement; import liquibase.statement.core.UpdateStatement;
/** * Copyright 2021 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.change; @DatabaseChange(name="addColumn", description = "Adds a new column to an existing table", priority = ChangeMetaData.PRIORITY_DATABASE, appliesTo = "table") public class AddColumnChangeSpanner extends AddColumnChange { @Override public boolean supports(Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/change/AddColumnChangeSpanner.java import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.change.core.AddColumnChange; import liquibase.database.Database; import liquibase.ext.spanner.ICloudSpanner; import liquibase.statement.SqlStatement; import liquibase.statement.core.UpdateStatement; /** * Copyright 2021 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.change; @DatabaseChange(name="addColumn", description = "Adds a new column to an existing table", priority = ChangeMetaData.PRIORITY_DATABASE, appliesTo = "table") public class AddColumnChangeSpanner extends AddColumnChange { @Override public boolean supports(Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/AddPrimaryKeyGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.AddPrimaryKeyGenerator; import liquibase.statement.core.AddPrimaryKeyStatement;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class AddPrimaryKeyGeneratorSpanner extends AddPrimaryKeyGenerator { static final String ADD_PK_VALIDATION_ERROR = "Cloud Spanner does not support adding a primary key to an existing table"; @Override public ValidationErrors validate( AddPrimaryKeyStatement addPrimaryKeyStatement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(addPrimaryKeyStatement, database, sqlGeneratorChain); errors.addError(ADD_PK_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(AddPrimaryKeyStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/AddPrimaryKeyGeneratorSpanner.java import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.AddPrimaryKeyGenerator; import liquibase.statement.core.AddPrimaryKeyStatement; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class AddPrimaryKeyGeneratorSpanner extends AddPrimaryKeyGenerator { static final String ADD_PK_VALIDATION_ERROR = "Cloud Spanner does not support adding a primary key to an existing table"; @Override public ValidationErrors validate( AddPrimaryKeyStatement addPrimaryKeyStatement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(addPrimaryKeyStatement, database, sqlGeneratorChain); errors.addError(ADD_PK_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(AddPrimaryKeyStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/InitializeChangeLogLockTableGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.sql.Sql; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.SqlGeneratorFactory; import liquibase.sqlgenerator.core.AbstractSqlGenerator; import liquibase.statement.SqlStatement; import liquibase.statement.core.DeleteStatement; import liquibase.statement.core.InitializeDatabaseChangeLogLockTableStatement; import liquibase.statement.core.InsertStatement; import liquibase.ext.spanner.ICloudSpanner;
Database database, SqlGeneratorChain<InitializeDatabaseChangeLogLockTableStatement> sqlGenerator) { return new ValidationErrors(); } @Override public Sql[] generateSql( InitializeDatabaseChangeLogLockTableStatement statement, Database database, SqlGeneratorChain<InitializeDatabaseChangeLogLockTableStatement> sqlGenerator) { return SqlGeneratorFactory.getInstance() .generateSql( new SqlStatement[] { new DeleteStatement( database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), database.getDatabaseChangeLogLockTableName()) .setWhere("true"), new InsertStatement( database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), database.getDatabaseChangeLogLockTableName()) .addColumnValue("ID", 1) .addColumnValue("LOCKED", Boolean.FALSE) }, database); } @Override public boolean supports(InitializeDatabaseChangeLogLockTableStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/InitializeChangeLogLockTableGeneratorSpanner.java import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.sql.Sql; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.SqlGeneratorFactory; import liquibase.sqlgenerator.core.AbstractSqlGenerator; import liquibase.statement.SqlStatement; import liquibase.statement.core.DeleteStatement; import liquibase.statement.core.InitializeDatabaseChangeLogLockTableStatement; import liquibase.statement.core.InsertStatement; import liquibase.ext.spanner.ICloudSpanner; Database database, SqlGeneratorChain<InitializeDatabaseChangeLogLockTableStatement> sqlGenerator) { return new ValidationErrors(); } @Override public Sql[] generateSql( InitializeDatabaseChangeLogLockTableStatement statement, Database database, SqlGeneratorChain<InitializeDatabaseChangeLogLockTableStatement> sqlGenerator) { return SqlGeneratorFactory.getInstance() .generateSql( new SqlStatement[] { new DeleteStatement( database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), database.getDatabaseChangeLogLockTableName()) .setWhere("true"), new InsertStatement( database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), database.getDatabaseChangeLogLockTableName()) .addColumnValue("ID", 1) .addColumnValue("LOCKED", Boolean.FALSE) }, database); } @Override public boolean supports(InitializeDatabaseChangeLogLockTableStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/InsertOrUpdateGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import java.util.ArrayList; import liquibase.database.Database; import liquibase.exception.LiquibaseException; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sql.Sql; import liquibase.sql.UnparsedSql; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.InsertOrUpdateGenerator; import liquibase.statement.core.InsertOrUpdateStatement;
/** * Copyright 2020 Google LLC * * <p> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * <p> * https://www.apache.org/licenses/LICENSE-2.0 * * <p> * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package liquibase.ext.spanner.sqlgenerator; public class InsertOrUpdateGeneratorSpanner extends InsertOrUpdateGenerator { @Override public boolean supports(InsertOrUpdateStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/InsertOrUpdateGeneratorSpanner.java import java.util.ArrayList; import liquibase.database.Database; import liquibase.exception.LiquibaseException; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sql.Sql; import liquibase.sql.UnparsedSql; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.InsertOrUpdateGenerator; import liquibase.statement.core.InsertOrUpdateStatement; /** * Copyright 2020 Google LLC * * <p> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * <p> * https://www.apache.org/licenses/LICENSE-2.0 * * <p> * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package liquibase.ext.spanner.sqlgenerator; public class InsertOrUpdateGeneratorSpanner extends InsertOrUpdateGenerator { @Override public boolean supports(InsertOrUpdateStatement statement, Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/SetNullableGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.datatype.DataTypeFactory; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sql.Sql; import liquibase.sql.UnparsedSql; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.SetNullableGenerator; import liquibase.statement.core.SetNullableStatement;
/** * Copyright 2020 Google LLC * * <p> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * <p> * https://www.apache.org/licenses/LICENSE-2.0 * * <p> * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package liquibase.ext.spanner.sqlgenerator; public class SetNullableGeneratorSpanner extends SetNullableGenerator { @Override public boolean supports(SetNullableStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/SetNullableGeneratorSpanner.java import liquibase.database.Database; import liquibase.datatype.DataTypeFactory; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sql.Sql; import liquibase.sql.UnparsedSql; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.SetNullableGenerator; import liquibase.statement.core.SetNullableStatement; /** * Copyright 2020 Google LLC * * <p> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * <p> * https://www.apache.org/licenses/LICENSE-2.0 * * <p> * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package liquibase.ext.spanner.sqlgenerator; public class SetNullableGeneratorSpanner extends SetNullableGenerator { @Override public boolean supports(SetNullableStatement statement, Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/datatype/SmallIntTypeSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.SmallIntType; import liquibase.ext.spanner.ICloudSpanner; import liquibase.database.Database;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.datatype; public class SmallIntTypeSpanner extends SmallIntType { private static final DatabaseDataType INT64 = new DatabaseDataType("INT64"); @Override public boolean supports(Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/datatype/SmallIntTypeSpanner.java import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.SmallIntType; import liquibase.ext.spanner.ICloudSpanner; import liquibase.database.Database; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.datatype; public class SmallIntTypeSpanner extends SmallIntType { private static final DatabaseDataType INT64 = new DatabaseDataType("INT64"); @Override public boolean supports(Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/DropUniqueConstraintGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.DropUniqueConstraintGenerator; import liquibase.statement.core.DropUniqueConstraintStatement;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; /** * Cloud Spanner does not support unique constraints. Applications should create a unique index * instead. */ public class DropUniqueConstraintGeneratorSpanner extends DropUniqueConstraintGenerator { static final String DROP_UNIQUE_CONSTRAINT_VALIDATION_ERROR = "Cloud Spanner does not support unique constraints. Use a unique index instead."; @Override public int getPriority() { return PRIORITY_DATABASE; } @Override public boolean supports(DropUniqueConstraintStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/DropUniqueConstraintGeneratorSpanner.java import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.DropUniqueConstraintGenerator; import liquibase.statement.core.DropUniqueConstraintStatement; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; /** * Cloud Spanner does not support unique constraints. Applications should create a unique index * instead. */ public class DropUniqueConstraintGeneratorSpanner extends DropUniqueConstraintGenerator { static final String DROP_UNIQUE_CONSTRAINT_VALIDATION_ERROR = "Cloud Spanner does not support unique constraints. Use a unique index instead."; @Override public int getPriority() { return PRIORITY_DATABASE; } @Override public boolean supports(DropUniqueConstraintStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/RenameSequenceGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.RenameSequenceGenerator; import liquibase.statement.core.RenameSequenceStatement;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class RenameSequenceGeneratorSpanner extends RenameSequenceGenerator { static final String RENAME_SEQUENCE_VALIDATION_ERROR = "Cloud Spanner does not support renaming sequences"; @Override public ValidationErrors validate( RenameSequenceStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(RENAME_SEQUENCE_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(RenameSequenceStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/RenameSequenceGeneratorSpanner.java import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.RenameSequenceGenerator; import liquibase.statement.core.RenameSequenceStatement; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class RenameSequenceGeneratorSpanner extends RenameSequenceGenerator { static final String RENAME_SEQUENCE_VALIDATION_ERROR = "Cloud Spanner does not support renaming sequences"; @Override public ValidationErrors validate( RenameSequenceStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(RENAME_SEQUENCE_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(RenameSequenceStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/datatype/TinyIntTypeSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.TinyIntType; import liquibase.ext.spanner.ICloudSpanner; import liquibase.database.Database;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.datatype; public class TinyIntTypeSpanner extends TinyIntType { private static final DatabaseDataType INT64 = new DatabaseDataType("INT64"); @Override public boolean supports(Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/datatype/TinyIntTypeSpanner.java import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.TinyIntType; import liquibase.ext.spanner.ICloudSpanner; import liquibase.database.Database; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.datatype; public class TinyIntTypeSpanner extends TinyIntType { private static final DatabaseDataType INT64 = new DatabaseDataType("INT64"); @Override public boolean supports(Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/datatype/TimeTypeSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.TimeType; import liquibase.ext.spanner.ICloudSpanner; import liquibase.database.Database;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.datatype; /** * Cloud Spanner does not have a data type that only stores time information. The best possible * translation is therefore a TIMESTAMP column. */ public class TimeTypeSpanner extends TimeType { private static final DatabaseDataType TIME = new DatabaseDataType("TIMESTAMP"); @Override public boolean supports(Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/datatype/TimeTypeSpanner.java import liquibase.datatype.DatabaseDataType; import liquibase.datatype.core.TimeType; import liquibase.ext.spanner.ICloudSpanner; import liquibase.database.Database; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.datatype; /** * Cloud Spanner does not have a data type that only stores time information. The best possible * translation is therefore a TIMESTAMP column. */ public class TimeTypeSpanner extends TimeType { private static final DatabaseDataType TIME = new DatabaseDataType("TIMESTAMP"); @Override public boolean supports(Database database) {
return database instanceof ICloudSpanner;
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/AddForeignKeyConstraintGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sql.Sql; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.AddForeignKeyConstraintGenerator; import liquibase.statement.core.AddForeignKeyConstraintStatement;
/** * Copyright 2021 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class AddForeignKeyConstraintGeneratorSpanner extends AddForeignKeyConstraintGenerator { @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(AddForeignKeyConstraintStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/AddForeignKeyConstraintGeneratorSpanner.java import liquibase.database.Database; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sql.Sql; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.AddForeignKeyConstraintGenerator; import liquibase.statement.core.AddForeignKeyConstraintStatement; /** * Copyright 2021 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class AddForeignKeyConstraintGeneratorSpanner extends AddForeignKeyConstraintGenerator { @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(AddForeignKeyConstraintStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/AddUniqueConstraintGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.AddUniqueConstraintGenerator; import liquibase.statement.core.AddUniqueConstraintStatement;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; /** * Cloud Spanner does not support unique constraints. Applications should create a unique index * instead. */ public class AddUniqueConstraintGeneratorSpanner extends AddUniqueConstraintGenerator { static final String ADD_UNIQUE_CONSTRAINT_VALIDATION_ERROR = "Cloud Spanner does not support unique constraints. Use a unique index instead."; @Override public int getPriority() { return PRIORITY_DATABASE; } @Override public boolean supports(AddUniqueConstraintStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/AddUniqueConstraintGeneratorSpanner.java import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.AddUniqueConstraintGenerator; import liquibase.statement.core.AddUniqueConstraintStatement; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; /** * Cloud Spanner does not support unique constraints. Applications should create a unique index * instead. */ public class AddUniqueConstraintGeneratorSpanner extends AddUniqueConstraintGenerator { static final String ADD_UNIQUE_CONSTRAINT_VALIDATION_ERROR = "Cloud Spanner does not support unique constraints. Use a unique index instead."; @Override public int getPriority() { return PRIORITY_DATABASE; } @Override public boolean supports(AddUniqueConstraintStatement statement, Database database) {
return (database instanceof ICloudSpanner);
cloudspannerecosystem/liquibase-spanner
src/main/java/liquibase/ext/spanner/sqlgenerator/DropSequenceGeneratorSpanner.java
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // }
import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.DropSequenceGenerator; import liquibase.statement.core.DropSequenceStatement;
/** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class DropSequenceGeneratorSpanner extends DropSequenceGenerator { static final String DROP_SEQUENCE_VALIDATION_ERROR = "Cloud Spanner does not support dropping sequences"; @Override public ValidationErrors validate( DropSequenceStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(DROP_SEQUENCE_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(DropSequenceStatement statement, Database database) {
// Path: src/main/java/liquibase/ext/spanner/ICloudSpanner.java // public interface ICloudSpanner extends Database { // } // Path: src/main/java/liquibase/ext/spanner/sqlgenerator/DropSequenceGeneratorSpanner.java import liquibase.database.Database; import liquibase.exception.ValidationErrors; import liquibase.ext.spanner.ICloudSpanner; import liquibase.sqlgenerator.SqlGenerator; import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.sqlgenerator.core.DropSequenceGenerator; import liquibase.statement.core.DropSequenceStatement; /** * Copyright 2020 Google LLC * * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * <p>https://www.apache.org/licenses/LICENSE-2.0 * * <p>Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ package liquibase.ext.spanner.sqlgenerator; public class DropSequenceGeneratorSpanner extends DropSequenceGenerator { static final String DROP_SEQUENCE_VALIDATION_ERROR = "Cloud Spanner does not support dropping sequences"; @Override public ValidationErrors validate( DropSequenceStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { ValidationErrors errors = super.validate(statement, database, sqlGeneratorChain); errors.addError(DROP_SEQUENCE_VALIDATION_ERROR); return errors; } @Override public int getPriority() { return SqlGenerator.PRIORITY_DATABASE; } @Override public boolean supports(DropSequenceStatement statement, Database database) {
return (database instanceof ICloudSpanner);
fiji/MaMuT
src/main/java/fiji/plugin/mamut/SourceSettings.java
// Path: src/main/java/fiji/plugin/mamut/providers/MamutSpotAnalyzerProvider.java // @SuppressWarnings( "rawtypes" ) // public class MamutSpotAnalyzerProvider extends AbstractProvider< MamutSpotAnalyzerFactory > // { // // private final int nChannels; // // public MamutSpotAnalyzerProvider( final int nChannels ) // { // super( MamutSpotAnalyzerFactory.class ); // this.nChannels = nChannels; // } // // @Override // public MamutSpotAnalyzerFactory getFactory( final String key ) // { // final MamutSpotAnalyzerFactory factory = super.getFactory( key ); // if ( factory == null ) // return null; // // factory.setNChannels( nChannels ); // return factory; // } // // public static void main( final String[] args ) // { // final MamutSpotAnalyzerProvider provider = new MamutSpotAnalyzerProvider( 2 ); // System.out.println( provider.echo() ); // } // }
import java.io.File; import java.util.ArrayList; import java.util.List; import bdv.BigDataViewer; import bdv.ViewerImgLoader; import bdv.cache.CacheControl; import bdv.spimdata.SpimDataMinimal; import bdv.spimdata.WrapBasicImgLoader; import bdv.spimdata.XmlIoSpimDataMinimal; import bdv.tools.brightness.ConverterSetup; import bdv.viewer.SourceAndConverter; import fiji.plugin.mamut.providers.MamutSpotAnalyzerProvider; import fiji.plugin.trackmate.Settings; import fiji.plugin.trackmate.features.spot.SpotAnalyzerFactoryBase; import fiji.plugin.trackmate.providers.EdgeAnalyzerProvider; import fiji.plugin.trackmate.providers.SpotAnalyzerProvider; import fiji.plugin.trackmate.providers.TrackAnalyzerProvider; import mpicbg.spim.data.SpimDataException; import mpicbg.spim.data.generic.sequence.AbstractSequenceDescription; import mpicbg.spim.data.sequence.TimePoint; import net.imglib2.RandomAccessibleInterval;
} this.cache = ( ( ViewerImgLoader ) seq.getImgLoader() ).getCacheControl(); final List< TimePoint > timepoints = seq.getTimePoints().getTimePointsOrdered(); this.nframes = timepoints.size(); // Image size final SourceAndConverter< ? > firstSource = sources.get( 0 ); final RandomAccessibleInterval< ? > firstStack = firstSource.getSpimSource().getSource( 0, 0 ); this.width = ( int ) firstStack.dimension( 0 ); this.height = ( int ) firstStack.dimension( 1 ); this.nslices = ( int ) firstStack.dimension( 2 ); this.dx = 1f; this.dy = 1f; this.dz = 1f; this.dt = 1f; // Crop cube this.xstart = 0; this.xend = width - 1; this.ystart = 0; this.yend = height - 1; this.roi = null; } @Override public void addAllAnalyzers() { clearSpotAnalyzerFactories(); // Analyzers specific to MaMuT.
// Path: src/main/java/fiji/plugin/mamut/providers/MamutSpotAnalyzerProvider.java // @SuppressWarnings( "rawtypes" ) // public class MamutSpotAnalyzerProvider extends AbstractProvider< MamutSpotAnalyzerFactory > // { // // private final int nChannels; // // public MamutSpotAnalyzerProvider( final int nChannels ) // { // super( MamutSpotAnalyzerFactory.class ); // this.nChannels = nChannels; // } // // @Override // public MamutSpotAnalyzerFactory getFactory( final String key ) // { // final MamutSpotAnalyzerFactory factory = super.getFactory( key ); // if ( factory == null ) // return null; // // factory.setNChannels( nChannels ); // return factory; // } // // public static void main( final String[] args ) // { // final MamutSpotAnalyzerProvider provider = new MamutSpotAnalyzerProvider( 2 ); // System.out.println( provider.echo() ); // } // } // Path: src/main/java/fiji/plugin/mamut/SourceSettings.java import java.io.File; import java.util.ArrayList; import java.util.List; import bdv.BigDataViewer; import bdv.ViewerImgLoader; import bdv.cache.CacheControl; import bdv.spimdata.SpimDataMinimal; import bdv.spimdata.WrapBasicImgLoader; import bdv.spimdata.XmlIoSpimDataMinimal; import bdv.tools.brightness.ConverterSetup; import bdv.viewer.SourceAndConverter; import fiji.plugin.mamut.providers.MamutSpotAnalyzerProvider; import fiji.plugin.trackmate.Settings; import fiji.plugin.trackmate.features.spot.SpotAnalyzerFactoryBase; import fiji.plugin.trackmate.providers.EdgeAnalyzerProvider; import fiji.plugin.trackmate.providers.SpotAnalyzerProvider; import fiji.plugin.trackmate.providers.TrackAnalyzerProvider; import mpicbg.spim.data.SpimDataException; import mpicbg.spim.data.generic.sequence.AbstractSequenceDescription; import mpicbg.spim.data.sequence.TimePoint; import net.imglib2.RandomAccessibleInterval; } this.cache = ( ( ViewerImgLoader ) seq.getImgLoader() ).getCacheControl(); final List< TimePoint > timepoints = seq.getTimePoints().getTimePointsOrdered(); this.nframes = timepoints.size(); // Image size final SourceAndConverter< ? > firstSource = sources.get( 0 ); final RandomAccessibleInterval< ? > firstStack = firstSource.getSpimSource().getSource( 0, 0 ); this.width = ( int ) firstStack.dimension( 0 ); this.height = ( int ) firstStack.dimension( 1 ); this.nslices = ( int ) firstStack.dimension( 2 ); this.dx = 1f; this.dy = 1f; this.dz = 1f; this.dt = 1f; // Crop cube this.xstart = 0; this.xend = width - 1; this.ystart = 0; this.yend = height - 1; this.roi = null; } @Override public void addAllAnalyzers() { clearSpotAnalyzerFactories(); // Analyzers specific to MaMuT.
final MamutSpotAnalyzerProvider mamutSpotAnalyzerProvider = new MamutSpotAnalyzerProvider( sources.size() );
fiji/MaMuT
src/main/java/fiji/plugin/mamut/feature/track/CellDivisionTimeAnalyzer.java
// Path: src/main/java/fiji/plugin/mamut/feature/spot/CellDivisionTimeAnalyzerSpotFactory.java // public static final String CELL_DIVISION_TIME = "CELL_DIVISION_TIME";
import javax.swing.ImageIcon; import org.scijava.plugin.Plugin; import fiji.plugin.trackmate.Dimension; import fiji.plugin.trackmate.FeatureModel; import fiji.plugin.trackmate.Model; import fiji.plugin.trackmate.Spot; import fiji.plugin.trackmate.TrackModel; import fiji.plugin.trackmate.features.track.TrackAnalyzer; import fiji.plugin.trackmate.graph.ConvexBranchesDecomposition; import fiji.plugin.trackmate.graph.ConvexBranchesDecomposition.TrackBranchDecomposition; import fiji.plugin.trackmate.graph.TimeDirectedNeighborIndex; import static fiji.plugin.mamut.feature.spot.CellDivisionTimeAnalyzerSpotFactory.CELL_DIVISION_TIME; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set;
if ( EXCLUDE_OPEN_BRANCHES ) { // Check if this branch arose from a cell division final Set< Spot > predecessors = neighborIndex.predecessorsOf( first ); if ( predecessors.size() == 0 ) { continue; } final Spot predecessor = predecessors.iterator().next(); if ( neighborIndex.successorsOf( predecessor ).size() < 2 ) { continue; } // Check if this branch ends by a cell division if ( neighborIndex.successorsOf( last ).size() < 2 ) { continue; } } // Ok, incorporate its duration val = last.diffTo( first, Spot.POSITION_T ); /* * Before we go on, we will add this value as a feature of all * the spots of this branch. */ for ( final Spot spot : branch ) {
// Path: src/main/java/fiji/plugin/mamut/feature/spot/CellDivisionTimeAnalyzerSpotFactory.java // public static final String CELL_DIVISION_TIME = "CELL_DIVISION_TIME"; // Path: src/main/java/fiji/plugin/mamut/feature/track/CellDivisionTimeAnalyzer.java import javax.swing.ImageIcon; import org.scijava.plugin.Plugin; import fiji.plugin.trackmate.Dimension; import fiji.plugin.trackmate.FeatureModel; import fiji.plugin.trackmate.Model; import fiji.plugin.trackmate.Spot; import fiji.plugin.trackmate.TrackModel; import fiji.plugin.trackmate.features.track.TrackAnalyzer; import fiji.plugin.trackmate.graph.ConvexBranchesDecomposition; import fiji.plugin.trackmate.graph.ConvexBranchesDecomposition.TrackBranchDecomposition; import fiji.plugin.trackmate.graph.TimeDirectedNeighborIndex; import static fiji.plugin.mamut.feature.spot.CellDivisionTimeAnalyzerSpotFactory.CELL_DIVISION_TIME; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; if ( EXCLUDE_OPEN_BRANCHES ) { // Check if this branch arose from a cell division final Set< Spot > predecessors = neighborIndex.predecessorsOf( first ); if ( predecessors.size() == 0 ) { continue; } final Spot predecessor = predecessors.iterator().next(); if ( neighborIndex.successorsOf( predecessor ).size() < 2 ) { continue; } // Check if this branch ends by a cell division if ( neighborIndex.successorsOf( last ).size() < 2 ) { continue; } } // Ok, incorporate its duration val = last.diffTo( first, Spot.POSITION_T ); /* * Before we go on, we will add this value as a feature of all * the spots of this branch. */ for ( final Spot spot : branch ) {
spot.putFeature( CELL_DIVISION_TIME, Double.valueOf( val ) );
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/AustraliaPost.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf; import java.awt.geom.Rectangle2D;
throw new OkapiException("Invalid characters in data"); } /* Verify that the first 8 characters are numbers */ deliveryPointId = zeroPaddedInput.substring(0, 8); if (!deliveryPointId.matches("[0-9]+")) { throw new OkapiException("Invalid characters in DPID"); } infoLine("DPID: " + deliveryPointId); /* Start */ barStateValues = "13"; /* Encode the FCC */ for(i = 0; i < 2; i++) { barStateValues += N_ENCODING_TABLE[formatControlCode.charAt(i) - '0']; } /* Delivery Point Identifier (DPID) */ for(i = 0; i < 8; i++) { barStateValues += N_ENCODING_TABLE[deliveryPointId.charAt(i) - '0']; } /* Customer Information */ switch(zeroPaddedInput.length()) { case 13: case 18: for(i = 8; i < zeroPaddedInput.length(); i++) {
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/AustraliaPost.java import static uk.org.okapibarcode.util.Arrays.positionOf; import java.awt.geom.Rectangle2D; throw new OkapiException("Invalid characters in data"); } /* Verify that the first 8 characters are numbers */ deliveryPointId = zeroPaddedInput.substring(0, 8); if (!deliveryPointId.matches("[0-9]+")) { throw new OkapiException("Invalid characters in DPID"); } infoLine("DPID: " + deliveryPointId); /* Start */ barStateValues = "13"; /* Encode the FCC */ for(i = 0; i < 2; i++) { barStateValues += N_ENCODING_TABLE[formatControlCode.charAt(i) - '0']; } /* Delivery Point Identifier (DPID) */ for(i = 0; i < 8; i++) { barStateValues += N_ENCODING_TABLE[deliveryPointId.charAt(i) - '0']; } /* Customer Information */ switch(zeroPaddedInput.length()) { case 13: case 18: for(i = 8; i < zeroPaddedInput.length(); i++) {
barStateValues += C_ENCODING_TABLE[positionOf(zeroPaddedInput.charAt(i), CHARACTER_SET)];
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/Code11.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf;
* @param stopDelimiter an optional stop delimiter to be shown in the human-readable text */ public void setStopDelimiter(Character stopDelimiter) { this.stopDelimiter = stopDelimiter; } /** * Returns the optional stop delimiter to be shown in the human-readable text. * * @return the optional stop delimiter to be shown in the human-readable text */ public Character getStopDelimiter() { return stopDelimiter; } /** {@inheritDoc} */ @Override protected void encode() { if (!content.matches("[0-9-]+")) { throw new OkapiException("Invalid characters in input"); } String horizontalSpacing = "112211"; String humanReadable = content; int length = content.length(); int[] weight = new int[length + 1]; for (int i = 0; i < length; i++) { char c = content.charAt(i);
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/Code11.java import static uk.org.okapibarcode.util.Arrays.positionOf; * @param stopDelimiter an optional stop delimiter to be shown in the human-readable text */ public void setStopDelimiter(Character stopDelimiter) { this.stopDelimiter = stopDelimiter; } /** * Returns the optional stop delimiter to be shown in the human-readable text. * * @return the optional stop delimiter to be shown in the human-readable text */ public Character getStopDelimiter() { return stopDelimiter; } /** {@inheritDoc} */ @Override protected void encode() { if (!content.matches("[0-9-]+")) { throw new OkapiException("Invalid characters in input"); } String horizontalSpacing = "112211"; String humanReadable = content; int length = content.length(); int[] weight = new int[length + 1]; for (int i = 0; i < length; i++) { char c = content.charAt(i);
weight[i] = positionOf(c, CHARACTER_SET);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/Composite.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // // Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static void binaryAppend(StringBuilder s, int value, int digits) { // int start = 0x01 << (digits - 1); // for (int i = 0; i < digits; i++) { // if ((value & (start >> i)) == 0) { // s.append('0'); // } else { // s.append('1'); // } // } // } // // Path: src/main/java/uk/org/okapibarcode/backend/DataBar14.java // public enum Mode { // /** DataBar-14 */ // LINEAR, // /** DataBar-14 Omnidirectional */ // OMNI, // /** DataBar-14 Omnidirectional Stacked */ // STACKED // }
import static uk.org.okapibarcode.util.Arrays.positionOf; import static uk.org.okapibarcode.util.Strings.binaryAppend; import java.awt.geom.Rectangle2D; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import uk.org.okapibarcode.backend.DataBar14.Mode;
* @param columns the number of segments in each row */ public void setPreferredColumns(int columns) { if (columns < 1 || columns > 10) { throw new IllegalArgumentException("Invalid column count: " + columns); } this.preferredColumns = columns; } @Override protected void encode() { List < Rectangle2D.Double > combine_rect = new ArrayList<>(); List < TextBox > combine_txt = new ArrayList<>(); int top_shift = 0; // 2D component x-coordinate shift int bottom_shift = 0; // linear component x-coordinate shift linearWidth = 0; if (linearContent.isEmpty()) { throw new OkapiException("No linear data set"); } // Manage composite component encoding first encodeComposite(); // Then encode linear component Symbol linear; switch (symbology) { case UPCA: Upc upca = new Upc();
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // // Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static void binaryAppend(StringBuilder s, int value, int digits) { // int start = 0x01 << (digits - 1); // for (int i = 0; i < digits; i++) { // if ((value & (start >> i)) == 0) { // s.append('0'); // } else { // s.append('1'); // } // } // } // // Path: src/main/java/uk/org/okapibarcode/backend/DataBar14.java // public enum Mode { // /** DataBar-14 */ // LINEAR, // /** DataBar-14 Omnidirectional */ // OMNI, // /** DataBar-14 Omnidirectional Stacked */ // STACKED // } // Path: src/main/java/uk/org/okapibarcode/backend/Composite.java import static uk.org.okapibarcode.util.Arrays.positionOf; import static uk.org.okapibarcode.util.Strings.binaryAppend; import java.awt.geom.Rectangle2D; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import uk.org.okapibarcode.backend.DataBar14.Mode; * @param columns the number of segments in each row */ public void setPreferredColumns(int columns) { if (columns < 1 || columns > 10) { throw new IllegalArgumentException("Invalid column count: " + columns); } this.preferredColumns = columns; } @Override protected void encode() { List < Rectangle2D.Double > combine_rect = new ArrayList<>(); List < TextBox > combine_txt = new ArrayList<>(); int top_shift = 0; // 2D component x-coordinate shift int bottom_shift = 0; // linear component x-coordinate shift linearWidth = 0; if (linearContent.isEmpty()) { throw new OkapiException("No linear data set"); } // Manage composite component encoding first encodeComposite(); // Then encode linear component Symbol linear; switch (symbology) { case UPCA: Upc upca = new Upc();
upca.setMode(Upc.Mode.UPCA);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/Composite.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // // Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static void binaryAppend(StringBuilder s, int value, int digits) { // int start = 0x01 << (digits - 1); // for (int i = 0; i < digits; i++) { // if ((value & (start >> i)) == 0) { // s.append('0'); // } else { // s.append('1'); // } // } // } // // Path: src/main/java/uk/org/okapibarcode/backend/DataBar14.java // public enum Mode { // /** DataBar-14 */ // LINEAR, // /** DataBar-14 Omnidirectional */ // OMNI, // /** DataBar-14 Omnidirectional Stacked */ // STACKED // }
import static uk.org.okapibarcode.util.Arrays.positionOf; import static uk.org.okapibarcode.util.Strings.binaryAppend; import java.awt.geom.Rectangle2D; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import uk.org.okapibarcode.backend.DataBar14.Mode;
case 1: infoLine("0"); break; case 2: infoLine("10"); break; case 3: infoLine("11"); break; } binary_string = new StringBuilder(); if (encoding_method == 1) { binary_string.append('0'); } if (encoding_method == 2) { /* Encoding Method field "10" - date and lot number */ binary_string.append("10"); if (inputData[1] == '0') { /* No date data */ binary_string.append("11"); } else { /* Production Date (11) or Expiration Date (17) */ group_val = ((10 * (inputData[2] - '0')) + (inputData[3] - '0')) * 384; group_val += (((10 * (inputData[4] - '0')) + (inputData[5] - '0')) - 1) * 32; group_val += (10 * (inputData[6] - '0')) + (inputData[7] - '0');
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // // Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static void binaryAppend(StringBuilder s, int value, int digits) { // int start = 0x01 << (digits - 1); // for (int i = 0; i < digits; i++) { // if ((value & (start >> i)) == 0) { // s.append('0'); // } else { // s.append('1'); // } // } // } // // Path: src/main/java/uk/org/okapibarcode/backend/DataBar14.java // public enum Mode { // /** DataBar-14 */ // LINEAR, // /** DataBar-14 Omnidirectional */ // OMNI, // /** DataBar-14 Omnidirectional Stacked */ // STACKED // } // Path: src/main/java/uk/org/okapibarcode/backend/Composite.java import static uk.org.okapibarcode.util.Arrays.positionOf; import static uk.org.okapibarcode.util.Strings.binaryAppend; import java.awt.geom.Rectangle2D; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import uk.org.okapibarcode.backend.DataBar14.Mode; case 1: infoLine("0"); break; case 2: infoLine("10"); break; case 3: infoLine("11"); break; } binary_string = new StringBuilder(); if (encoding_method == 1) { binary_string.append('0'); } if (encoding_method == 2) { /* Encoding Method field "10" - date and lot number */ binary_string.append("10"); if (inputData[1] == '0') { /* No date data */ binary_string.append("11"); } else { /* Production Date (11) or Expiration Date (17) */ group_val = ((10 * (inputData[2] - '0')) + (inputData[3] - '0')) * 384; group_val += (((10 * (inputData[4] - '0')) + (inputData[5] - '0')) - 1) * 32; group_val += (10 * (inputData[6] - '0')) + (inputData[7] - '0');
binaryAppend(binary_string, group_val, 16);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/Composite.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // // Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static void binaryAppend(StringBuilder s, int value, int digits) { // int start = 0x01 << (digits - 1); // for (int i = 0; i < digits; i++) { // if ((value & (start >> i)) == 0) { // s.append('0'); // } else { // s.append('1'); // } // } // } // // Path: src/main/java/uk/org/okapibarcode/backend/DataBar14.java // public enum Mode { // /** DataBar-14 */ // LINEAR, // /** DataBar-14 Omnidirectional */ // OMNI, // /** DataBar-14 Omnidirectional Stacked */ // STACKED // }
import static uk.org.okapibarcode.util.Arrays.positionOf; import static uk.org.okapibarcode.util.Strings.binaryAppend; import java.awt.geom.Rectangle2D; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import uk.org.okapibarcode.backend.DataBar14.Mode;
codebarre += CODAGEMC[offset + dummy[3]]; codebarre += "1"; } if (cc_width == 4) { codebarre += "1"; codebarre += CODAGEMC[offset + dummy[4]]; codebarre += "1"; } codebarre += RAPLR[RightRAP]; codebarre += "1"; /* stop */ /* Now codebarre is a mixture of letters and numbers */ flip = 1; bin.setLength(0); for (loop = 0; loop < codebarre.length(); loop++) { if ((codebarre.charAt(loop) >= '0') && (codebarre.charAt(loop) <= '9')) { for (k = 0; k < codebarre.charAt(loop) - '0'; k++) { if (flip == 0) { bin.append('0'); } else { bin.append('1'); } } if (flip == 0) { flip = 1; } else { flip = 0; } } else {
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // // Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static void binaryAppend(StringBuilder s, int value, int digits) { // int start = 0x01 << (digits - 1); // for (int i = 0; i < digits; i++) { // if ((value & (start >> i)) == 0) { // s.append('0'); // } else { // s.append('1'); // } // } // } // // Path: src/main/java/uk/org/okapibarcode/backend/DataBar14.java // public enum Mode { // /** DataBar-14 */ // LINEAR, // /** DataBar-14 Omnidirectional */ // OMNI, // /** DataBar-14 Omnidirectional Stacked */ // STACKED // } // Path: src/main/java/uk/org/okapibarcode/backend/Composite.java import static uk.org.okapibarcode.util.Arrays.positionOf; import static uk.org.okapibarcode.util.Strings.binaryAppend; import java.awt.geom.Rectangle2D; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import uk.org.okapibarcode.backend.DataBar14.Mode; codebarre += CODAGEMC[offset + dummy[3]]; codebarre += "1"; } if (cc_width == 4) { codebarre += "1"; codebarre += CODAGEMC[offset + dummy[4]]; codebarre += "1"; } codebarre += RAPLR[RightRAP]; codebarre += "1"; /* stop */ /* Now codebarre is a mixture of letters and numbers */ flip = 1; bin.setLength(0); for (loop = 0; loop < codebarre.length(); loop++) { if ((codebarre.charAt(loop) >= '0') && (codebarre.charAt(loop) <= '9')) { for (k = 0; k < codebarre.charAt(loop) - '0'; k++) { if (flip == 0) { bin.append('0'); } else { bin.append('1'); } } if (flip == 0) { flip = 1; } else { flip = 0; } } else {
bin.append(PDF_TTF[positionOf(codebarre.charAt(loop), BR_SET)]);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/Code93.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf;
* Sets an optional start/stop delimiter to be shown in the human-readable text (defaults to <code>null</code>). * * @param startStopDelimiter an optional start/stop delimiter to be shown in the human-readable text */ public void setStartStopDelimiter(Character startStopDelimiter) { this.startStopDelimiter = startStopDelimiter; } /** * Returns the optional start/stop delimiter to be shown in the human-readable text. * * @return the optional start/stop delimiter to be shown in the human-readable text */ public Character getStartStopDelimiter() { return startStopDelimiter; } /** {@inheritDoc} */ @Override protected void encode() { char[] controlChars = toControlChars(content); int l = controlChars.length; if (!content.matches("[\u0000-\u007F]+")) { throw new OkapiException("Invalid characters in input data"); } int[] values = new int[controlChars.length + 2]; for (int i = 0; i < l; i++) {
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/Code93.java import static uk.org.okapibarcode.util.Arrays.positionOf; * Sets an optional start/stop delimiter to be shown in the human-readable text (defaults to <code>null</code>). * * @param startStopDelimiter an optional start/stop delimiter to be shown in the human-readable text */ public void setStartStopDelimiter(Character startStopDelimiter) { this.startStopDelimiter = startStopDelimiter; } /** * Returns the optional start/stop delimiter to be shown in the human-readable text. * * @return the optional start/stop delimiter to be shown in the human-readable text */ public Character getStartStopDelimiter() { return startStopDelimiter; } /** {@inheritDoc} */ @Override protected void encode() { char[] controlChars = toControlChars(content); int l = controlChars.length; if (!content.matches("[\u0000-\u007F]+")) { throw new OkapiException("Invalid characters in input data"); } int[] values = new int[controlChars.length + 2]; for (int i = 0; i < l; i++) {
values[i] = positionOf(controlChars[i], CODE_93_LOOKUP);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/JapanPost.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf; import java.awt.geom.Rectangle2D; import java.util.Locale;
if ((c >= '0') && (c <= '9')) { inter += c; } if (c == '-') { inter += c; } if ((c >= 'A') && (c <= 'J')) { inter += 'a'; inter += CH_KASUT_SET[(c - 'A')]; } if ((c >= 'K') && (c <= 'O')) { inter += 'b'; inter += CH_KASUT_SET[(c - 'K')]; } if ((c >= 'U') && (c <= 'Z')) { inter += 'c'; inter += CH_KASUT_SET[(c - 'U')]; } } for (i = inter.length(); i < 20; i++) { inter += "d"; } dest = "FD"; sum = 0; for (i = 0; i < 20; i++) {
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/JapanPost.java import static uk.org.okapibarcode.util.Arrays.positionOf; import java.awt.geom.Rectangle2D; import java.util.Locale; if ((c >= '0') && (c <= '9')) { inter += c; } if (c == '-') { inter += c; } if ((c >= 'A') && (c <= 'J')) { inter += 'a'; inter += CH_KASUT_SET[(c - 'A')]; } if ((c >= 'K') && (c <= 'O')) { inter += 'b'; inter += CH_KASUT_SET[(c - 'K')]; } if ((c >= 'U') && (c <= 'Z')) { inter += 'c'; inter += CH_KASUT_SET[(c - 'U')]; } } for (i = inter.length(); i < 20; i++) { inter += "d"; } dest = "FD"; sum = 0; for (i = 0; i < 20; i++) {
dest += JAPAN_TABLE[positionOf(inter.charAt(i), KASUT_SET)];
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/DataBarExpanded.java
// Path: src/main/java/uk/org/okapibarcode/backend/DataBarLimited.java // static int[] getWidths(int val, int n, int elements, int maxWidth, int noNarrow) { // // int bar; // int elmWidth; // int mxwElement; // int subVal, lessVal; // int narrowMask = 0; // int[] widths = new int[elements]; // // for (bar = 0; bar < elements - 1; bar++) { // for (elmWidth = 1, narrowMask |= (1 << bar); ; // elmWidth++, narrowMask &= ~ (1 << bar)) { // /* get all combinations */ // subVal = getCombinations(n - elmWidth - 1, elements - bar - 2); // /* less combinations with no single-module element */ // if ((noNarrow == 0) && (narrowMask == 0) // && (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { // subVal -= getCombinations(n - elmWidth - (elements - bar), elements - bar - 2); // } // /* less combinations with elements > maxVal */ // if (elements - bar - 1 > 1) { // lessVal = 0; // for (mxwElement = n - elmWidth - (elements - bar - 2); // mxwElement > maxWidth; // mxwElement--) { // lessVal += getCombinations(n - elmWidth - mxwElement - 1, elements - bar - 3); // } // subVal -= lessVal * (elements - 1 - bar); // } else if (n - elmWidth > maxWidth) { // subVal--; // } // val -= subVal; // if (val < 0) break; // } // val += subVal; // n -= elmWidth; // widths[bar] = elmWidth; // } // // widths[bar] = n; // // return widths; // } // // Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static void binaryAppend(StringBuilder s, int value, int digits) { // int start = 0x01 << (digits - 1); // for (int i = 0; i < digits; i++) { // if ((value & (start >> i)) == 0) { // s.append('0'); // } else { // s.append('1'); // } // } // }
import static uk.org.okapibarcode.backend.DataBarLimited.getWidths; import static uk.org.okapibarcode.util.Strings.binaryAppend; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean;
for (i = 0; i < data_chars; i++) { vs[i] = 0; for (j = 0; j < 12; j++) { if (binaryString.charAt((i * 12) + j) == '1') { vs[i] += 2048 >> j; } } infoSpace(vs[i]); } infoLine(); for (i = 0; i < data_chars; i++) { if (vs[i] <= 347) { group[i] = 1; } if ((vs[i] >= 348) && (vs[i] <= 1387)) { group[i] = 2; } if ((vs[i] >= 1388) && (vs[i] <= 2947)) { group[i] = 3; } if ((vs[i] >= 2948) && (vs[i] <= 3987)) { group[i] = 4; } if (vs[i] >= 3988) { group[i] = 5; } v_odd[i] = (vs[i] - G_SUM_EXP[group[i] - 1]) / T_EVEN_EXP[group[i] - 1]; v_even[i] = (vs[i] - G_SUM_EXP[group[i] - 1]) % T_EVEN_EXP[group[i] - 1];
// Path: src/main/java/uk/org/okapibarcode/backend/DataBarLimited.java // static int[] getWidths(int val, int n, int elements, int maxWidth, int noNarrow) { // // int bar; // int elmWidth; // int mxwElement; // int subVal, lessVal; // int narrowMask = 0; // int[] widths = new int[elements]; // // for (bar = 0; bar < elements - 1; bar++) { // for (elmWidth = 1, narrowMask |= (1 << bar); ; // elmWidth++, narrowMask &= ~ (1 << bar)) { // /* get all combinations */ // subVal = getCombinations(n - elmWidth - 1, elements - bar - 2); // /* less combinations with no single-module element */ // if ((noNarrow == 0) && (narrowMask == 0) // && (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { // subVal -= getCombinations(n - elmWidth - (elements - bar), elements - bar - 2); // } // /* less combinations with elements > maxVal */ // if (elements - bar - 1 > 1) { // lessVal = 0; // for (mxwElement = n - elmWidth - (elements - bar - 2); // mxwElement > maxWidth; // mxwElement--) { // lessVal += getCombinations(n - elmWidth - mxwElement - 1, elements - bar - 3); // } // subVal -= lessVal * (elements - 1 - bar); // } else if (n - elmWidth > maxWidth) { // subVal--; // } // val -= subVal; // if (val < 0) break; // } // val += subVal; // n -= elmWidth; // widths[bar] = elmWidth; // } // // widths[bar] = n; // // return widths; // } // // Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static void binaryAppend(StringBuilder s, int value, int digits) { // int start = 0x01 << (digits - 1); // for (int i = 0; i < digits; i++) { // if ((value & (start >> i)) == 0) { // s.append('0'); // } else { // s.append('1'); // } // } // } // Path: src/main/java/uk/org/okapibarcode/backend/DataBarExpanded.java import static uk.org.okapibarcode.backend.DataBarLimited.getWidths; import static uk.org.okapibarcode.util.Strings.binaryAppend; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; for (i = 0; i < data_chars; i++) { vs[i] = 0; for (j = 0; j < 12; j++) { if (binaryString.charAt((i * 12) + j) == '1') { vs[i] += 2048 >> j; } } infoSpace(vs[i]); } infoLine(); for (i = 0; i < data_chars; i++) { if (vs[i] <= 347) { group[i] = 1; } if ((vs[i] >= 348) && (vs[i] <= 1387)) { group[i] = 2; } if ((vs[i] >= 1388) && (vs[i] <= 2947)) { group[i] = 3; } if ((vs[i] >= 2948) && (vs[i] <= 3987)) { group[i] = 4; } if (vs[i] >= 3988) { group[i] = 5; } v_odd[i] = (vs[i] - G_SUM_EXP[group[i] - 1]) / T_EVEN_EXP[group[i] - 1]; v_even[i] = (vs[i] - G_SUM_EXP[group[i] - 1]) % T_EVEN_EXP[group[i] - 1];
int[] widths = getWidths(v_odd[i], MODULES_ODD_EXP[group[i] - 1], 4, WIDEST_ODD_EXP[group[i] - 1], 0);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/DataBarExpanded.java
// Path: src/main/java/uk/org/okapibarcode/backend/DataBarLimited.java // static int[] getWidths(int val, int n, int elements, int maxWidth, int noNarrow) { // // int bar; // int elmWidth; // int mxwElement; // int subVal, lessVal; // int narrowMask = 0; // int[] widths = new int[elements]; // // for (bar = 0; bar < elements - 1; bar++) { // for (elmWidth = 1, narrowMask |= (1 << bar); ; // elmWidth++, narrowMask &= ~ (1 << bar)) { // /* get all combinations */ // subVal = getCombinations(n - elmWidth - 1, elements - bar - 2); // /* less combinations with no single-module element */ // if ((noNarrow == 0) && (narrowMask == 0) // && (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { // subVal -= getCombinations(n - elmWidth - (elements - bar), elements - bar - 2); // } // /* less combinations with elements > maxVal */ // if (elements - bar - 1 > 1) { // lessVal = 0; // for (mxwElement = n - elmWidth - (elements - bar - 2); // mxwElement > maxWidth; // mxwElement--) { // lessVal += getCombinations(n - elmWidth - mxwElement - 1, elements - bar - 3); // } // subVal -= lessVal * (elements - 1 - bar); // } else if (n - elmWidth > maxWidth) { // subVal--; // } // val -= subVal; // if (val < 0) break; // } // val += subVal; // n -= elmWidth; // widths[bar] = elmWidth; // } // // widths[bar] = n; // // return widths; // } // // Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static void binaryAppend(StringBuilder s, int value, int digits) { // int start = 0x01 << (digits - 1); // for (int i = 0; i < digits; i++) { // if ((value & (start >> i)) == 0) { // s.append('0'); // } else { // s.append('1'); // } // } // }
import static uk.org.okapibarcode.backend.DataBarLimited.getWidths; import static uk.org.okapibarcode.util.Strings.binaryAppend; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean;
case 4: binaryString.append("0101"); read_posn = inputData.length; break; case 5: binaryString.append("01100XX"); read_posn = 20; break; case 6: binaryString.append("01101XX"); read_posn = 23; break; default: /* modes 7 (0111000) to 14 (0111111) */ binaryString.append("0" + Integer.toBinaryString(56 + encodingMethod - 7)); read_posn = inputData.length; break; } /* Verify that the data to be placed in the compressed data field is all numeric data before carrying out compression */ for (i = 0; i < read_posn; i++) { if (inputData[i] < '0' || inputData[i] > '9') { /* Something is wrong */ throw new OkapiException("Invalid characters in input data"); } } /* Now encode the compressed data field */ if (encodingMethod == 1) { /* Encoding method field "1" - general item identification data */
// Path: src/main/java/uk/org/okapibarcode/backend/DataBarLimited.java // static int[] getWidths(int val, int n, int elements, int maxWidth, int noNarrow) { // // int bar; // int elmWidth; // int mxwElement; // int subVal, lessVal; // int narrowMask = 0; // int[] widths = new int[elements]; // // for (bar = 0; bar < elements - 1; bar++) { // for (elmWidth = 1, narrowMask |= (1 << bar); ; // elmWidth++, narrowMask &= ~ (1 << bar)) { // /* get all combinations */ // subVal = getCombinations(n - elmWidth - 1, elements - bar - 2); // /* less combinations with no single-module element */ // if ((noNarrow == 0) && (narrowMask == 0) // && (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { // subVal -= getCombinations(n - elmWidth - (elements - bar), elements - bar - 2); // } // /* less combinations with elements > maxVal */ // if (elements - bar - 1 > 1) { // lessVal = 0; // for (mxwElement = n - elmWidth - (elements - bar - 2); // mxwElement > maxWidth; // mxwElement--) { // lessVal += getCombinations(n - elmWidth - mxwElement - 1, elements - bar - 3); // } // subVal -= lessVal * (elements - 1 - bar); // } else if (n - elmWidth > maxWidth) { // subVal--; // } // val -= subVal; // if (val < 0) break; // } // val += subVal; // n -= elmWidth; // widths[bar] = elmWidth; // } // // widths[bar] = n; // // return widths; // } // // Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static void binaryAppend(StringBuilder s, int value, int digits) { // int start = 0x01 << (digits - 1); // for (int i = 0; i < digits; i++) { // if ((value & (start >> i)) == 0) { // s.append('0'); // } else { // s.append('1'); // } // } // } // Path: src/main/java/uk/org/okapibarcode/backend/DataBarExpanded.java import static uk.org.okapibarcode.backend.DataBarLimited.getWidths; import static uk.org.okapibarcode.util.Strings.binaryAppend; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; case 4: binaryString.append("0101"); read_posn = inputData.length; break; case 5: binaryString.append("01100XX"); read_posn = 20; break; case 6: binaryString.append("01101XX"); read_posn = 23; break; default: /* modes 7 (0111000) to 14 (0111111) */ binaryString.append("0" + Integer.toBinaryString(56 + encodingMethod - 7)); read_posn = inputData.length; break; } /* Verify that the data to be placed in the compressed data field is all numeric data before carrying out compression */ for (i = 0; i < read_posn; i++) { if (inputData[i] < '0' || inputData[i] > '9') { /* Something is wrong */ throw new OkapiException("Invalid characters in input data"); } } /* Now encode the compressed data field */ if (encodingMethod == 1) { /* Encoding method field "1" - general item identification data */
binaryAppend(binaryString, inputData[2] - '0', 4);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/Codabar.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf;
/* * Copyright 2014 Robin Stuart * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.backend; /** * <p>Implements Codabar barcode symbology according to BS EN 798:1996. * * <p>Also known as NW-7, Monarch, ABC Codabar, USD-4, Ames Code and Code 27. * Codabar can encode any length string starting and ending with the letters * A-D and containing between these letters the numbers 0-9, dash (-), dollar * ($), colon (:), slash (/), full stop (.) or plus (+). No check digit is * generated. * * @author <a href="mailto:jakel2006@me.com">Robert Elliott</a> */ public class Codabar extends Symbol { private static final String[] CODABAR_TABLE = { "11111221", "11112211", "11121121", "22111111", "11211211", "21111211", "12111121", "12112111", "12211111", "21121111", "11122111", "11221111", "21112121", "21211121", "21212111", "11212121", "11221211", "12121121", "11121221", "11122211" }; private static final char[] CHARACTER_SET = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '$', ':', '/', '.', '+', 'A', 'B', 'C', 'D' }; /** Ratio of wide bar width to narrow bar width. */ private double moduleWidthRatio = 2; /** * Sets the ratio of wide bar width to narrow bar width. Valid values are usually * between {@code 2} and {@code 3}. The default value is {@code 2}. * * @param moduleWidthRatio the ratio of wide bar width to narrow bar width */ public void setModuleWidthRatio(double moduleWidthRatio) { this.moduleWidthRatio = moduleWidthRatio; } /** * Returns the ratio of wide bar width to narrow bar width. * * @return the ratio of wide bar width to narrow bar width */ public double getModuleWidthRatio() { return moduleWidthRatio; } /** {@inheritDoc} */ @Override protected void encode() { if (!content.matches("[A-D]{1}[0-9:/\\$\\.\\+\u002D]+[A-D]{1}")) { throw new OkapiException("Invalid characters in input"); } String horizontalSpacing = ""; int l = content.length(); for (int i = 0; i < l; i++) {
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/Codabar.java import static uk.org.okapibarcode.util.Arrays.positionOf; /* * Copyright 2014 Robin Stuart * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.backend; /** * <p>Implements Codabar barcode symbology according to BS EN 798:1996. * * <p>Also known as NW-7, Monarch, ABC Codabar, USD-4, Ames Code and Code 27. * Codabar can encode any length string starting and ending with the letters * A-D and containing between these letters the numbers 0-9, dash (-), dollar * ($), colon (:), slash (/), full stop (.) or plus (+). No check digit is * generated. * * @author <a href="mailto:jakel2006@me.com">Robert Elliott</a> */ public class Codabar extends Symbol { private static final String[] CODABAR_TABLE = { "11111221", "11112211", "11121121", "22111111", "11211211", "21111211", "12111121", "12112111", "12211111", "21121111", "11122111", "11221111", "21112121", "21211121", "21212111", "11212121", "11221211", "12121121", "11121221", "11122211" }; private static final char[] CHARACTER_SET = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '$', ':', '/', '.', '+', 'A', 'B', 'C', 'D' }; /** Ratio of wide bar width to narrow bar width. */ private double moduleWidthRatio = 2; /** * Sets the ratio of wide bar width to narrow bar width. Valid values are usually * between {@code 2} and {@code 3}. The default value is {@code 2}. * * @param moduleWidthRatio the ratio of wide bar width to narrow bar width */ public void setModuleWidthRatio(double moduleWidthRatio) { this.moduleWidthRatio = moduleWidthRatio; } /** * Returns the ratio of wide bar width to narrow bar width. * * @return the ratio of wide bar width to narrow bar width */ public double getModuleWidthRatio() { return moduleWidthRatio; } /** {@inheritDoc} */ @Override protected void encode() { if (!content.matches("[A-D]{1}[0-9:/\\$\\.\\+\u002D]+[A-D]{1}")) { throw new OkapiException("Invalid characters in input"); } String horizontalSpacing = ""; int l = content.length(); for (int i = 0; i < l; i++) {
horizontalSpacing += CODABAR_TABLE[positionOf(content.charAt(i), CHARACTER_SET)];
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/QrCode.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf; import java.nio.CharBuffer; import java.nio.charset.Charset;
int percentCount = 0; if (gs1) { for (i = 0; i < short_data_block_length; i++) { if (inputData[position + i] == '%') { percentCount++; } } } int[] inputExpanded = new int[short_data_block_length + percentCount]; percentCount = 0; for (i = 0; i < short_data_block_length; i++) { int c = inputData[position + i]; if (c == FNC1) { inputExpanded[i + percentCount] = '%'; /* FNC1 */ } else { inputExpanded[i + percentCount] = c; if (gs1 && c == '%') { percentCount++; inputExpanded[i + percentCount] = c; } } } /* Character count indicator */ binaryAppend(inputExpanded.length, tribus(version, 9, 11, 13), binary); info("ALPH "); /* Character representation */ for (i = 0; i + 1 < inputExpanded.length; i += 2) {
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/QrCode.java import static uk.org.okapibarcode.util.Arrays.positionOf; import java.nio.CharBuffer; import java.nio.charset.Charset; int percentCount = 0; if (gs1) { for (i = 0; i < short_data_block_length; i++) { if (inputData[position + i] == '%') { percentCount++; } } } int[] inputExpanded = new int[short_data_block_length + percentCount]; percentCount = 0; for (i = 0; i < short_data_block_length; i++) { int c = inputData[position + i]; if (c == FNC1) { inputExpanded[i + percentCount] = '%'; /* FNC1 */ } else { inputExpanded[i + percentCount] = c; if (gs1 && c == '%') { percentCount++; inputExpanded[i + percentCount] = c; } } } /* Character count indicator */ binaryAppend(inputExpanded.length, tribus(version, 9, 11, 13), binary); info("ALPH "); /* Character representation */ for (i = 0; i + 1 < inputExpanded.length; i += 2) {
int first = positionOf((char) inputExpanded[i], RHODIUM);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/Pdf417.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf; import java.math.BigInteger; import java.util.ArrayList; import java.util.List;
switch (i % 3) { case 0: offset = 0; // cluster 0 dummy[0] = k + c1; // left row indicator dummy[columns + 1] = k + c3; // right row indicator break; case 1: offset = 929; // cluster 3 dummy[0] = k + c2; // left row indicator dummy[columns + 1] = k + c1; // right row indicator break; case 2: offset = 1858; // cluster 6 dummy[0] = k + c3; // left row indicator dummy[columns + 1] = k + c2; // right row indicator break; } codebarre.setLength(0); codebarre.append("+*"); for (j = 0; j <= columns + 1; j++) { if (!(symbolMode == Mode.TRUNCATED && j > columns)) { codebarre.append(CODAGEMC[offset + dummy[j]]); codebarre.append('*'); } } if(symbolMode != Mode.TRUNCATED) { codebarre.append('-'); } bin.setLength(0); for (j = 0; j < codebarre.length(); j++) {
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/Pdf417.java import static uk.org.okapibarcode.util.Arrays.positionOf; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; switch (i % 3) { case 0: offset = 0; // cluster 0 dummy[0] = k + c1; // left row indicator dummy[columns + 1] = k + c3; // right row indicator break; case 1: offset = 929; // cluster 3 dummy[0] = k + c2; // left row indicator dummy[columns + 1] = k + c1; // right row indicator break; case 2: offset = 1858; // cluster 6 dummy[0] = k + c3; // left row indicator dummy[columns + 1] = k + c2; // right row indicator break; } codebarre.setLength(0); codebarre.append("+*"); for (j = 0; j <= columns + 1; j++) { if (!(symbolMode == Mode.TRUNCATED && j > columns)) { codebarre.append(CODAGEMC[offset + dummy[j]]); codebarre.append('*'); } } if(symbolMode != Mode.TRUNCATED) { codebarre.append('-'); } bin.setLength(0); for (j = 0; j < codebarre.length(); j++) {
bin.append(PDF_TTF[positionOf(codebarre.charAt(j), BR_SET)]);
woo-j/OkapiBarcode
src/test/java/uk/org/okapibarcode/util/StringsTest.java
// Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static String escape(String s) { // StringBuilder sb = new StringBuilder(s.length() + 10); // for (int i = 0; i < s.length(); i++) { // char c = s.charAt(i); // switch (c) { // case '\u0000': // sb.append("\\0"); // null // break; // case '\u0004': // sb.append("\\E"); // end of transmission // break; // case '\u0007': // sb.append("\\a"); // bell // break; // case '\u0008': // sb.append("\\b"); // backspace // break; // case '\u0009': // sb.append("\\t"); // horizontal tab // break; // case '\n': // sb.append("\\n"); // line feed // break; // case '\u000b': // sb.append("\\v"); // vertical tab // break; // case '\u000c': // sb.append("\\f"); // form feed // break; // case '\r': // sb.append("\\r"); // carriage return // break; // case '\u001b': // sb.append("\\e"); // escape // break; // case '\u001d': // sb.append("\\G"); // group separator // break; // case '\u001e': // sb.append("\\R"); // record separator // break; // case '\\': // sb.append("\\\\"); // escape the escape character // break; // default: // if (c >= 32 && c <= 126) { // sb.append(c); // printable ASCII // } else { // byte[] bytes = String.valueOf(c).getBytes(ISO_8859_1); // String hex = String.format("%02X", bytes[0] & 0xFF); // sb.append("\\x").append(hex); // } // break; // } // } // return sb.toString(); // } // // Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static String unescape(String s, boolean lenient) { // StringBuilder sb = new StringBuilder(s.length()); // for (int i = 0; i < s.length(); i++) { // char c = s.charAt(i); // if (c != '\\') { // sb.append(c); // } else { // if (i + 1 >= s.length()) { // String msg = "Error processing escape sequences: expected escape character, found end of string"; // throw new OkapiException(msg); // } else { // char c2 = s.charAt(i + 1); // switch (c2) { // case '0': // sb.append('\u0000'); // null // i++; // break; // case 'E': // sb.append('\u0004'); // end of transmission // i++; // break; // case 'a': // sb.append('\u0007'); // bell // i++; // break; // case 'b': // sb.append('\u0008'); // backspace // i++; // break; // case 't': // sb.append('\u0009'); // horizontal tab // i++; // break; // case 'n': // sb.append('\n'); // line feed // i++; // break; // case 'v': // sb.append('\u000b'); // vertical tab // i++; // break; // case 'f': // sb.append('\u000c'); // form feed // i++; // break; // case 'r': // sb.append('\r'); // carriage return // i++; // break; // case 'e': // sb.append('\u001b'); // escape // i++; // break; // case 'G': // sb.append('\u001d'); // group separator // i++; // break; // case 'R': // sb.append('\u001e'); // record separator // i++; // break; // case '\\': // sb.append('\\'); // escape the escape character // i++; // break; // case 'x': // if (i + 3 >= s.length()) { // String msg = "Error processing escape sequences: expected hex sequence, found end of string"; // throw new OkapiException(msg); // } else { // char c3 = s.charAt(i + 2); // char c4 = s.charAt(i + 3); // if (isHex(c3) && isHex(c4)) { // byte b = (byte) Integer.parseInt("" + c3 + c4, 16); // sb.append(new String(new byte[] { b }, StandardCharsets.ISO_8859_1)); // i += 3; // } else { // String msg = "Error processing escape sequences: expected hex sequence, found '" + c3 + c4 + "'"; // throw new OkapiException(msg); // } // } // break; // default: // if (lenient) { // sb.append(c); // } else { // throw new OkapiException("Error processing escape sequences: expected valid escape character, found '" + c2 + "'"); // } // } // } // } // } // return sb.toString(); // }
import static org.junit.Assert.assertEquals; import static uk.org.okapibarcode.util.Strings.escape; import static uk.org.okapibarcode.util.Strings.unescape; import org.junit.Test;
/* * Copyright 2020 Daniel Gredler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.util; /** * Tests for {@link Strings}. */ public class StringsTest { @Test public void testUnescape() {
// Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static String escape(String s) { // StringBuilder sb = new StringBuilder(s.length() + 10); // for (int i = 0; i < s.length(); i++) { // char c = s.charAt(i); // switch (c) { // case '\u0000': // sb.append("\\0"); // null // break; // case '\u0004': // sb.append("\\E"); // end of transmission // break; // case '\u0007': // sb.append("\\a"); // bell // break; // case '\u0008': // sb.append("\\b"); // backspace // break; // case '\u0009': // sb.append("\\t"); // horizontal tab // break; // case '\n': // sb.append("\\n"); // line feed // break; // case '\u000b': // sb.append("\\v"); // vertical tab // break; // case '\u000c': // sb.append("\\f"); // form feed // break; // case '\r': // sb.append("\\r"); // carriage return // break; // case '\u001b': // sb.append("\\e"); // escape // break; // case '\u001d': // sb.append("\\G"); // group separator // break; // case '\u001e': // sb.append("\\R"); // record separator // break; // case '\\': // sb.append("\\\\"); // escape the escape character // break; // default: // if (c >= 32 && c <= 126) { // sb.append(c); // printable ASCII // } else { // byte[] bytes = String.valueOf(c).getBytes(ISO_8859_1); // String hex = String.format("%02X", bytes[0] & 0xFF); // sb.append("\\x").append(hex); // } // break; // } // } // return sb.toString(); // } // // Path: src/main/java/uk/org/okapibarcode/util/Strings.java // public static String unescape(String s, boolean lenient) { // StringBuilder sb = new StringBuilder(s.length()); // for (int i = 0; i < s.length(); i++) { // char c = s.charAt(i); // if (c != '\\') { // sb.append(c); // } else { // if (i + 1 >= s.length()) { // String msg = "Error processing escape sequences: expected escape character, found end of string"; // throw new OkapiException(msg); // } else { // char c2 = s.charAt(i + 1); // switch (c2) { // case '0': // sb.append('\u0000'); // null // i++; // break; // case 'E': // sb.append('\u0004'); // end of transmission // i++; // break; // case 'a': // sb.append('\u0007'); // bell // i++; // break; // case 'b': // sb.append('\u0008'); // backspace // i++; // break; // case 't': // sb.append('\u0009'); // horizontal tab // i++; // break; // case 'n': // sb.append('\n'); // line feed // i++; // break; // case 'v': // sb.append('\u000b'); // vertical tab // i++; // break; // case 'f': // sb.append('\u000c'); // form feed // i++; // break; // case 'r': // sb.append('\r'); // carriage return // i++; // break; // case 'e': // sb.append('\u001b'); // escape // i++; // break; // case 'G': // sb.append('\u001d'); // group separator // i++; // break; // case 'R': // sb.append('\u001e'); // record separator // i++; // break; // case '\\': // sb.append('\\'); // escape the escape character // i++; // break; // case 'x': // if (i + 3 >= s.length()) { // String msg = "Error processing escape sequences: expected hex sequence, found end of string"; // throw new OkapiException(msg); // } else { // char c3 = s.charAt(i + 2); // char c4 = s.charAt(i + 3); // if (isHex(c3) && isHex(c4)) { // byte b = (byte) Integer.parseInt("" + c3 + c4, 16); // sb.append(new String(new byte[] { b }, StandardCharsets.ISO_8859_1)); // i += 3; // } else { // String msg = "Error processing escape sequences: expected hex sequence, found '" + c3 + c4 + "'"; // throw new OkapiException(msg); // } // } // break; // default: // if (lenient) { // sb.append(c); // } else { // throw new OkapiException("Error processing escape sequences: expected valid escape character, found '" + c2 + "'"); // } // } // } // } // } // return sb.toString(); // } // Path: src/test/java/uk/org/okapibarcode/util/StringsTest.java import static org.junit.Assert.assertEquals; import static uk.org.okapibarcode.util.Strings.escape; import static uk.org.okapibarcode.util.Strings.unescape; import org.junit.Test; /* * Copyright 2020 Daniel Gredler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.util; /** * Tests for {@link Strings}. */ public class StringsTest { @Test public void testUnescape() {
assertEquals("", unescape("", false));
woo-j/OkapiBarcode
src/test/java/uk/org/okapibarcode/backend/SymbolBasicTest.java
// Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC1 = -1; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC2 = -2; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC3 = -3; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC4 = -4; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static int[] toBytes(String s, Charset charset, int... suffix) { // // if (!charset.newEncoder().canEncode(s)) { // return null; // } // // byte[] fnc1 = FNC1_STRING.getBytes(charset); // byte[] fnc2 = FNC2_STRING.getBytes(charset); // byte[] fnc3 = FNC3_STRING.getBytes(charset); // byte[] fnc4 = FNC4_STRING.getBytes(charset); // // byte[] bytes = s.getBytes(charset); // int[] data = new int[bytes.length + suffix.length]; // // int i = 0, j = 0; // for (; i < bytes.length; i++, j++) { // if (containsAt(bytes, fnc1, i)) { // data[j] = FNC1; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc2, i)) { // data[j] = FNC2; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc3, i)) { // data[j] = FNC3; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc4, i)) { // data[j] = FNC4; // i += fnc1.length - 1; // } else { // data[j] = bytes[i] & 0xff; // } // } // // int k = 0; // for (; k < suffix.length; k++) { // data[j + k] = suffix[k]; // } // // if (j + k < i) { // data = Arrays.copyOf(data, j + k); // } // // return data; // }
import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertArrayEquals; import static uk.org.okapibarcode.backend.Symbol.FNC1; import static uk.org.okapibarcode.backend.Symbol.FNC2; import static uk.org.okapibarcode.backend.Symbol.FNC3; import static uk.org.okapibarcode.backend.Symbol.FNC4; import static uk.org.okapibarcode.backend.Symbol.toBytes; import java.nio.charset.Charset; import org.junit.Test;
package uk.org.okapibarcode.backend; public class SymbolBasicTest { @Test public void testToBytes() {
// Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC1 = -1; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC2 = -2; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC3 = -3; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC4 = -4; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static int[] toBytes(String s, Charset charset, int... suffix) { // // if (!charset.newEncoder().canEncode(s)) { // return null; // } // // byte[] fnc1 = FNC1_STRING.getBytes(charset); // byte[] fnc2 = FNC2_STRING.getBytes(charset); // byte[] fnc3 = FNC3_STRING.getBytes(charset); // byte[] fnc4 = FNC4_STRING.getBytes(charset); // // byte[] bytes = s.getBytes(charset); // int[] data = new int[bytes.length + suffix.length]; // // int i = 0, j = 0; // for (; i < bytes.length; i++, j++) { // if (containsAt(bytes, fnc1, i)) { // data[j] = FNC1; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc2, i)) { // data[j] = FNC2; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc3, i)) { // data[j] = FNC3; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc4, i)) { // data[j] = FNC4; // i += fnc1.length - 1; // } else { // data[j] = bytes[i] & 0xff; // } // } // // int k = 0; // for (; k < suffix.length; k++) { // data[j + k] = suffix[k]; // } // // if (j + k < i) { // data = Arrays.copyOf(data, j + k); // } // // return data; // } // Path: src/test/java/uk/org/okapibarcode/backend/SymbolBasicTest.java import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertArrayEquals; import static uk.org.okapibarcode.backend.Symbol.FNC1; import static uk.org.okapibarcode.backend.Symbol.FNC2; import static uk.org.okapibarcode.backend.Symbol.FNC3; import static uk.org.okapibarcode.backend.Symbol.FNC4; import static uk.org.okapibarcode.backend.Symbol.toBytes; import java.nio.charset.Charset; import org.junit.Test; package uk.org.okapibarcode.backend; public class SymbolBasicTest { @Test public void testToBytes() {
assertArrayEquals(null, toBytes("\u00e9", US_ASCII));
woo-j/OkapiBarcode
src/test/java/uk/org/okapibarcode/backend/SymbolBasicTest.java
// Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC1 = -1; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC2 = -2; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC3 = -3; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC4 = -4; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static int[] toBytes(String s, Charset charset, int... suffix) { // // if (!charset.newEncoder().canEncode(s)) { // return null; // } // // byte[] fnc1 = FNC1_STRING.getBytes(charset); // byte[] fnc2 = FNC2_STRING.getBytes(charset); // byte[] fnc3 = FNC3_STRING.getBytes(charset); // byte[] fnc4 = FNC4_STRING.getBytes(charset); // // byte[] bytes = s.getBytes(charset); // int[] data = new int[bytes.length + suffix.length]; // // int i = 0, j = 0; // for (; i < bytes.length; i++, j++) { // if (containsAt(bytes, fnc1, i)) { // data[j] = FNC1; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc2, i)) { // data[j] = FNC2; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc3, i)) { // data[j] = FNC3; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc4, i)) { // data[j] = FNC4; // i += fnc1.length - 1; // } else { // data[j] = bytes[i] & 0xff; // } // } // // int k = 0; // for (; k < suffix.length; k++) { // data[j + k] = suffix[k]; // } // // if (j + k < i) { // data = Arrays.copyOf(data, j + k); // } // // return data; // }
import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertArrayEquals; import static uk.org.okapibarcode.backend.Symbol.FNC1; import static uk.org.okapibarcode.backend.Symbol.FNC2; import static uk.org.okapibarcode.backend.Symbol.FNC3; import static uk.org.okapibarcode.backend.Symbol.FNC4; import static uk.org.okapibarcode.backend.Symbol.toBytes; import java.nio.charset.Charset; import org.junit.Test;
package uk.org.okapibarcode.backend; public class SymbolBasicTest { @Test public void testToBytes() { assertArrayEquals(null, toBytes("\u00e9", US_ASCII)); assertArrayEquals(new int[] { 0xC3, 0xA9 }, toBytes("\u00e9", UTF_8)); testToBytes(Charset.forName("ISO-8859-1")); testToBytes(Charset.forName("ISO-8859-2")); testToBytes(Charset.forName("ISO-8859-3")); testToBytes(Charset.forName("ISO-8859-4")); testToBytes(Charset.forName("ISO-8859-5")); testToBytes(Charset.forName("ISO-8859-6")); testToBytes(Charset.forName("ISO-8859-7")); testToBytes(Charset.forName("ISO-8859-8")); testToBytes(Charset.forName("ISO-8859-9")); testToBytes(Charset.forName("ISO-8859-11")); testToBytes(Charset.forName("ISO-8859-13")); testToBytes(Charset.forName("ISO-8859-15")); testToBytes(Charset.forName("windows-1250")); testToBytes(Charset.forName("windows-1251")); testToBytes(Charset.forName("windows-1252")); testToBytes(Charset.forName("windows-1256")); testToBytes(Charset.forName("SJIS")); testToBytes(Charset.forName("UTF-8")); } private static void testToBytes(Charset charset) { assertArrayEquals(new int[] {}, toBytes("", charset)); assertArrayEquals(new int[] { 'a' }, toBytes("a", charset)); assertArrayEquals(new int[] { 'a', 'b', 'c' }, toBytes("abc", charset));
// Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC1 = -1; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC2 = -2; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC3 = -3; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC4 = -4; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static int[] toBytes(String s, Charset charset, int... suffix) { // // if (!charset.newEncoder().canEncode(s)) { // return null; // } // // byte[] fnc1 = FNC1_STRING.getBytes(charset); // byte[] fnc2 = FNC2_STRING.getBytes(charset); // byte[] fnc3 = FNC3_STRING.getBytes(charset); // byte[] fnc4 = FNC4_STRING.getBytes(charset); // // byte[] bytes = s.getBytes(charset); // int[] data = new int[bytes.length + suffix.length]; // // int i = 0, j = 0; // for (; i < bytes.length; i++, j++) { // if (containsAt(bytes, fnc1, i)) { // data[j] = FNC1; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc2, i)) { // data[j] = FNC2; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc3, i)) { // data[j] = FNC3; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc4, i)) { // data[j] = FNC4; // i += fnc1.length - 1; // } else { // data[j] = bytes[i] & 0xff; // } // } // // int k = 0; // for (; k < suffix.length; k++) { // data[j + k] = suffix[k]; // } // // if (j + k < i) { // data = Arrays.copyOf(data, j + k); // } // // return data; // } // Path: src/test/java/uk/org/okapibarcode/backend/SymbolBasicTest.java import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertArrayEquals; import static uk.org.okapibarcode.backend.Symbol.FNC1; import static uk.org.okapibarcode.backend.Symbol.FNC2; import static uk.org.okapibarcode.backend.Symbol.FNC3; import static uk.org.okapibarcode.backend.Symbol.FNC4; import static uk.org.okapibarcode.backend.Symbol.toBytes; import java.nio.charset.Charset; import org.junit.Test; package uk.org.okapibarcode.backend; public class SymbolBasicTest { @Test public void testToBytes() { assertArrayEquals(null, toBytes("\u00e9", US_ASCII)); assertArrayEquals(new int[] { 0xC3, 0xA9 }, toBytes("\u00e9", UTF_8)); testToBytes(Charset.forName("ISO-8859-1")); testToBytes(Charset.forName("ISO-8859-2")); testToBytes(Charset.forName("ISO-8859-3")); testToBytes(Charset.forName("ISO-8859-4")); testToBytes(Charset.forName("ISO-8859-5")); testToBytes(Charset.forName("ISO-8859-6")); testToBytes(Charset.forName("ISO-8859-7")); testToBytes(Charset.forName("ISO-8859-8")); testToBytes(Charset.forName("ISO-8859-9")); testToBytes(Charset.forName("ISO-8859-11")); testToBytes(Charset.forName("ISO-8859-13")); testToBytes(Charset.forName("ISO-8859-15")); testToBytes(Charset.forName("windows-1250")); testToBytes(Charset.forName("windows-1251")); testToBytes(Charset.forName("windows-1252")); testToBytes(Charset.forName("windows-1256")); testToBytes(Charset.forName("SJIS")); testToBytes(Charset.forName("UTF-8")); } private static void testToBytes(Charset charset) { assertArrayEquals(new int[] {}, toBytes("", charset)); assertArrayEquals(new int[] { 'a' }, toBytes("a", charset)); assertArrayEquals(new int[] { 'a', 'b', 'c' }, toBytes("abc", charset));
assertArrayEquals(new int[] { FNC1 }, toBytes("\\<FNC1>", charset));
woo-j/OkapiBarcode
src/test/java/uk/org/okapibarcode/backend/SymbolBasicTest.java
// Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC1 = -1; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC2 = -2; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC3 = -3; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC4 = -4; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static int[] toBytes(String s, Charset charset, int... suffix) { // // if (!charset.newEncoder().canEncode(s)) { // return null; // } // // byte[] fnc1 = FNC1_STRING.getBytes(charset); // byte[] fnc2 = FNC2_STRING.getBytes(charset); // byte[] fnc3 = FNC3_STRING.getBytes(charset); // byte[] fnc4 = FNC4_STRING.getBytes(charset); // // byte[] bytes = s.getBytes(charset); // int[] data = new int[bytes.length + suffix.length]; // // int i = 0, j = 0; // for (; i < bytes.length; i++, j++) { // if (containsAt(bytes, fnc1, i)) { // data[j] = FNC1; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc2, i)) { // data[j] = FNC2; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc3, i)) { // data[j] = FNC3; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc4, i)) { // data[j] = FNC4; // i += fnc1.length - 1; // } else { // data[j] = bytes[i] & 0xff; // } // } // // int k = 0; // for (; k < suffix.length; k++) { // data[j + k] = suffix[k]; // } // // if (j + k < i) { // data = Arrays.copyOf(data, j + k); // } // // return data; // }
import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertArrayEquals; import static uk.org.okapibarcode.backend.Symbol.FNC1; import static uk.org.okapibarcode.backend.Symbol.FNC2; import static uk.org.okapibarcode.backend.Symbol.FNC3; import static uk.org.okapibarcode.backend.Symbol.FNC4; import static uk.org.okapibarcode.backend.Symbol.toBytes; import java.nio.charset.Charset; import org.junit.Test;
assertArrayEquals(null, toBytes("\u00e9", US_ASCII)); assertArrayEquals(new int[] { 0xC3, 0xA9 }, toBytes("\u00e9", UTF_8)); testToBytes(Charset.forName("ISO-8859-1")); testToBytes(Charset.forName("ISO-8859-2")); testToBytes(Charset.forName("ISO-8859-3")); testToBytes(Charset.forName("ISO-8859-4")); testToBytes(Charset.forName("ISO-8859-5")); testToBytes(Charset.forName("ISO-8859-6")); testToBytes(Charset.forName("ISO-8859-7")); testToBytes(Charset.forName("ISO-8859-8")); testToBytes(Charset.forName("ISO-8859-9")); testToBytes(Charset.forName("ISO-8859-11")); testToBytes(Charset.forName("ISO-8859-13")); testToBytes(Charset.forName("ISO-8859-15")); testToBytes(Charset.forName("windows-1250")); testToBytes(Charset.forName("windows-1251")); testToBytes(Charset.forName("windows-1252")); testToBytes(Charset.forName("windows-1256")); testToBytes(Charset.forName("SJIS")); testToBytes(Charset.forName("UTF-8")); } private static void testToBytes(Charset charset) { assertArrayEquals(new int[] {}, toBytes("", charset)); assertArrayEquals(new int[] { 'a' }, toBytes("a", charset)); assertArrayEquals(new int[] { 'a', 'b', 'c' }, toBytes("abc", charset)); assertArrayEquals(new int[] { FNC1 }, toBytes("\\<FNC1>", charset)); assertArrayEquals(new int[] { 'a', FNC1 }, toBytes("a\\<FNC1>", charset)); assertArrayEquals(new int[] { FNC1, 'a' }, toBytes("\\<FNC1>a", charset));
// Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC1 = -1; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC2 = -2; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC3 = -3; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC4 = -4; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static int[] toBytes(String s, Charset charset, int... suffix) { // // if (!charset.newEncoder().canEncode(s)) { // return null; // } // // byte[] fnc1 = FNC1_STRING.getBytes(charset); // byte[] fnc2 = FNC2_STRING.getBytes(charset); // byte[] fnc3 = FNC3_STRING.getBytes(charset); // byte[] fnc4 = FNC4_STRING.getBytes(charset); // // byte[] bytes = s.getBytes(charset); // int[] data = new int[bytes.length + suffix.length]; // // int i = 0, j = 0; // for (; i < bytes.length; i++, j++) { // if (containsAt(bytes, fnc1, i)) { // data[j] = FNC1; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc2, i)) { // data[j] = FNC2; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc3, i)) { // data[j] = FNC3; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc4, i)) { // data[j] = FNC4; // i += fnc1.length - 1; // } else { // data[j] = bytes[i] & 0xff; // } // } // // int k = 0; // for (; k < suffix.length; k++) { // data[j + k] = suffix[k]; // } // // if (j + k < i) { // data = Arrays.copyOf(data, j + k); // } // // return data; // } // Path: src/test/java/uk/org/okapibarcode/backend/SymbolBasicTest.java import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertArrayEquals; import static uk.org.okapibarcode.backend.Symbol.FNC1; import static uk.org.okapibarcode.backend.Symbol.FNC2; import static uk.org.okapibarcode.backend.Symbol.FNC3; import static uk.org.okapibarcode.backend.Symbol.FNC4; import static uk.org.okapibarcode.backend.Symbol.toBytes; import java.nio.charset.Charset; import org.junit.Test; assertArrayEquals(null, toBytes("\u00e9", US_ASCII)); assertArrayEquals(new int[] { 0xC3, 0xA9 }, toBytes("\u00e9", UTF_8)); testToBytes(Charset.forName("ISO-8859-1")); testToBytes(Charset.forName("ISO-8859-2")); testToBytes(Charset.forName("ISO-8859-3")); testToBytes(Charset.forName("ISO-8859-4")); testToBytes(Charset.forName("ISO-8859-5")); testToBytes(Charset.forName("ISO-8859-6")); testToBytes(Charset.forName("ISO-8859-7")); testToBytes(Charset.forName("ISO-8859-8")); testToBytes(Charset.forName("ISO-8859-9")); testToBytes(Charset.forName("ISO-8859-11")); testToBytes(Charset.forName("ISO-8859-13")); testToBytes(Charset.forName("ISO-8859-15")); testToBytes(Charset.forName("windows-1250")); testToBytes(Charset.forName("windows-1251")); testToBytes(Charset.forName("windows-1252")); testToBytes(Charset.forName("windows-1256")); testToBytes(Charset.forName("SJIS")); testToBytes(Charset.forName("UTF-8")); } private static void testToBytes(Charset charset) { assertArrayEquals(new int[] {}, toBytes("", charset)); assertArrayEquals(new int[] { 'a' }, toBytes("a", charset)); assertArrayEquals(new int[] { 'a', 'b', 'c' }, toBytes("abc", charset)); assertArrayEquals(new int[] { FNC1 }, toBytes("\\<FNC1>", charset)); assertArrayEquals(new int[] { 'a', FNC1 }, toBytes("a\\<FNC1>", charset)); assertArrayEquals(new int[] { FNC1, 'a' }, toBytes("\\<FNC1>a", charset));
assertArrayEquals(new int[] { FNC2 }, toBytes("\\<FNC2>", charset));
woo-j/OkapiBarcode
src/test/java/uk/org/okapibarcode/backend/SymbolBasicTest.java
// Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC1 = -1; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC2 = -2; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC3 = -3; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC4 = -4; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static int[] toBytes(String s, Charset charset, int... suffix) { // // if (!charset.newEncoder().canEncode(s)) { // return null; // } // // byte[] fnc1 = FNC1_STRING.getBytes(charset); // byte[] fnc2 = FNC2_STRING.getBytes(charset); // byte[] fnc3 = FNC3_STRING.getBytes(charset); // byte[] fnc4 = FNC4_STRING.getBytes(charset); // // byte[] bytes = s.getBytes(charset); // int[] data = new int[bytes.length + suffix.length]; // // int i = 0, j = 0; // for (; i < bytes.length; i++, j++) { // if (containsAt(bytes, fnc1, i)) { // data[j] = FNC1; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc2, i)) { // data[j] = FNC2; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc3, i)) { // data[j] = FNC3; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc4, i)) { // data[j] = FNC4; // i += fnc1.length - 1; // } else { // data[j] = bytes[i] & 0xff; // } // } // // int k = 0; // for (; k < suffix.length; k++) { // data[j + k] = suffix[k]; // } // // if (j + k < i) { // data = Arrays.copyOf(data, j + k); // } // // return data; // }
import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertArrayEquals; import static uk.org.okapibarcode.backend.Symbol.FNC1; import static uk.org.okapibarcode.backend.Symbol.FNC2; import static uk.org.okapibarcode.backend.Symbol.FNC3; import static uk.org.okapibarcode.backend.Symbol.FNC4; import static uk.org.okapibarcode.backend.Symbol.toBytes; import java.nio.charset.Charset; import org.junit.Test;
testToBytes(Charset.forName("ISO-8859-1")); testToBytes(Charset.forName("ISO-8859-2")); testToBytes(Charset.forName("ISO-8859-3")); testToBytes(Charset.forName("ISO-8859-4")); testToBytes(Charset.forName("ISO-8859-5")); testToBytes(Charset.forName("ISO-8859-6")); testToBytes(Charset.forName("ISO-8859-7")); testToBytes(Charset.forName("ISO-8859-8")); testToBytes(Charset.forName("ISO-8859-9")); testToBytes(Charset.forName("ISO-8859-11")); testToBytes(Charset.forName("ISO-8859-13")); testToBytes(Charset.forName("ISO-8859-15")); testToBytes(Charset.forName("windows-1250")); testToBytes(Charset.forName("windows-1251")); testToBytes(Charset.forName("windows-1252")); testToBytes(Charset.forName("windows-1256")); testToBytes(Charset.forName("SJIS")); testToBytes(Charset.forName("UTF-8")); } private static void testToBytes(Charset charset) { assertArrayEquals(new int[] {}, toBytes("", charset)); assertArrayEquals(new int[] { 'a' }, toBytes("a", charset)); assertArrayEquals(new int[] { 'a', 'b', 'c' }, toBytes("abc", charset)); assertArrayEquals(new int[] { FNC1 }, toBytes("\\<FNC1>", charset)); assertArrayEquals(new int[] { 'a', FNC1 }, toBytes("a\\<FNC1>", charset)); assertArrayEquals(new int[] { FNC1, 'a' }, toBytes("\\<FNC1>a", charset)); assertArrayEquals(new int[] { FNC2 }, toBytes("\\<FNC2>", charset)); assertArrayEquals(new int[] { 'a', FNC2 }, toBytes("a\\<FNC2>", charset)); assertArrayEquals(new int[] { FNC2, 'a' }, toBytes("\\<FNC2>a", charset));
// Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC1 = -1; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC2 = -2; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC3 = -3; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC4 = -4; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static int[] toBytes(String s, Charset charset, int... suffix) { // // if (!charset.newEncoder().canEncode(s)) { // return null; // } // // byte[] fnc1 = FNC1_STRING.getBytes(charset); // byte[] fnc2 = FNC2_STRING.getBytes(charset); // byte[] fnc3 = FNC3_STRING.getBytes(charset); // byte[] fnc4 = FNC4_STRING.getBytes(charset); // // byte[] bytes = s.getBytes(charset); // int[] data = new int[bytes.length + suffix.length]; // // int i = 0, j = 0; // for (; i < bytes.length; i++, j++) { // if (containsAt(bytes, fnc1, i)) { // data[j] = FNC1; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc2, i)) { // data[j] = FNC2; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc3, i)) { // data[j] = FNC3; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc4, i)) { // data[j] = FNC4; // i += fnc1.length - 1; // } else { // data[j] = bytes[i] & 0xff; // } // } // // int k = 0; // for (; k < suffix.length; k++) { // data[j + k] = suffix[k]; // } // // if (j + k < i) { // data = Arrays.copyOf(data, j + k); // } // // return data; // } // Path: src/test/java/uk/org/okapibarcode/backend/SymbolBasicTest.java import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertArrayEquals; import static uk.org.okapibarcode.backend.Symbol.FNC1; import static uk.org.okapibarcode.backend.Symbol.FNC2; import static uk.org.okapibarcode.backend.Symbol.FNC3; import static uk.org.okapibarcode.backend.Symbol.FNC4; import static uk.org.okapibarcode.backend.Symbol.toBytes; import java.nio.charset.Charset; import org.junit.Test; testToBytes(Charset.forName("ISO-8859-1")); testToBytes(Charset.forName("ISO-8859-2")); testToBytes(Charset.forName("ISO-8859-3")); testToBytes(Charset.forName("ISO-8859-4")); testToBytes(Charset.forName("ISO-8859-5")); testToBytes(Charset.forName("ISO-8859-6")); testToBytes(Charset.forName("ISO-8859-7")); testToBytes(Charset.forName("ISO-8859-8")); testToBytes(Charset.forName("ISO-8859-9")); testToBytes(Charset.forName("ISO-8859-11")); testToBytes(Charset.forName("ISO-8859-13")); testToBytes(Charset.forName("ISO-8859-15")); testToBytes(Charset.forName("windows-1250")); testToBytes(Charset.forName("windows-1251")); testToBytes(Charset.forName("windows-1252")); testToBytes(Charset.forName("windows-1256")); testToBytes(Charset.forName("SJIS")); testToBytes(Charset.forName("UTF-8")); } private static void testToBytes(Charset charset) { assertArrayEquals(new int[] {}, toBytes("", charset)); assertArrayEquals(new int[] { 'a' }, toBytes("a", charset)); assertArrayEquals(new int[] { 'a', 'b', 'c' }, toBytes("abc", charset)); assertArrayEquals(new int[] { FNC1 }, toBytes("\\<FNC1>", charset)); assertArrayEquals(new int[] { 'a', FNC1 }, toBytes("a\\<FNC1>", charset)); assertArrayEquals(new int[] { FNC1, 'a' }, toBytes("\\<FNC1>a", charset)); assertArrayEquals(new int[] { FNC2 }, toBytes("\\<FNC2>", charset)); assertArrayEquals(new int[] { 'a', FNC2 }, toBytes("a\\<FNC2>", charset)); assertArrayEquals(new int[] { FNC2, 'a' }, toBytes("\\<FNC2>a", charset));
assertArrayEquals(new int[] { FNC3 }, toBytes("\\<FNC3>", charset));
woo-j/OkapiBarcode
src/test/java/uk/org/okapibarcode/backend/SymbolBasicTest.java
// Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC1 = -1; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC2 = -2; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC3 = -3; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC4 = -4; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static int[] toBytes(String s, Charset charset, int... suffix) { // // if (!charset.newEncoder().canEncode(s)) { // return null; // } // // byte[] fnc1 = FNC1_STRING.getBytes(charset); // byte[] fnc2 = FNC2_STRING.getBytes(charset); // byte[] fnc3 = FNC3_STRING.getBytes(charset); // byte[] fnc4 = FNC4_STRING.getBytes(charset); // // byte[] bytes = s.getBytes(charset); // int[] data = new int[bytes.length + suffix.length]; // // int i = 0, j = 0; // for (; i < bytes.length; i++, j++) { // if (containsAt(bytes, fnc1, i)) { // data[j] = FNC1; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc2, i)) { // data[j] = FNC2; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc3, i)) { // data[j] = FNC3; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc4, i)) { // data[j] = FNC4; // i += fnc1.length - 1; // } else { // data[j] = bytes[i] & 0xff; // } // } // // int k = 0; // for (; k < suffix.length; k++) { // data[j + k] = suffix[k]; // } // // if (j + k < i) { // data = Arrays.copyOf(data, j + k); // } // // return data; // }
import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertArrayEquals; import static uk.org.okapibarcode.backend.Symbol.FNC1; import static uk.org.okapibarcode.backend.Symbol.FNC2; import static uk.org.okapibarcode.backend.Symbol.FNC3; import static uk.org.okapibarcode.backend.Symbol.FNC4; import static uk.org.okapibarcode.backend.Symbol.toBytes; import java.nio.charset.Charset; import org.junit.Test;
testToBytes(Charset.forName("ISO-8859-4")); testToBytes(Charset.forName("ISO-8859-5")); testToBytes(Charset.forName("ISO-8859-6")); testToBytes(Charset.forName("ISO-8859-7")); testToBytes(Charset.forName("ISO-8859-8")); testToBytes(Charset.forName("ISO-8859-9")); testToBytes(Charset.forName("ISO-8859-11")); testToBytes(Charset.forName("ISO-8859-13")); testToBytes(Charset.forName("ISO-8859-15")); testToBytes(Charset.forName("windows-1250")); testToBytes(Charset.forName("windows-1251")); testToBytes(Charset.forName("windows-1252")); testToBytes(Charset.forName("windows-1256")); testToBytes(Charset.forName("SJIS")); testToBytes(Charset.forName("UTF-8")); } private static void testToBytes(Charset charset) { assertArrayEquals(new int[] {}, toBytes("", charset)); assertArrayEquals(new int[] { 'a' }, toBytes("a", charset)); assertArrayEquals(new int[] { 'a', 'b', 'c' }, toBytes("abc", charset)); assertArrayEquals(new int[] { FNC1 }, toBytes("\\<FNC1>", charset)); assertArrayEquals(new int[] { 'a', FNC1 }, toBytes("a\\<FNC1>", charset)); assertArrayEquals(new int[] { FNC1, 'a' }, toBytes("\\<FNC1>a", charset)); assertArrayEquals(new int[] { FNC2 }, toBytes("\\<FNC2>", charset)); assertArrayEquals(new int[] { 'a', FNC2 }, toBytes("a\\<FNC2>", charset)); assertArrayEquals(new int[] { FNC2, 'a' }, toBytes("\\<FNC2>a", charset)); assertArrayEquals(new int[] { FNC3 }, toBytes("\\<FNC3>", charset)); assertArrayEquals(new int[] { 'a', FNC3 }, toBytes("a\\<FNC3>", charset)); assertArrayEquals(new int[] { FNC3, 'a' }, toBytes("\\<FNC3>a", charset));
// Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC1 = -1; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC2 = -2; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC3 = -3; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static final int FNC4 = -4; // // Path: src/main/java/uk/org/okapibarcode/backend/Symbol.java // protected static int[] toBytes(String s, Charset charset, int... suffix) { // // if (!charset.newEncoder().canEncode(s)) { // return null; // } // // byte[] fnc1 = FNC1_STRING.getBytes(charset); // byte[] fnc2 = FNC2_STRING.getBytes(charset); // byte[] fnc3 = FNC3_STRING.getBytes(charset); // byte[] fnc4 = FNC4_STRING.getBytes(charset); // // byte[] bytes = s.getBytes(charset); // int[] data = new int[bytes.length + suffix.length]; // // int i = 0, j = 0; // for (; i < bytes.length; i++, j++) { // if (containsAt(bytes, fnc1, i)) { // data[j] = FNC1; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc2, i)) { // data[j] = FNC2; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc3, i)) { // data[j] = FNC3; // i += fnc1.length - 1; // } else if (containsAt(bytes, fnc4, i)) { // data[j] = FNC4; // i += fnc1.length - 1; // } else { // data[j] = bytes[i] & 0xff; // } // } // // int k = 0; // for (; k < suffix.length; k++) { // data[j + k] = suffix[k]; // } // // if (j + k < i) { // data = Arrays.copyOf(data, j + k); // } // // return data; // } // Path: src/test/java/uk/org/okapibarcode/backend/SymbolBasicTest.java import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertArrayEquals; import static uk.org.okapibarcode.backend.Symbol.FNC1; import static uk.org.okapibarcode.backend.Symbol.FNC2; import static uk.org.okapibarcode.backend.Symbol.FNC3; import static uk.org.okapibarcode.backend.Symbol.FNC4; import static uk.org.okapibarcode.backend.Symbol.toBytes; import java.nio.charset.Charset; import org.junit.Test; testToBytes(Charset.forName("ISO-8859-4")); testToBytes(Charset.forName("ISO-8859-5")); testToBytes(Charset.forName("ISO-8859-6")); testToBytes(Charset.forName("ISO-8859-7")); testToBytes(Charset.forName("ISO-8859-8")); testToBytes(Charset.forName("ISO-8859-9")); testToBytes(Charset.forName("ISO-8859-11")); testToBytes(Charset.forName("ISO-8859-13")); testToBytes(Charset.forName("ISO-8859-15")); testToBytes(Charset.forName("windows-1250")); testToBytes(Charset.forName("windows-1251")); testToBytes(Charset.forName("windows-1252")); testToBytes(Charset.forName("windows-1256")); testToBytes(Charset.forName("SJIS")); testToBytes(Charset.forName("UTF-8")); } private static void testToBytes(Charset charset) { assertArrayEquals(new int[] {}, toBytes("", charset)); assertArrayEquals(new int[] { 'a' }, toBytes("a", charset)); assertArrayEquals(new int[] { 'a', 'b', 'c' }, toBytes("abc", charset)); assertArrayEquals(new int[] { FNC1 }, toBytes("\\<FNC1>", charset)); assertArrayEquals(new int[] { 'a', FNC1 }, toBytes("a\\<FNC1>", charset)); assertArrayEquals(new int[] { FNC1, 'a' }, toBytes("\\<FNC1>a", charset)); assertArrayEquals(new int[] { FNC2 }, toBytes("\\<FNC2>", charset)); assertArrayEquals(new int[] { 'a', FNC2 }, toBytes("a\\<FNC2>", charset)); assertArrayEquals(new int[] { FNC2, 'a' }, toBytes("\\<FNC2>a", charset)); assertArrayEquals(new int[] { FNC3 }, toBytes("\\<FNC3>", charset)); assertArrayEquals(new int[] { 'a', FNC3 }, toBytes("a\\<FNC3>", charset)); assertArrayEquals(new int[] { FNC3, 'a' }, toBytes("\\<FNC3>a", charset));
assertArrayEquals(new int[] { FNC4 }, toBytes("\\<FNC4>", charset));
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/RoyalMail4State.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf; import java.awt.geom.Rectangle2D; import java.util.Locale;
/* * Copyright 2014 Robin Stuart * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.backend; /** * <p>Encodes data according to the Royal Mail 4-State Country Code. * * <p>Data input can consist of numbers 0-9 and letters A-Z and usually includes * delivery postcode followed by house number. A check digit is calculated * and added. * * @author <a href="mailto:rstuart114@gmail.com">Robin Stuart</a> */ public class RoyalMail4State extends Symbol { private static final String[] ROYAL_TABLE = { "TTFF", "TDAF", "TDFA", "DTAF", "DTFA", "DDAA", "TADF", "TFTF", "TFDA", "DATF", "DADA", "DFTA", "TAFD", "TFAD", "TFFT", "DAAD", "DAFT", "DFAT", "ATDF", "ADTF", "ADDA", "FTTF", "FTDA", "FDTA", "ATFD", "ADAD", "ADFT", "FTAD", "FTFT", "FDAT", "AADD", "AFTD", "AFDT", "FATD", "FADT", "FFTT" }; private static final char[] KR_SET = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; @Override protected void encode() { String dest; int i, top = 0, bottom = 0; int row, column; int index; content = content.toUpperCase(Locale.ENGLISH); if(!content.matches("[0-9A-Z]+")) { throw new OkapiException("Invalid characters in data"); } dest = "A"; for (i = 0; i < content.length(); i++) {
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/RoyalMail4State.java import static uk.org.okapibarcode.util.Arrays.positionOf; import java.awt.geom.Rectangle2D; import java.util.Locale; /* * Copyright 2014 Robin Stuart * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.backend; /** * <p>Encodes data according to the Royal Mail 4-State Country Code. * * <p>Data input can consist of numbers 0-9 and letters A-Z and usually includes * delivery postcode followed by house number. A check digit is calculated * and added. * * @author <a href="mailto:rstuart114@gmail.com">Robin Stuart</a> */ public class RoyalMail4State extends Symbol { private static final String[] ROYAL_TABLE = { "TTFF", "TDAF", "TDFA", "DTAF", "DTFA", "DDAA", "TADF", "TFTF", "TFDA", "DATF", "DADA", "DFTA", "TAFD", "TFAD", "TFFT", "DAAD", "DAFT", "DFAT", "ATDF", "ADTF", "ADDA", "FTTF", "FTDA", "FDTA", "ATFD", "ADAD", "ADFT", "FTAD", "FTFT", "FDAT", "AADD", "AFTD", "AFDT", "FATD", "FADT", "FFTT" }; private static final char[] KR_SET = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; @Override protected void encode() { String dest; int i, top = 0, bottom = 0; int row, column; int index; content = content.toUpperCase(Locale.ENGLISH); if(!content.matches("[0-9A-Z]+")) { throw new OkapiException("Invalid characters in data"); } dest = "A"; for (i = 0; i < content.length(); i++) {
index = positionOf(content.charAt(i), KR_SET);
woo-j/OkapiBarcode
src/test/java/uk/org/okapibarcode/backend/UspsOneCodeTest.java
// Path: src/main/java/uk/org/okapibarcode/backend/UspsOneCode.java // protected static String formatHumanReadableText(String content) { // StringBuilder hrt = new StringBuilder(50); // boolean mid9 = false; // 9-digit mailer ID instead of 6-digit mailer ID // boolean tracing = true; // STID indicates Origin IMb Tracing Services (050, 052) // boolean pimb = true; // barcode identifier (BI) is 94, indicating pIMb // boolean mpe5 = false; // if MPE = 5, it's a CFS/RFS variant of pIMb // int i = 0; // for (char c : content.toCharArray()) { // if (c < '0' || c > '9') { // continue; // } // if (i == 5 && c == '9') { // mid9 = true; // } // if ((i == 2 && c != '0') || (i == 3 && c != '5') || (i == 4 && c != '0' && c != '2')) { // tracing = false; // } // if ((i == 0 && c != '9') || (i == 1 && c != '4')) { // pimb = false; // } // if (i == 5 && c == '5') { // mpe5 = true; // } // if ((i == 2) // BI -> STID // || (i == 5) // STID -> ... // || (i == 6 && pimb) // || (i == 10 && pimb) // || (i == 13 && pimb && !mpe5) // || (i == 15 && pimb && !mpe5) // || (i == 11 && !mid9 && !tracing && !pimb) // || (i == 14 && mid9 && !tracing && !pimb) // || (i == 20) // ... -> zip-5 // || (i == 25) // zip-5 -> zip-4 // || (i == 29)) { // zip-4 -> zip-2 // hrt.append(' '); // } // hrt.append(c); // i++; // } // return hrt.toString().trim(); // }
import static org.junit.Assert.assertEquals; import static uk.org.okapibarcode.backend.UspsOneCode.formatHumanReadableText; import org.junit.Test;
/* * Copyright 2019 Daniel Gredler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.backend; /** * {@link UspsOneCode} tests that can't be run via the {@link SymbolTest}. */ public class UspsOneCodeTest { @Test public void testFormatHumanReadableText() { // 6-digit mailer IDs: 000000-899999 // 9-digit mailer IDs: 900000000-999999999 // 11.3.1.1, Table 26 (6-digit mailer ID) // 11.3.2.3, Table 36 (6-digit mailer ID, BI = 93)
// Path: src/main/java/uk/org/okapibarcode/backend/UspsOneCode.java // protected static String formatHumanReadableText(String content) { // StringBuilder hrt = new StringBuilder(50); // boolean mid9 = false; // 9-digit mailer ID instead of 6-digit mailer ID // boolean tracing = true; // STID indicates Origin IMb Tracing Services (050, 052) // boolean pimb = true; // barcode identifier (BI) is 94, indicating pIMb // boolean mpe5 = false; // if MPE = 5, it's a CFS/RFS variant of pIMb // int i = 0; // for (char c : content.toCharArray()) { // if (c < '0' || c > '9') { // continue; // } // if (i == 5 && c == '9') { // mid9 = true; // } // if ((i == 2 && c != '0') || (i == 3 && c != '5') || (i == 4 && c != '0' && c != '2')) { // tracing = false; // } // if ((i == 0 && c != '9') || (i == 1 && c != '4')) { // pimb = false; // } // if (i == 5 && c == '5') { // mpe5 = true; // } // if ((i == 2) // BI -> STID // || (i == 5) // STID -> ... // || (i == 6 && pimb) // || (i == 10 && pimb) // || (i == 13 && pimb && !mpe5) // || (i == 15 && pimb && !mpe5) // || (i == 11 && !mid9 && !tracing && !pimb) // || (i == 14 && mid9 && !tracing && !pimb) // || (i == 20) // ... -> zip-5 // || (i == 25) // zip-5 -> zip-4 // || (i == 29)) { // zip-4 -> zip-2 // hrt.append(' '); // } // hrt.append(c); // i++; // } // return hrt.toString().trim(); // } // Path: src/test/java/uk/org/okapibarcode/backend/UspsOneCodeTest.java import static org.junit.Assert.assertEquals; import static uk.org.okapibarcode.backend.UspsOneCode.formatHumanReadableText; import org.junit.Test; /* * Copyright 2019 Daniel Gredler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.backend; /** * {@link UspsOneCode} tests that can't be run via the {@link SymbolTest}. */ public class UspsOneCodeTest { @Test public void testFormatHumanReadableText() { // 6-digit mailer IDs: 000000-899999 // 9-digit mailer IDs: 900000000-999999999 // 11.3.1.1, Table 26 (6-digit mailer ID) // 11.3.2.3, Table 36 (6-digit mailer ID, BI = 93)
assertEquals("12 123 123456 123456789", formatHumanReadableText("12.123.123456.123456789")); // zip code: none
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/AztecCode.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int[] insertArray(int[] original, int index, int[] inserted) { // int[] modified = new int[original.length + inserted.length]; // System.arraycopy(original, 0, modified, 0, index); // System.arraycopy(inserted, 0, modified, index, inserted.length); // System.arraycopy(original, index, modified, index + inserted.length, modified.length - index - inserted.length); // return modified; // }
import static java.nio.charset.StandardCharsets.US_ASCII; import static uk.org.okapibarcode.util.Arrays.insertArray;
} @Override protected boolean gs1Supported() { return true; } @Override protected void encode() { int layers; boolean compact; StringBuilder adjustedString; if (inputDataType == DataType.GS1 && readerInit) { throw new OkapiException("Cannot encode in GS1 and Reader Initialisation mode at the same time"); } eciProcess(); // Get ECI mode /* Optional structured append (Section 8 of spec) */ /* ML + UL start flag handled later, not part of data */ if (structuredAppendTotal != 1) { StringBuilder prefix = new StringBuilder(); if (structuredAppendMessageId != null) { prefix.append(' ').append(structuredAppendMessageId).append(' '); } prefix.append((char) (structuredAppendPosition + 64)); // 1-26 as A-Z prefix.append((char) (structuredAppendTotal + 64)); // 1-26 as A-Z int[] prefixArray = toBytes(prefix.toString(), US_ASCII);
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int[] insertArray(int[] original, int index, int[] inserted) { // int[] modified = new int[original.length + inserted.length]; // System.arraycopy(original, 0, modified, 0, index); // System.arraycopy(inserted, 0, modified, index, inserted.length); // System.arraycopy(original, index, modified, index + inserted.length, modified.length - index - inserted.length); // return modified; // } // Path: src/main/java/uk/org/okapibarcode/backend/AztecCode.java import static java.nio.charset.StandardCharsets.US_ASCII; import static uk.org.okapibarcode.util.Arrays.insertArray; } @Override protected boolean gs1Supported() { return true; } @Override protected void encode() { int layers; boolean compact; StringBuilder adjustedString; if (inputDataType == DataType.GS1 && readerInit) { throw new OkapiException("Cannot encode in GS1 and Reader Initialisation mode at the same time"); } eciProcess(); // Get ECI mode /* Optional structured append (Section 8 of spec) */ /* ML + UL start flag handled later, not part of data */ if (structuredAppendTotal != 1) { StringBuilder prefix = new StringBuilder(); if (structuredAppendMessageId != null) { prefix.append(' ').append(structuredAppendMessageId).append(' '); } prefix.append((char) (structuredAppendPosition + 64)); // 1-26 as A-Z prefix.append((char) (structuredAppendTotal + 64)); // 1-26 as A-Z int[] prefixArray = toBytes(prefix.toString(), US_ASCII);
inputData = insertArray(inputData, 0, prefixArray);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/MicroQrCode.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf; import java.io.UnsupportedEncodingException;
for (i = 0; i < blockLength; i++) { int lbyte = content.charAt(position + i); binary.append(toBinary(lbyte, 0x80)); infoSpace(lbyte); } break; case ALPHANUM: /* Alphanumeric mode */ /* Mode indicator */ switch (version) { case 1: binary.append("1"); break; case 2: binary.append("01"); break; case 3: binary.append("001"); break; } /* Character count indicator */ binary.append(toBinary(blockLength, 2 << version)); /* version = 1..3 */ info("ALPH (" + blockLength + ") "); /* Character representation */ i = 0; while (i < blockLength) {
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/MicroQrCode.java import static uk.org.okapibarcode.util.Arrays.positionOf; import java.io.UnsupportedEncodingException; for (i = 0; i < blockLength; i++) { int lbyte = content.charAt(position + i); binary.append(toBinary(lbyte, 0x80)); infoSpace(lbyte); } break; case ALPHANUM: /* Alphanumeric mode */ /* Mode indicator */ switch (version) { case 1: binary.append("1"); break; case 2: binary.append("01"); break; case 3: binary.append("001"); break; } /* Character count indicator */ binary.append(toBinary(blockLength, 2 << version)); /* version = 1..3 */ info("ALPH (" + blockLength + ") "); /* Character representation */ i = 0; while (i < blockLength) {
first = positionOf(content.charAt(position + i), RHODIUM);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/KixCode.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf; import java.awt.geom.Rectangle2D; import java.util.Locale;
/* * Copyright 2014 Robin Stuart * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.backend; /** * <p>Implements Dutch Post KIX Code as used by Royal Dutch TPG Post (Netherlands). * * <p>The input data can consist of digits 0-9 and characters A-Z, and should be 11 * characters in length. No check digit is added. * * <p>KIX Code is the same as RM4SCC, but without the check digit. * * @author <a href="mailto:rstuart114@gmail.com">Robin Stuart</a> * @see <a href="http://www.tntpost.nl/zakelijk/klantenservice/downloads/kIX_code/download.aspx">KIX Code Specification</a> */ public class KixCode extends Symbol { private static final String[] ROYAL_TABLE = { "TTFF", "TDAF", "TDFA", "DTAF", "DTFA", "DDAA", "TADF", "TFTF", "TFDA", "DATF", "DADA", "DFTA", "TAFD", "TFAD", "TFFT", "DAAD", "DAFT", "DFAT", "ATDF", "ADTF", "ADDA", "FTTF", "FTDA", "FDTA", "ATFD", "ADAD", "ADFT", "FTAD", "FTFT", "FDAT", "AADD", "AFTD", "AFDT", "FATD", "FADT", "FFTT" }; private static final char[] KR_SET = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; @Override protected void encode() { content = content.toUpperCase(Locale.ENGLISH); if(!content.matches("[0-9A-Z]+")) { throw new OkapiException("Invalid characters in data"); } StringBuilder sb = new StringBuilder(content.length()); for (int i = 0; i < content.length(); i++) {
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/KixCode.java import static uk.org.okapibarcode.util.Arrays.positionOf; import java.awt.geom.Rectangle2D; import java.util.Locale; /* * Copyright 2014 Robin Stuart * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.backend; /** * <p>Implements Dutch Post KIX Code as used by Royal Dutch TPG Post (Netherlands). * * <p>The input data can consist of digits 0-9 and characters A-Z, and should be 11 * characters in length. No check digit is added. * * <p>KIX Code is the same as RM4SCC, but without the check digit. * * @author <a href="mailto:rstuart114@gmail.com">Robin Stuart</a> * @see <a href="http://www.tntpost.nl/zakelijk/klantenservice/downloads/kIX_code/download.aspx">KIX Code Specification</a> */ public class KixCode extends Symbol { private static final String[] ROYAL_TABLE = { "TTFF", "TDAF", "TDFA", "DTAF", "DTFA", "DDAA", "TADF", "TFTF", "TFDA", "DATF", "DADA", "DFTA", "TAFD", "TFAD", "TFFT", "DAAD", "DAFT", "DFAT", "ATDF", "ADTF", "ADDA", "FTTF", "FTDA", "FDTA", "ATFD", "ADAD", "ADFT", "FTAD", "FTFT", "FDAT", "AADD", "AFTD", "AFDT", "FATD", "FADT", "FFTT" }; private static final char[] KR_SET = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; @Override protected void encode() { content = content.toUpperCase(Locale.ENGLISH); if(!content.matches("[0-9A-Z]+")) { throw new OkapiException("Invalid characters in data"); } StringBuilder sb = new StringBuilder(content.length()); for (int i = 0; i < content.length(); i++) {
int j = positionOf(content.charAt(i), KR_SET);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/GridMatrix.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf; import java.nio.charset.Charset; import java.nio.charset.UnsupportedCharsetException;
glyph = inputData[sp]; infoSpace(glyph); for (i = 0x80; i > 0; i = i >> 1) { if ((glyph & i) != 0) { binary.append('1'); } else { binary.append('0'); } } sp++; byte_count++; break; case GM_MIXED: shift = 1; if ((inputData[sp] >= '0') && (inputData[sp] <= '9')) { shift = 0; } if ((inputData[sp] >= 'A') && (inputData[sp] <= 'Z')) { shift = 0; } if ((inputData[sp] >= 'a') && (inputData[sp] <= 'z')) { shift = 0; } if (inputData[sp] == ' ') { shift = 0; } if (shift == 0) { /* Mixed Mode character */
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/GridMatrix.java import static uk.org.okapibarcode.util.Arrays.positionOf; import java.nio.charset.Charset; import java.nio.charset.UnsupportedCharsetException; glyph = inputData[sp]; infoSpace(glyph); for (i = 0x80; i > 0; i = i >> 1) { if ((glyph & i) != 0) { binary.append('1'); } else { binary.append('0'); } } sp++; byte_count++; break; case GM_MIXED: shift = 1; if ((inputData[sp] >= '0') && (inputData[sp] <= '9')) { shift = 0; } if ((inputData[sp] >= 'A') && (inputData[sp] <= 'Z')) { shift = 0; } if ((inputData[sp] >= 'a') && (inputData[sp] <= 'z')) { shift = 0; } if (inputData[sp] == ' ') { shift = 0; } if (shift == 0) { /* Mixed Mode character */
glyph = positionOf((char) inputData[sp], MIXED_ALPHANUM_SET);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/Code3Of9.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf;
* * @return the check digit mode */ public CheckDigit getCheckDigit() { return checkOption; } @Override protected void encode() { if (!content.matches("[0-9A-Z\\. \\-$/+%]*")) { throw new OkapiException("Invalid characters in input"); } String start = "1211212111"; String stop = "121121211"; int patternLength = start.length() + stop.length() + (10 * content.length()) + (checkOption == CheckDigit.MOD43 ? 10 : 0); StringBuilder dest = new StringBuilder(patternLength); dest.append(start); int counter = 0; char checkDigit = ' '; for (int i = 0; i < content.length(); i++) { char c = content.charAt(i);
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/Code3Of9.java import static uk.org.okapibarcode.util.Arrays.positionOf; * * @return the check digit mode */ public CheckDigit getCheckDigit() { return checkOption; } @Override protected void encode() { if (!content.matches("[0-9A-Z\\. \\-$/+%]*")) { throw new OkapiException("Invalid characters in input"); } String start = "1211212111"; String stop = "121121211"; int patternLength = start.length() + stop.length() + (10 * content.length()) + (checkOption == CheckDigit.MOD43 ? 10 : 0); StringBuilder dest = new StringBuilder(patternLength); dest.append(start); int counter = 0; char checkDigit = ' '; for (int i = 0; i < content.length(); i++) { char c = content.charAt(i);
int index = positionOf(c, LOOKUP);
woo-j/OkapiBarcode
src/test/java/uk/org/okapibarcode/backend/DataMatrixTest.java
// Path: src/main/java/uk/org/okapibarcode/backend/DataMatrix.java // public enum ForceMode { // NONE, SQUARE, RECTANGULAR // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import org.junit.Test; import uk.org.okapibarcode.backend.DataMatrix.ForceMode;
/* * Copyright 2018 Daniel Gredler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.backend; /** * {@link DataMatrix} tests that can't be run via the {@link SymbolTest}. */ public class DataMatrixTest { @Test public void testActualSize() { DataMatrix dm = new DataMatrix(); try { dm.getActualSize(); fail("Expected error."); } catch (IllegalStateException e) { assertEquals("Actual size not calculated until symbol is encoded.", e.getMessage()); } try { dm.getActualWidth(); fail("Expected error."); } catch (IllegalStateException e) { assertEquals("Actual size not calculated until symbol is encoded.", e.getMessage()); } try { dm.getActualHeight(); fail("Expected error."); } catch (IllegalStateException e) { assertEquals("Actual size not calculated until symbol is encoded.", e.getMessage()); } dm.setPreferredSize(3); dm.setContent("ABC"); assertEquals(3, dm.getPreferredSize()); assertEquals(3, dm.getActualSize()); assertEquals(14, dm.getActualWidth()); assertEquals(14, dm.getActualHeight());
// Path: src/main/java/uk/org/okapibarcode/backend/DataMatrix.java // public enum ForceMode { // NONE, SQUARE, RECTANGULAR // } // Path: src/test/java/uk/org/okapibarcode/backend/DataMatrixTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import org.junit.Test; import uk.org.okapibarcode.backend.DataMatrix.ForceMode; /* * Copyright 2018 Daniel Gredler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.backend; /** * {@link DataMatrix} tests that can't be run via the {@link SymbolTest}. */ public class DataMatrixTest { @Test public void testActualSize() { DataMatrix dm = new DataMatrix(); try { dm.getActualSize(); fail("Expected error."); } catch (IllegalStateException e) { assertEquals("Actual size not calculated until symbol is encoded.", e.getMessage()); } try { dm.getActualWidth(); fail("Expected error."); } catch (IllegalStateException e) { assertEquals("Actual size not calculated until symbol is encoded.", e.getMessage()); } try { dm.getActualHeight(); fail("Expected error."); } catch (IllegalStateException e) { assertEquals("Actual size not calculated until symbol is encoded.", e.getMessage()); } dm.setPreferredSize(3); dm.setContent("ABC"); assertEquals(3, dm.getPreferredSize()); assertEquals(3, dm.getActualSize()); assertEquals(14, dm.getActualWidth()); assertEquals(14, dm.getActualHeight());
assertEquals(ForceMode.NONE, dm.getForceMode());
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/Logmars.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf;
/* * Copyright 2014 Robin Stuart * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.backend; /** * Implements the LOGMARS (Logistics Applications of Automated Marking * and Reading Symbols) standard used by the US Department of Defense. * Input data can be of any length and supports the characters 0-9, A-Z, dash * (-), full stop (.), space, dollar ($), slash (/), plus (+) and percent (%). * A Modulo-43 check digit is calculated and added, and should not form part * of the input data. * * @author <a href="mailto:rstuart114@gmail.com">Robin Stuart</a> */ public class Logmars extends Symbol { private static final String[] CODE39LM = { "1113313111", "3113111131", "1133111131", "3133111111", "1113311131", "3113311111", "1133311111", "1113113131", "3113113111", "1133113111", "3111131131", "1131131131", "3131131111", "1111331131", "3111331111", "1131331111", "1111133131", "3111133111", "1131133111", "1111333111", "3111111331", "1131111331", "3131111311", "1111311331", "3111311311", "1131311311", "1111113331", "3111113311", "1131113311", "1111313311", "3311111131", "1331111131", "3331111111", "1311311131", "3311311111", "1331311111", "1311113131", "3311113111", "1331113111", "1313131111", "1313111311", "1311131311", "1113131311" }; private static final char[] LOOKUP = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%' }; /** Ratio of wide bar width to narrow bar width. */ private double moduleWidthRatio = 3; /** * Sets the ratio of wide bar width to narrow bar width. Valid values are usually * between {@code 2} and {@code 3}. The default value is {@code 3}. * * @param moduleWidthRatio the ratio of wide bar width to narrow bar width */ public void setModuleWidthRatio(double moduleWidthRatio) { this.moduleWidthRatio = moduleWidthRatio; } /** * Returns the ratio of wide bar width to narrow bar width. * * @return the ratio of wide bar width to narrow bar width */ public double getModuleWidthRatio() { return moduleWidthRatio; } /** {@inheritDoc} */ @Override protected double getModuleWidth(int originalWidth) { if (originalWidth == 1) { return 1; } else { return moduleWidthRatio; } } /** {@inheritDoc} */ @Override protected void encode() { if (!content.matches("[0-9A-Z\\. \\-$/+%]*")) { throw new OkapiException("Invalid characters in input"); } String p = ""; int l = content.length(); int charval, counter = 0; char thischar; char checkDigit; for (int i = 0; i < l; i++) { thischar = content.charAt(i);
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/Logmars.java import static uk.org.okapibarcode.util.Arrays.positionOf; /* * Copyright 2014 Robin Stuart * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package uk.org.okapibarcode.backend; /** * Implements the LOGMARS (Logistics Applications of Automated Marking * and Reading Symbols) standard used by the US Department of Defense. * Input data can be of any length and supports the characters 0-9, A-Z, dash * (-), full stop (.), space, dollar ($), slash (/), plus (+) and percent (%). * A Modulo-43 check digit is calculated and added, and should not form part * of the input data. * * @author <a href="mailto:rstuart114@gmail.com">Robin Stuart</a> */ public class Logmars extends Symbol { private static final String[] CODE39LM = { "1113313111", "3113111131", "1133111131", "3133111111", "1113311131", "3113311111", "1133311111", "1113113131", "3113113111", "1133113111", "3111131131", "1131131131", "3131131111", "1111331131", "3111331111", "1131331111", "1111133131", "3111133111", "1131133111", "1111333111", "3111111331", "1131111331", "3131111311", "1111311331", "3111311311", "1131311311", "1111113331", "3111113311", "1131113311", "1111313311", "3311111131", "1331111131", "3331111111", "1311311131", "3311311111", "1331311111", "1311113131", "3311113111", "1331113111", "1313131111", "1313111311", "1311131311", "1113131311" }; private static final char[] LOOKUP = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%' }; /** Ratio of wide bar width to narrow bar width. */ private double moduleWidthRatio = 3; /** * Sets the ratio of wide bar width to narrow bar width. Valid values are usually * between {@code 2} and {@code 3}. The default value is {@code 3}. * * @param moduleWidthRatio the ratio of wide bar width to narrow bar width */ public void setModuleWidthRatio(double moduleWidthRatio) { this.moduleWidthRatio = moduleWidthRatio; } /** * Returns the ratio of wide bar width to narrow bar width. * * @return the ratio of wide bar width to narrow bar width */ public double getModuleWidthRatio() { return moduleWidthRatio; } /** {@inheritDoc} */ @Override protected double getModuleWidth(int originalWidth) { if (originalWidth == 1) { return 1; } else { return moduleWidthRatio; } } /** {@inheritDoc} */ @Override protected void encode() { if (!content.matches("[0-9A-Z\\. \\-$/+%]*")) { throw new OkapiException("Invalid characters in input"); } String p = ""; int l = content.length(); int charval, counter = 0; char thischar; char checkDigit; for (int i = 0; i < l; i++) { thischar = content.charAt(i);
charval = positionOf(thischar, LOOKUP);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/Upc.java
// Path: src/main/java/uk/org/okapibarcode/backend/Ean.java // protected static char calcDigit(String s) { // // int count = 0; // int p = 0; // // for (int i = s.length() - 1; i >= 0; i--) { // int c = Character.getNumericValue(s.charAt(i)); // if (p % 2 == 0) { // c = c * 3; // } // count += c; // p++; // } // // int cdigit = 10 - (count % 10); // if (cdigit == 10) { // cdigit = 0; // } // // return (char) (cdigit + '0'); // } // // Path: src/main/java/uk/org/okapibarcode/backend/Ean.java // protected static String validateAndPad(String s, int targetLength) { // // if (!s.matches("[0-9]+")) { // throw new OkapiException("Invalid characters in input"); // } // // if (s.length() > targetLength) { // throw new OkapiException("Input data too long"); // } // // if (s.length() < targetLength) { // for (int i = s.length(); i < targetLength; i++) { // s = '0' + s; // } // } // // return s; // }
import static uk.org.okapibarcode.backend.Ean.calcDigit; import static uk.org.okapibarcode.backend.Ean.validateAndPad; import static uk.org.okapibarcode.backend.HumanReadableLocation.BOTTOM; import static uk.org.okapibarcode.backend.HumanReadableLocation.NONE; import static uk.org.okapibarcode.backend.HumanReadableLocation.TOP; import java.awt.geom.Rectangle2D; import java.util.Arrays;
upca(); } else { upce(); } } private void separateContent() { int splitPoint = content.indexOf('+'); if (splitPoint == -1) { // there is no add-on data addOn = null; } else if (splitPoint == content.length() - 1) { // we found the add-on separator, but no add-on data throw new OkapiException("Invalid add-on data"); } else { // there is a '+' in the input data, use an add-on EAN2 or EAN5 addOn = new EanUpcAddOn(); addOn.font = this.font; addOn.fontName = this.fontName; addOn.fontSize = this.fontSize; addOn.humanReadableLocation = (this.humanReadableLocation == NONE ? NONE : TOP); addOn.moduleWidth = this.moduleWidth; addOn.default_height = this.default_height + this.guardPatternExtraHeight - 8; addOn.setContent(content.substring(splitPoint + 1)); content = content.substring(0, splitPoint); } } private void upca() {
// Path: src/main/java/uk/org/okapibarcode/backend/Ean.java // protected static char calcDigit(String s) { // // int count = 0; // int p = 0; // // for (int i = s.length() - 1; i >= 0; i--) { // int c = Character.getNumericValue(s.charAt(i)); // if (p % 2 == 0) { // c = c * 3; // } // count += c; // p++; // } // // int cdigit = 10 - (count % 10); // if (cdigit == 10) { // cdigit = 0; // } // // return (char) (cdigit + '0'); // } // // Path: src/main/java/uk/org/okapibarcode/backend/Ean.java // protected static String validateAndPad(String s, int targetLength) { // // if (!s.matches("[0-9]+")) { // throw new OkapiException("Invalid characters in input"); // } // // if (s.length() > targetLength) { // throw new OkapiException("Input data too long"); // } // // if (s.length() < targetLength) { // for (int i = s.length(); i < targetLength; i++) { // s = '0' + s; // } // } // // return s; // } // Path: src/main/java/uk/org/okapibarcode/backend/Upc.java import static uk.org.okapibarcode.backend.Ean.calcDigit; import static uk.org.okapibarcode.backend.Ean.validateAndPad; import static uk.org.okapibarcode.backend.HumanReadableLocation.BOTTOM; import static uk.org.okapibarcode.backend.HumanReadableLocation.NONE; import static uk.org.okapibarcode.backend.HumanReadableLocation.TOP; import java.awt.geom.Rectangle2D; import java.util.Arrays; upca(); } else { upce(); } } private void separateContent() { int splitPoint = content.indexOf('+'); if (splitPoint == -1) { // there is no add-on data addOn = null; } else if (splitPoint == content.length() - 1) { // we found the add-on separator, but no add-on data throw new OkapiException("Invalid add-on data"); } else { // there is a '+' in the input data, use an add-on EAN2 or EAN5 addOn = new EanUpcAddOn(); addOn.font = this.font; addOn.fontName = this.fontName; addOn.fontSize = this.fontSize; addOn.humanReadableLocation = (this.humanReadableLocation == NONE ? NONE : TOP); addOn.moduleWidth = this.moduleWidth; addOn.default_height = this.default_height + this.guardPatternExtraHeight - 8; addOn.setContent(content.substring(splitPoint + 1)); content = content.substring(0, splitPoint); } } private void upca() {
content = validateAndPad(content, 11);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/Upc.java
// Path: src/main/java/uk/org/okapibarcode/backend/Ean.java // protected static char calcDigit(String s) { // // int count = 0; // int p = 0; // // for (int i = s.length() - 1; i >= 0; i--) { // int c = Character.getNumericValue(s.charAt(i)); // if (p % 2 == 0) { // c = c * 3; // } // count += c; // p++; // } // // int cdigit = 10 - (count % 10); // if (cdigit == 10) { // cdigit = 0; // } // // return (char) (cdigit + '0'); // } // // Path: src/main/java/uk/org/okapibarcode/backend/Ean.java // protected static String validateAndPad(String s, int targetLength) { // // if (!s.matches("[0-9]+")) { // throw new OkapiException("Invalid characters in input"); // } // // if (s.length() > targetLength) { // throw new OkapiException("Input data too long"); // } // // if (s.length() < targetLength) { // for (int i = s.length(); i < targetLength; i++) { // s = '0' + s; // } // } // // return s; // }
import static uk.org.okapibarcode.backend.Ean.calcDigit; import static uk.org.okapibarcode.backend.Ean.validateAndPad; import static uk.org.okapibarcode.backend.HumanReadableLocation.BOTTOM; import static uk.org.okapibarcode.backend.HumanReadableLocation.NONE; import static uk.org.okapibarcode.backend.HumanReadableLocation.TOP; import java.awt.geom.Rectangle2D; import java.util.Arrays;
upce(); } } private void separateContent() { int splitPoint = content.indexOf('+'); if (splitPoint == -1) { // there is no add-on data addOn = null; } else if (splitPoint == content.length() - 1) { // we found the add-on separator, but no add-on data throw new OkapiException("Invalid add-on data"); } else { // there is a '+' in the input data, use an add-on EAN2 or EAN5 addOn = new EanUpcAddOn(); addOn.font = this.font; addOn.fontName = this.fontName; addOn.fontSize = this.fontSize; addOn.humanReadableLocation = (this.humanReadableLocation == NONE ? NONE : TOP); addOn.moduleWidth = this.moduleWidth; addOn.default_height = this.default_height + this.guardPatternExtraHeight - 8; addOn.setContent(content.substring(splitPoint + 1)); content = content.substring(0, splitPoint); } } private void upca() { content = validateAndPad(content, 11);
// Path: src/main/java/uk/org/okapibarcode/backend/Ean.java // protected static char calcDigit(String s) { // // int count = 0; // int p = 0; // // for (int i = s.length() - 1; i >= 0; i--) { // int c = Character.getNumericValue(s.charAt(i)); // if (p % 2 == 0) { // c = c * 3; // } // count += c; // p++; // } // // int cdigit = 10 - (count % 10); // if (cdigit == 10) { // cdigit = 0; // } // // return (char) (cdigit + '0'); // } // // Path: src/main/java/uk/org/okapibarcode/backend/Ean.java // protected static String validateAndPad(String s, int targetLength) { // // if (!s.matches("[0-9]+")) { // throw new OkapiException("Invalid characters in input"); // } // // if (s.length() > targetLength) { // throw new OkapiException("Input data too long"); // } // // if (s.length() < targetLength) { // for (int i = s.length(); i < targetLength; i++) { // s = '0' + s; // } // } // // return s; // } // Path: src/main/java/uk/org/okapibarcode/backend/Upc.java import static uk.org.okapibarcode.backend.Ean.calcDigit; import static uk.org.okapibarcode.backend.Ean.validateAndPad; import static uk.org.okapibarcode.backend.HumanReadableLocation.BOTTOM; import static uk.org.okapibarcode.backend.HumanReadableLocation.NONE; import static uk.org.okapibarcode.backend.HumanReadableLocation.TOP; import java.awt.geom.Rectangle2D; import java.util.Arrays; upce(); } } private void separateContent() { int splitPoint = content.indexOf('+'); if (splitPoint == -1) { // there is no add-on data addOn = null; } else if (splitPoint == content.length() - 1) { // we found the add-on separator, but no add-on data throw new OkapiException("Invalid add-on data"); } else { // there is a '+' in the input data, use an add-on EAN2 or EAN5 addOn = new EanUpcAddOn(); addOn.font = this.font; addOn.fontName = this.fontName; addOn.fontSize = this.fontSize; addOn.humanReadableLocation = (this.humanReadableLocation == NONE ? NONE : TOP); addOn.moduleWidth = this.moduleWidth; addOn.default_height = this.default_height + this.guardPatternExtraHeight - 8; addOn.setContent(content.substring(splitPoint + 1)); content = content.substring(0, splitPoint); } } private void upca() { content = validateAndPad(content, 11);
char check = calcDigit(content);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/MaxiCode.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static boolean contains(int[] array, int value) { // for (int i = 0; i < array.length; i++) { // if (array[i] == value) { // return true; // } // } // return false; // } // // Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int[] insertArray(int[] original, int index, int[] inserted) { // int[] modified = new int[original.length + inserted.length]; // System.arraycopy(original, 0, modified, 0, index); // System.arraycopy(inserted, 0, modified, index, inserted.length); // System.arraycopy(original, index, modified, index + inserted.length, modified.length - index - inserted.length); // return modified; // }
import static uk.org.okapibarcode.util.Arrays.contains; import static uk.org.okapibarcode.util.Arrays.insertArray; import java.awt.geom.Ellipse2D; import java.util.Arrays;
* @return the primary data for this MaxiCode symbol */ public String getPrimary() { return primaryData; } /** {@inheritDoc} */ @Override protected void encode() { eciProcess(); // mode 2 -> mode 3 if postal code isn't strictly numeric if (mode == 2) { for (int i = 0; i < 10 && i < primaryData.length(); i++) { if ((primaryData.charAt(i) < '0') || (primaryData.charAt(i) > '9')) { mode = 3; break; } } } // initialize the set and character arrays processText(); // start building the codeword array, starting with a copy of the character data // insert primary message if this is a structured carrier message; insert mode otherwise codewords = Arrays.copyOf(character, character.length); if (mode == 2 || mode == 3) { int[] primary = getPrimaryCodewords();
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static boolean contains(int[] array, int value) { // for (int i = 0; i < array.length; i++) { // if (array[i] == value) { // return true; // } // } // return false; // } // // Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int[] insertArray(int[] original, int index, int[] inserted) { // int[] modified = new int[original.length + inserted.length]; // System.arraycopy(original, 0, modified, 0, index); // System.arraycopy(inserted, 0, modified, index, inserted.length); // System.arraycopy(original, index, modified, index + inserted.length, modified.length - index - inserted.length); // return modified; // } // Path: src/main/java/uk/org/okapibarcode/backend/MaxiCode.java import static uk.org.okapibarcode.util.Arrays.contains; import static uk.org.okapibarcode.util.Arrays.insertArray; import java.awt.geom.Ellipse2D; import java.util.Arrays; * @return the primary data for this MaxiCode symbol */ public String getPrimary() { return primaryData; } /** {@inheritDoc} */ @Override protected void encode() { eciProcess(); // mode 2 -> mode 3 if postal code isn't strictly numeric if (mode == 2) { for (int i = 0; i < 10 && i < primaryData.length(); i++) { if ((primaryData.charAt(i) < '0') || (primaryData.charAt(i) > '9')) { mode = 3; break; } } } // initialize the set and character arrays processText(); // start building the codeword array, starting with a copy of the character data // insert primary message if this is a structured carrier message; insert mode otherwise codewords = Arrays.copyOf(character, character.length); if (mode == 2 || mode == 3) { int[] primary = getPrimaryCodewords();
codewords = insertArray(codewords, 0, primary);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/MaxiCode.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static boolean contains(int[] array, int value) { // for (int i = 0; i < array.length; i++) { // if (array[i] == value) { // return true; // } // } // return false; // } // // Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int[] insertArray(int[] original, int index, int[] inserted) { // int[] modified = new int[original.length + inserted.length]; // System.arraycopy(original, 0, modified, 0, index); // System.arraycopy(inserted, 0, modified, index, inserted.length); // System.arraycopy(original, index, modified, index + inserted.length, modified.length - index - inserted.length); // return modified; // }
import static uk.org.okapibarcode.util.Arrays.contains; import static uk.org.okapibarcode.util.Arrays.insertArray; import java.awt.geom.Ellipse2D; import java.util.Arrays;
int maxLength; if (mode == 2 || mode == 3) { maxLength = 84; } else if (mode == 4 || mode == 6) { maxLength = 93; } else if (mode == 5) { maxLength = 77; } else { maxLength = 0; // impossible } if (length > maxLength) { throw new OkapiException("Input data too long"); } } /** * Guesses the best set to use at the specified index by looking at the surrounding sets. In general, characters in * lower-numbered sets are more common, so we choose them if we can. If no good surrounding sets can be found, the default * value returned is the first value from the valid set. * * @param index the current index * @param length the maximum length to look at * @param valid the valid sets for this index * @return the best set to use at the specified index */ private int bestSurroundingSet(int index, int length, int... valid) { int option1 = set[index - 1]; if (index + 1 < length) { // we have two options to check int option2 = set[index + 1];
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static boolean contains(int[] array, int value) { // for (int i = 0; i < array.length; i++) { // if (array[i] == value) { // return true; // } // } // return false; // } // // Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int[] insertArray(int[] original, int index, int[] inserted) { // int[] modified = new int[original.length + inserted.length]; // System.arraycopy(original, 0, modified, 0, index); // System.arraycopy(inserted, 0, modified, index, inserted.length); // System.arraycopy(original, index, modified, index + inserted.length, modified.length - index - inserted.length); // return modified; // } // Path: src/main/java/uk/org/okapibarcode/backend/MaxiCode.java import static uk.org.okapibarcode.util.Arrays.contains; import static uk.org.okapibarcode.util.Arrays.insertArray; import java.awt.geom.Ellipse2D; import java.util.Arrays; int maxLength; if (mode == 2 || mode == 3) { maxLength = 84; } else if (mode == 4 || mode == 6) { maxLength = 93; } else if (mode == 5) { maxLength = 77; } else { maxLength = 0; // impossible } if (length > maxLength) { throw new OkapiException("Input data too long"); } } /** * Guesses the best set to use at the specified index by looking at the surrounding sets. In general, characters in * lower-numbered sets are more common, so we choose them if we can. If no good surrounding sets can be found, the default * value returned is the first value from the valid set. * * @param index the current index * @param length the maximum length to look at * @param valid the valid sets for this index * @return the best set to use at the specified index */ private int bestSurroundingSet(int index, int length, int... valid) { int option1 = set[index - 1]; if (index + 1 < length) { // we have two options to check int option2 = set[index + 1];
if (contains(valid, option1) && contains(valid, option2)) {
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/DataBar14.java
// Path: src/main/java/uk/org/okapibarcode/backend/DataBarLimited.java // static int[] getWidths(int val, int n, int elements, int maxWidth, int noNarrow) { // // int bar; // int elmWidth; // int mxwElement; // int subVal, lessVal; // int narrowMask = 0; // int[] widths = new int[elements]; // // for (bar = 0; bar < elements - 1; bar++) { // for (elmWidth = 1, narrowMask |= (1 << bar); ; // elmWidth++, narrowMask &= ~ (1 << bar)) { // /* get all combinations */ // subVal = getCombinations(n - elmWidth - 1, elements - bar - 2); // /* less combinations with no single-module element */ // if ((noNarrow == 0) && (narrowMask == 0) // && (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { // subVal -= getCombinations(n - elmWidth - (elements - bar), elements - bar - 2); // } // /* less combinations with elements > maxVal */ // if (elements - bar - 1 > 1) { // lessVal = 0; // for (mxwElement = n - elmWidth - (elements - bar - 2); // mxwElement > maxWidth; // mxwElement--) { // lessVal += getCombinations(n - elmWidth - mxwElement - 1, elements - bar - 3); // } // subVal -= lessVal * (elements - 1 - bar); // } else if (n - elmWidth > maxWidth) { // subVal--; // } // val -= subVal; // if (val < 0) break; // } // val += subVal; // n -= elmWidth; // widths[bar] = elmWidth; // } // // widths[bar] = n; // // return widths; // }
import static uk.org.okapibarcode.backend.DataBarLimited.getWidths; import java.math.BigInteger;
data_group[3] = 8; } if (data_character[2] >= 0 && data_character[2] <= 160) { data_group[2] = 0; } if (data_character[2] >= 161 && data_character[2] <= 960) { data_group[2] = 1; } if (data_character[2] >= 961 && data_character[2] <= 2014) { data_group[2] = 2; } if (data_character[2] >= 2015 && data_character[2] <= 2714) { data_group[2] = 3; } if (data_character[2] >= 2715 && data_character[2] <= 2840) { data_group[2] = 4; } v_odd[0] = (data_character[0] - G_SUM_TABLE[data_group[0]]) / T_TABLE[data_group[0]]; v_even[0] = (data_character[0] - G_SUM_TABLE[data_group[0]]) % T_TABLE[data_group[0]]; v_odd[1] = (data_character[1] - G_SUM_TABLE[data_group[1]]) % T_TABLE[data_group[1]]; v_even[1] = (data_character[1] - G_SUM_TABLE[data_group[1]]) / T_TABLE[data_group[1]]; v_odd[3] = (data_character[3] - G_SUM_TABLE[data_group[3]]) % T_TABLE[data_group[3]]; v_even[3] = (data_character[3] - G_SUM_TABLE[data_group[3]]) / T_TABLE[data_group[3]]; v_odd[2] = (data_character[2] - G_SUM_TABLE[data_group[2]]) / T_TABLE[data_group[2]]; v_even[2] = (data_character[2] - G_SUM_TABLE[data_group[2]]) % T_TABLE[data_group[2]]; /* Use RSS subset width algorithm */ for (i = 0; i < 4; i++) { if ((i == 0) || (i == 2)) {
// Path: src/main/java/uk/org/okapibarcode/backend/DataBarLimited.java // static int[] getWidths(int val, int n, int elements, int maxWidth, int noNarrow) { // // int bar; // int elmWidth; // int mxwElement; // int subVal, lessVal; // int narrowMask = 0; // int[] widths = new int[elements]; // // for (bar = 0; bar < elements - 1; bar++) { // for (elmWidth = 1, narrowMask |= (1 << bar); ; // elmWidth++, narrowMask &= ~ (1 << bar)) { // /* get all combinations */ // subVal = getCombinations(n - elmWidth - 1, elements - bar - 2); // /* less combinations with no single-module element */ // if ((noNarrow == 0) && (narrowMask == 0) // && (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { // subVal -= getCombinations(n - elmWidth - (elements - bar), elements - bar - 2); // } // /* less combinations with elements > maxVal */ // if (elements - bar - 1 > 1) { // lessVal = 0; // for (mxwElement = n - elmWidth - (elements - bar - 2); // mxwElement > maxWidth; // mxwElement--) { // lessVal += getCombinations(n - elmWidth - mxwElement - 1, elements - bar - 3); // } // subVal -= lessVal * (elements - 1 - bar); // } else if (n - elmWidth > maxWidth) { // subVal--; // } // val -= subVal; // if (val < 0) break; // } // val += subVal; // n -= elmWidth; // widths[bar] = elmWidth; // } // // widths[bar] = n; // // return widths; // } // Path: src/main/java/uk/org/okapibarcode/backend/DataBar14.java import static uk.org.okapibarcode.backend.DataBarLimited.getWidths; import java.math.BigInteger; data_group[3] = 8; } if (data_character[2] >= 0 && data_character[2] <= 160) { data_group[2] = 0; } if (data_character[2] >= 161 && data_character[2] <= 960) { data_group[2] = 1; } if (data_character[2] >= 961 && data_character[2] <= 2014) { data_group[2] = 2; } if (data_character[2] >= 2015 && data_character[2] <= 2714) { data_group[2] = 3; } if (data_character[2] >= 2715 && data_character[2] <= 2840) { data_group[2] = 4; } v_odd[0] = (data_character[0] - G_SUM_TABLE[data_group[0]]) / T_TABLE[data_group[0]]; v_even[0] = (data_character[0] - G_SUM_TABLE[data_group[0]]) % T_TABLE[data_group[0]]; v_odd[1] = (data_character[1] - G_SUM_TABLE[data_group[1]]) % T_TABLE[data_group[1]]; v_even[1] = (data_character[1] - G_SUM_TABLE[data_group[1]]) / T_TABLE[data_group[1]]; v_odd[3] = (data_character[3] - G_SUM_TABLE[data_group[3]]) % T_TABLE[data_group[3]]; v_even[3] = (data_character[3] - G_SUM_TABLE[data_group[3]]) / T_TABLE[data_group[3]]; v_odd[2] = (data_character[2] - G_SUM_TABLE[data_group[2]]) / T_TABLE[data_group[2]]; v_even[2] = (data_character[2] - G_SUM_TABLE[data_group[2]]) % T_TABLE[data_group[2]]; /* Use RSS subset width algorithm */ for (i = 0; i < 4; i++) { if ((i == 0) || (i == 2)) {
int[] widths = getWidths(v_odd[i], MODULES_ODD[data_group[i]], 4, WIDEST_ODD[data_group[i]], 1);
woo-j/OkapiBarcode
src/main/java/uk/org/okapibarcode/backend/DataMatrix.java
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // }
import static uk.org.okapibarcode.util.Arrays.positionOf; import java.util.Arrays;
placeData(NR, NC); grid = new int[W * H]; for (i = 0; i < (W * H); i++) { grid[i] = 0; } for (y = 0; y < H; y += FH) { for (x = 0; x < W; x++) { grid[y * W + x] = 1; } for (x = 0; x < W; x += 2) { grid[(y + FH - 1) * W + x] = 1; } } for (x = 0; x < W; x += FW) { for (y = 0; y < H; y++) { grid[y * W + x] = 1; } for (y = 0; y < H; y += 2) { grid[y * W + x + FW - 1] = 1; } } for (y = 0; y < NR; y++) { for (x = 0; x < NC; x++) { v = places[(NR - y - 1) * NC + x]; if (v == 1 || (v > 7 && (target[(v >> 3) - 1] & (1 << (v & 7))) != 0)) { grid[(1 + y + 2 * (y / (FH - 2))) * W + 1 + x + 2 * (x / (FW - 2))] = 1; } } }
// Path: src/main/java/uk/org/okapibarcode/util/Arrays.java // public static int positionOf(char value, char[] array) { // for (int i = 0; i < array.length; i++) { // if (value == array[i]) { // return i; // } // } // throw new OkapiException("Unable to find character '" + value + "' in character array."); // } // Path: src/main/java/uk/org/okapibarcode/backend/DataMatrix.java import static uk.org.okapibarcode.util.Arrays.positionOf; import java.util.Arrays; placeData(NR, NC); grid = new int[W * H]; for (i = 0; i < (W * H); i++) { grid[i] = 0; } for (y = 0; y < H; y += FH) { for (x = 0; x < W; x++) { grid[y * W + x] = 1; } for (x = 0; x < W; x += 2) { grid[(y + FH - 1) * W + x] = 1; } } for (x = 0; x < W; x += FW) { for (y = 0; y < H; y++) { grid[y * W + x] = 1; } for (y = 0; y < H; y += 2) { grid[y * W + x + FW - 1] = 1; } } for (y = 0; y < NR; y++) { for (x = 0; x < NC; x++) { v = places[(NR - y - 1) * NC + x]; if (v == 1 || (v > 7 && (target[(v >> 3) - 1] & (1 << (v & 7))) != 0)) { grid[(1 + y + 2 * (y / (FH - 2))) * W + 1 + x + 2 * (x / (FW - 2))] = 1; } } }
actualSize = positionOf(symbolsize, INT_SYMBOL) + 1;
marcusschiesser/my-aktion
my-aktion-monitor/src/main/java/de/dpunkt/myaktion/monitor/ws/SpendeDelegator.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // }
import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.jws.WebMethod; import javax.jws.WebService; import javax.websocket.EncodeException; import javax.websocket.Session; import de.dpunkt.myaktion.model.Spende; import de.dpunkt.myaktion.monitor.MonitorWebSocket;
package de.dpunkt.myaktion.monitor.ws; @WebService public class SpendeDelegator { private Logger logger = Logger.getLogger(SpendeDelegator.class.getName()); @WebMethod
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // Path: my-aktion-monitor/src/main/java/de/dpunkt/myaktion/monitor/ws/SpendeDelegator.java import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.jws.WebMethod; import javax.jws.WebService; import javax.websocket.EncodeException; import javax.websocket.Session; import de.dpunkt.myaktion.model.Spende; import de.dpunkt.myaktion.monitor.MonitorWebSocket; package de.dpunkt.myaktion.monitor.ws; @WebService public class SpendeDelegator { private Logger logger = Logger.getLogger(SpendeDelegator.class.getName()); @WebMethod
public void sendSpende(Long aktionId, Spende spende) {
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/resources/AktionResource.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/AktionService.java // public interface AktionService { // List<Aktion> getAllAktionen(); // Aktion addAktion(Aktion aktion); // void deleteAktion(Aktion aktion); // Aktion updateAktion(Aktion aktion); // void deleteAktion(Long aktionId); // Aktion getAktion(Long aktionId); // }
import java.util.List; import javax.inject.Inject; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.services.AktionService;
package de.dpunkt.myaktion.resources; @Path("/organisator/aktion") public class AktionResource { @Inject
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/AktionService.java // public interface AktionService { // List<Aktion> getAllAktionen(); // Aktion addAktion(Aktion aktion); // void deleteAktion(Aktion aktion); // Aktion updateAktion(Aktion aktion); // void deleteAktion(Long aktionId); // Aktion getAktion(Long aktionId); // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/resources/AktionResource.java import java.util.List; import javax.inject.Inject; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.services.AktionService; package de.dpunkt.myaktion.resources; @Path("/organisator/aktion") public class AktionResource { @Inject
private AktionService aktionService;
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/monitor/ws/SpendeDelegator.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // }
import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.ws.RequestWrapper; import javax.xml.ws.ResponseWrapper; import de.dpunkt.myaktion.model.Spende;
package de.dpunkt.myaktion.monitor.ws; /** * This class was generated by the JAX-WS RI. * JAX-WS RI 2.1.6 in JDK 6 * Generated source version: 2.1 * */ @WebService(name = "SpendeDelegator", targetNamespace = "http://ws.monitor.myaktion.dpunkt.de/") @XmlSeeAlso({ ObjectFactory.class }) public interface SpendeDelegator { /** * * @param arg1 * @param arg0 */ @WebMethod @RequestWrapper(localName = "sendSpende", targetNamespace = "http://ws.monitor.myaktion.dpunkt.de/", className = "de.dpunkt.myaktion.monitor.ws.SendSpende") @ResponseWrapper(localName = "sendSpendeResponse", targetNamespace = "http://ws.monitor.myaktion.dpunkt.de/", className = "de.dpunkt.myaktion.monitor.ws.SendSpendeResponse") public void sendSpende( @WebParam(name = "arg0", targetNamespace = "") Long arg0, @WebParam(name = "arg1", targetNamespace = "")
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/monitor/ws/SpendeDelegator.java import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.ws.RequestWrapper; import javax.xml.ws.ResponseWrapper; import de.dpunkt.myaktion.model.Spende; package de.dpunkt.myaktion.monitor.ws; /** * This class was generated by the JAX-WS RI. * JAX-WS RI 2.1.6 in JDK 6 * Generated source version: 2.1 * */ @WebService(name = "SpendeDelegator", targetNamespace = "http://ws.monitor.myaktion.dpunkt.de/") @XmlSeeAlso({ ObjectFactory.class }) public interface SpendeDelegator { /** * * @param arg1 * @param arg0 */ @WebMethod @RequestWrapper(localName = "sendSpende", targetNamespace = "http://ws.monitor.myaktion.dpunkt.de/", className = "de.dpunkt.myaktion.monitor.ws.SendSpende") @ResponseWrapper(localName = "sendSpendeResponse", targetNamespace = "http://ws.monitor.myaktion.dpunkt.de/", className = "de.dpunkt.myaktion.monitor.ws.SendSpendeResponse") public void sendSpende( @WebParam(name = "arg0", targetNamespace = "") Long arg0, @WebParam(name = "arg1", targetNamespace = "")
Spende arg1);
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/scheduler/SchedulerBean.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // }
import javax.ejb.Schedule; import javax.ejb.Singleton; import javax.inject.Inject; import de.dpunkt.myaktion.services.SpendeService;
package de.dpunkt.myaktion.scheduler; @Singleton public class SchedulerBean { @Inject
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/scheduler/SchedulerBean.java import javax.ejb.Schedule; import javax.ejb.Singleton; import javax.inject.Inject; import de.dpunkt.myaktion.services.SpendeService; package de.dpunkt.myaktion.scheduler; @Singleton public class SchedulerBean { @Inject
private SpendeService spendeService;
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/controller/SpendeFormEditController.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // }
import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.inject.Inject; import javax.inject.Named; import javax.servlet.http.HttpServletRequest; import de.dpunkt.myaktion.model.Aktion;
package de.dpunkt.myaktion.controller; @SessionScoped @Named public class SpendeFormEditController implements Serializable { private static final long serialVersionUID = -4210085664588144340L; private String textColor = "000000"; private String bgColor = "ffffff";
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/SpendeFormEditController.java import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.inject.Inject; import javax.inject.Named; import javax.servlet.http.HttpServletRequest; import de.dpunkt.myaktion.model.Aktion; package de.dpunkt.myaktion.controller; @SessionScoped @Named public class SpendeFormEditController implements Serializable { private static final long serialVersionUID = -4210085664588144340L; private String textColor = "000000"; private String bgColor = "ffffff";
private Aktion aktion;
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/monitor/ws/SendSpende.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // }
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; import de.dpunkt.myaktion.model.Spende;
package de.dpunkt.myaktion.monitor.ws; /** * <p>Java class for sendSpende complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="sendSpende"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="arg0" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/> * &lt;element name="arg1" type="{http://ws.monitor.myaktion.dpunkt.de/}spende" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "sendSpende", propOrder = { "arg0", "arg1" }) public class SendSpende { protected Long arg0;
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/monitor/ws/SendSpende.java import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; import de.dpunkt.myaktion.model.Spende; package de.dpunkt.myaktion.monitor.ws; /** * <p>Java class for sendSpende complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="sendSpende"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="arg0" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/> * &lt;element name="arg1" type="{http://ws.monitor.myaktion.dpunkt.de/}spende" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "sendSpende", propOrder = { "arg0", "arg1" }) public class SendSpende { protected Long arg0;
protected Spende arg1;
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/controller/AktionEditController.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // }
import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Event; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.util.Events.Added; import de.dpunkt.myaktion.util.Events.Updated;
package de.dpunkt.myaktion.controller; @SessionScoped @Named public class AktionEditController implements Serializable { private static final long serialVersionUID = 2815796004558360299L; @Inject @Added
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/AktionEditController.java import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Event; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.util.Events.Added; import de.dpunkt.myaktion.util.Events.Updated; package de.dpunkt.myaktion.controller; @SessionScoped @Named public class AktionEditController implements Serializable { private static final long serialVersionUID = 2815796004558360299L; @Inject @Added
private Event<Aktion> aktionAddEventSrc;
marcusschiesser/my-aktion
my-aktion-monitor/src/main/java/de/dpunkt/myaktion/monitor/SpendeListProvider.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // // Path: my-aktion-monitor/src/main/java/de/dpunkt/myaktion/monitor/util/DisableHostnameVerifier.java // public class DisableHostnameVerifier implements HostnameVerifier { // public boolean verify(String hostname, SSLSession sslSession) { // return true; // } // }
import java.util.List; import javax.ws.rs.NotFoundException; import javax.ws.rs.WebApplicationException; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType; import de.dpunkt.myaktion.model.Spende; import de.dpunkt.myaktion.model.SpendeListMBR; import de.dpunkt.myaktion.monitor.util.DisableHostnameVerifier;
package de.dpunkt.myaktion.monitor; /** * @author marcus */ public class SpendeListProvider { private static final String REST_HOST = "localhost"; private static final int REST_PORT = 8443; private static final String REST_SPENDE_LIST = "https://" + REST_HOST + ":" + REST_PORT + "/my-aktion/rest/spende/list/"; private Client restClient; public SpendeListProvider() { ClientBuilder builder = ClientBuilder.newBuilder(); builder.register(SpendeListMBR.class);
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // // Path: my-aktion-monitor/src/main/java/de/dpunkt/myaktion/monitor/util/DisableHostnameVerifier.java // public class DisableHostnameVerifier implements HostnameVerifier { // public boolean verify(String hostname, SSLSession sslSession) { // return true; // } // } // Path: my-aktion-monitor/src/main/java/de/dpunkt/myaktion/monitor/SpendeListProvider.java import java.util.List; import javax.ws.rs.NotFoundException; import javax.ws.rs.WebApplicationException; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType; import de.dpunkt.myaktion.model.Spende; import de.dpunkt.myaktion.model.SpendeListMBR; import de.dpunkt.myaktion.monitor.util.DisableHostnameVerifier; package de.dpunkt.myaktion.monitor; /** * @author marcus */ public class SpendeListProvider { private static final String REST_HOST = "localhost"; private static final int REST_PORT = 8443; private static final String REST_SPENDE_LIST = "https://" + REST_HOST + ":" + REST_PORT + "/my-aktion/rest/spende/list/"; private Client restClient; public SpendeListProvider() { ClientBuilder builder = ClientBuilder.newBuilder(); builder.register(SpendeListMBR.class);
builder.hostnameVerifier(new DisableHostnameVerifier());
marcusschiesser/my-aktion
my-aktion-monitor/src/main/java/de/dpunkt/myaktion/monitor/SpendeListProvider.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // // Path: my-aktion-monitor/src/main/java/de/dpunkt/myaktion/monitor/util/DisableHostnameVerifier.java // public class DisableHostnameVerifier implements HostnameVerifier { // public boolean verify(String hostname, SSLSession sslSession) { // return true; // } // }
import java.util.List; import javax.ws.rs.NotFoundException; import javax.ws.rs.WebApplicationException; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType; import de.dpunkt.myaktion.model.Spende; import de.dpunkt.myaktion.model.SpendeListMBR; import de.dpunkt.myaktion.monitor.util.DisableHostnameVerifier;
package de.dpunkt.myaktion.monitor; /** * @author marcus */ public class SpendeListProvider { private static final String REST_HOST = "localhost"; private static final int REST_PORT = 8443; private static final String REST_SPENDE_LIST = "https://" + REST_HOST + ":" + REST_PORT + "/my-aktion/rest/spende/list/"; private Client restClient; public SpendeListProvider() { ClientBuilder builder = ClientBuilder.newBuilder(); builder.register(SpendeListMBR.class); builder.hostnameVerifier(new DisableHostnameVerifier()); restClient = builder.build(); } /** * Gibt die Liste aller Spenden zu der Aktion mit der angegebenen ID zurück. * * @param aktionId * @return * @throws NotFoundException * @throws WebApplicationException */
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // // Path: my-aktion-monitor/src/main/java/de/dpunkt/myaktion/monitor/util/DisableHostnameVerifier.java // public class DisableHostnameVerifier implements HostnameVerifier { // public boolean verify(String hostname, SSLSession sslSession) { // return true; // } // } // Path: my-aktion-monitor/src/main/java/de/dpunkt/myaktion/monitor/SpendeListProvider.java import java.util.List; import javax.ws.rs.NotFoundException; import javax.ws.rs.WebApplicationException; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType; import de.dpunkt.myaktion.model.Spende; import de.dpunkt.myaktion.model.SpendeListMBR; import de.dpunkt.myaktion.monitor.util.DisableHostnameVerifier; package de.dpunkt.myaktion.monitor; /** * @author marcus */ public class SpendeListProvider { private static final String REST_HOST = "localhost"; private static final int REST_PORT = 8443; private static final String REST_SPENDE_LIST = "https://" + REST_HOST + ":" + REST_PORT + "/my-aktion/rest/spende/list/"; private Client restClient; public SpendeListProvider() { ClientBuilder builder = ClientBuilder.newBuilder(); builder.register(SpendeListMBR.class); builder.hostnameVerifier(new DisableHostnameVerifier()); restClient = builder.build(); } /** * Gibt die Liste aller Spenden zu der Aktion mit der angegebenen ID zurück. * * @param aktionId * @return * @throws NotFoundException * @throws WebApplicationException */
public List<Spende> getSpendeList(long aktionId) throws NotFoundException,
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/services/AktionServiceBean.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // }
import java.util.List; import javax.annotation.Resource; import javax.annotation.security.RolesAllowed; import javax.ejb.SessionContext; import javax.ejb.Stateless; import javax.inject.Inject; import javax.persistence.EntityManager; import javax.persistence.TypedQuery; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.model.Organisator;
package de.dpunkt.myaktion.services; @Stateless @RolesAllowed("Organisator") public class AktionServiceBean implements AktionService { @Inject private EntityManager entityManager; @Resource private SessionContext sessionContext;
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/AktionServiceBean.java import java.util.List; import javax.annotation.Resource; import javax.annotation.security.RolesAllowed; import javax.ejb.SessionContext; import javax.ejb.Stateless; import javax.inject.Inject; import javax.persistence.EntityManager; import javax.persistence.TypedQuery; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.model.Organisator; package de.dpunkt.myaktion.services; @Stateless @RolesAllowed("Organisator") public class AktionServiceBean implements AktionService { @Inject private EntityManager entityManager; @Resource private SessionContext sessionContext;
public List<Aktion> getAllAktionen() {
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/controller/GeldSpendenController.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // }
import java.io.Serializable; import java.util.logging.Logger; import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Spende; import de.dpunkt.myaktion.model.Spende.Status; import de.dpunkt.myaktion.services.SpendeService;
package de.dpunkt.myaktion.controller; @SessionScoped @Named public class GeldSpendenController implements Serializable { private static final long serialVersionUID = 5493038842003809106L; private String textColor = "000000"; private String bgColor = "ffffff"; private Long aktionId;
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/GeldSpendenController.java import java.io.Serializable; import java.util.logging.Logger; import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Spende; import de.dpunkt.myaktion.model.Spende.Status; import de.dpunkt.myaktion.services.SpendeService; package de.dpunkt.myaktion.controller; @SessionScoped @Named public class GeldSpendenController implements Serializable { private static final long serialVersionUID = 5493038842003809106L; private String textColor = "000000"; private String bgColor = "ffffff"; private Long aktionId;
private Spende spende;
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/controller/GeldSpendenController.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // }
import java.io.Serializable; import java.util.logging.Logger; import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Spende; import de.dpunkt.myaktion.model.Spende.Status; import de.dpunkt.myaktion.services.SpendeService;
package de.dpunkt.myaktion.controller; @SessionScoped @Named public class GeldSpendenController implements Serializable { private static final long serialVersionUID = 5493038842003809106L; private String textColor = "000000"; private String bgColor = "ffffff"; private Long aktionId; private Spende spende; @Inject private FacesContext facesContext; @Inject private Logger logger; @Inject
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/GeldSpendenController.java import java.io.Serializable; import java.util.logging.Logger; import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Spende; import de.dpunkt.myaktion.model.Spende.Status; import de.dpunkt.myaktion.services.SpendeService; package de.dpunkt.myaktion.controller; @SessionScoped @Named public class GeldSpendenController implements Serializable { private static final long serialVersionUID = 5493038842003809106L; private String textColor = "000000"; private String bgColor = "ffffff"; private Long aktionId; private Spende spende; @Inject private FacesContext facesContext; @Inject private Logger logger; @Inject
private SpendeService spendeService;
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/controller/GeldSpendenController.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // }
import java.io.Serializable; import java.util.logging.Logger; import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Spende; import de.dpunkt.myaktion.model.Spende.Status; import de.dpunkt.myaktion.services.SpendeService;
public void setSpende(Spende spende) { this.spende = spende; } public String getTextColor() { return textColor; } public void setTextColor(String textColor) { this.textColor = textColor; } public String getBgColor() { return bgColor; } public void setBgColor(String bgColor) { this.bgColor = bgColor; } public String doSpende() { addSpende(); FacesMessage facesMessage = new FacesMessage( FacesMessage.SEVERITY_INFO, "Vielen Dank für die Spende", null); facesContext.addMessage(null, facesMessage); return Pages.GELD_SPENDEN; } public void addSpende() {
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/GeldSpendenController.java import java.io.Serializable; import java.util.logging.Logger; import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Spende; import de.dpunkt.myaktion.model.Spende.Status; import de.dpunkt.myaktion.services.SpendeService; public void setSpende(Spende spende) { this.spende = spende; } public String getTextColor() { return textColor; } public void setTextColor(String textColor) { this.textColor = textColor; } public String getBgColor() { return bgColor; } public void setBgColor(String bgColor) { this.bgColor = bgColor; } public String doSpende() { addSpende(); FacesMessage facesMessage = new FacesMessage( FacesMessage.SEVERITY_INFO, "Vielen Dank für die Spende", null); facesContext.addMessage(null, facesMessage); return Pages.GELD_SPENDEN; } public void addSpende() {
getSpende().setStatus(Status.IN_BEARBEITUNG);
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/monitor/ws/ObjectFactory.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // }
import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementDecl; import javax.xml.bind.annotation.XmlRegistry; import javax.xml.namespace.QName; import de.dpunkt.myaktion.model.Spende;
package de.dpunkt.myaktion.monitor.ws; /** * This object contains factory methods for each * Java content interface and Java element interface * generated in the de.dpunkt.myaktion.monitor.ws package. * <p>An ObjectFactory allows you to programatically * construct new instances of the Java representation * for XML content. The Java representation of XML * content can consist of schema derived interfaces * and classes representing the binding of schema * type definitions, element declarations and model * groups. Factory methods for each of these are * provided in this class. * */ @XmlRegistry public class ObjectFactory { private final static QName _SendSpende_QNAME = new QName("http://ws.monitor.myaktion.dpunkt.de/", "sendSpende"); private final static QName _SendSpendeResponse_QNAME = new QName("http://ws.monitor.myaktion.dpunkt.de/", "sendSpendeResponse"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: de.dpunkt.myaktion.monitor.ws * */ public ObjectFactory() { } /** * Create an instance of {@link SendSpendeResponse } * */ public SendSpendeResponse createSendSpendeResponse() { return new SendSpendeResponse(); } /** * Create an instance of {@link SendSpende } * */ public SendSpende createSendSpende() { return new SendSpende(); } /** * Create an instance of {@link Spende } * */
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // @NamedQueries({ // @NamedQuery(name=Spende.findByStatus,query="SELECT s FROM Spende s WHERE s.status = :status") // }) // @Entity // public class Spende implements Serializable { // private static final long serialVersionUID = -305029412912522665L; // // public static final String findByStatus = "Spende.findWorkInProcess"; // // // Der NumberConverter konvertiert leere Strings in einen Null-Wert, daher // // kommen bei Nicht-Angabe Null-Werte von Faces zurück - für diese wird daher ein Message-Wert benötigt. // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double betrag; // @NotNull // @Size(min=5, max=40, message="Der Name eines Spenders muss min. 5 und darf max. 40 Zeichen lang sein.") // private String spenderName; // @NotNull // private Boolean quittung; // @NotNull // private Status status; // @NotNull // private Konto konto; // @NotNull // @ManyToOne // private Aktion aktion; // // @GeneratedValue // @Id // private Long id; // // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // public Spende() { // this.konto = new Konto(); // } // // public Aktion getAktion() { // return aktion; // } // // public void setAktion(Aktion aktion) { // this.aktion = aktion; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Double getBetrag() { // return betrag; // } // // public void setBetrag(Double betrag) { // this.betrag = betrag; // } // // public String getSpenderName() { // return spenderName; // } // // public void setSpenderName(String spenderName) { // this.spenderName = spenderName; // } // // public Boolean getQuittung() { // return quittung; // } // // public void setQuittung(Boolean quittung) { // this.quittung = quittung; // } // // public Status getStatus() { // return status; // } // // public void setStatus(Status status) { // this.status = status; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/monitor/ws/ObjectFactory.java import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementDecl; import javax.xml.bind.annotation.XmlRegistry; import javax.xml.namespace.QName; import de.dpunkt.myaktion.model.Spende; package de.dpunkt.myaktion.monitor.ws; /** * This object contains factory methods for each * Java content interface and Java element interface * generated in the de.dpunkt.myaktion.monitor.ws package. * <p>An ObjectFactory allows you to programatically * construct new instances of the Java representation * for XML content. The Java representation of XML * content can consist of schema derived interfaces * and classes representing the binding of schema * type definitions, element declarations and model * groups. Factory methods for each of these are * provided in this class. * */ @XmlRegistry public class ObjectFactory { private final static QName _SendSpende_QNAME = new QName("http://ws.monitor.myaktion.dpunkt.de/", "sendSpende"); private final static QName _SendSpendeResponse_QNAME = new QName("http://ws.monitor.myaktion.dpunkt.de/", "sendSpendeResponse"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: de.dpunkt.myaktion.monitor.ws * */ public ObjectFactory() { } /** * Create an instance of {@link SendSpendeResponse } * */ public SendSpendeResponse createSendSpendeResponse() { return new SendSpendeResponse(); } /** * Create an instance of {@link SendSpende } * */ public SendSpende createSendSpende() { return new SendSpende(); } /** * Create an instance of {@link Spende } * */
public Spende createSpende() {
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/controller/AktionListController.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/AktionEditController.java // public enum Mode { // EDIT, ADD // }; // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // }
import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Event; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.controller.AktionEditController.Mode; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.util.Events.Deleted;
package de.dpunkt.myaktion.controller; @SessionScoped @Named public class AktionListController implements Serializable { private static final long serialVersionUID = 8693277383648025822L; @Inject private AktionEditController aktionEditController; @Inject private SpendeListController spendeListController; @Inject private SpendeFormEditController spendeFormEditController; @Inject @Deleted
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/AktionEditController.java // public enum Mode { // EDIT, ADD // }; // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/AktionListController.java import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Event; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.controller.AktionEditController.Mode; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.util.Events.Deleted; package de.dpunkt.myaktion.controller; @SessionScoped @Named public class AktionListController implements Serializable { private static final long serialVersionUID = 8693277383648025822L; @Inject private AktionEditController aktionEditController; @Inject private SpendeListController spendeListController; @Inject private SpendeFormEditController spendeFormEditController; @Inject @Deleted
private Event<Aktion> aktionDeleteEventSrc;
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/controller/AktionListController.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/AktionEditController.java // public enum Mode { // EDIT, ADD // }; // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // }
import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Event; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.controller.AktionEditController.Mode; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.util.Events.Deleted;
package de.dpunkt.myaktion.controller; @SessionScoped @Named public class AktionListController implements Serializable { private static final long serialVersionUID = 8693277383648025822L; @Inject private AktionEditController aktionEditController; @Inject private SpendeListController spendeListController; @Inject private SpendeFormEditController spendeFormEditController; @Inject @Deleted private Event<Aktion> aktionDeleteEventSrc; private Aktion aktionToDelete; public String doAddAktion() {
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/AktionEditController.java // public enum Mode { // EDIT, ADD // }; // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/AktionListController.java import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Event; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.controller.AktionEditController.Mode; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.util.Events.Deleted; package de.dpunkt.myaktion.controller; @SessionScoped @Named public class AktionListController implements Serializable { private static final long serialVersionUID = 8693277383648025822L; @Inject private AktionEditController aktionEditController; @Inject private SpendeListController spendeListController; @Inject private SpendeFormEditController spendeFormEditController; @Inject @Deleted private Event<Aktion> aktionDeleteEventSrc; private Aktion aktionToDelete; public String doAddAktion() {
aktionEditController.setAktionToEdit(Mode.ADD);
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/controller/SpendeListController.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // }
import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.model.Spende.Status; import de.dpunkt.myaktion.services.SpendeService;
package de.dpunkt.myaktion.controller; @RequestScoped @Named public class SpendeListController {
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/SpendeListController.java import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.model.Spende.Status; import de.dpunkt.myaktion.services.SpendeService; package de.dpunkt.myaktion.controller; @RequestScoped @Named public class SpendeListController {
private Aktion aktion;
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/controller/SpendeListController.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // }
import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.model.Spende.Status; import de.dpunkt.myaktion.services.SpendeService;
package de.dpunkt.myaktion.controller; @RequestScoped @Named public class SpendeListController { private Aktion aktion; @Inject
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/SpendeListController.java import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.model.Spende.Status; import de.dpunkt.myaktion.services.SpendeService; package de.dpunkt.myaktion.controller; @RequestScoped @Named public class SpendeListController { private Aktion aktion; @Inject
private SpendeService spendeService;
marcusschiesser/my-aktion
my-aktion/src/main/java/de/dpunkt/myaktion/controller/SpendeListController.java
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // }
import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.model.Spende.Status; import de.dpunkt.myaktion.services.SpendeService;
package de.dpunkt.myaktion.controller; @RequestScoped @Named public class SpendeListController { private Aktion aktion; @Inject private SpendeService spendeService; public Aktion getAktion() { return aktion; } public void setAktion(Aktion aktion) { aktion.setSpenden(spendeService.getSpendeList(aktion.getId())); this.aktion = aktion; } public String doOk() { return Pages.AKTION_LIST; }
// Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Aktion.java // @NamedQueries({ // @NamedQuery(name=Aktion.findByOrganisator,query="SELECT a FROM Aktion a WHERE a.organisator = :organisator ORDER BY a.name"), // @NamedQuery(name=Aktion.findAll,query="SELECT a FROM Aktion a ORDER BY a.name"), // @NamedQuery(name=Aktion.getBisherGespendet,query="SELECT SUM(s.betrag) FROM Spende s WHERE s.aktion = :aktion") // }) // @Entity // public class Aktion { // public static final String findByOrganisator = "Aktion.findByOrganisator"; // public static final String findAll = "Aktion.findAll"; // public static final String getBisherGespendet = "Aktion.getBisherGespendet"; // // @NotNull // @Size(min=4, max=30, message="Der Name einer Aktion muss min. 4 und darf max. 30 Zeichen lang sein.") // private String name; // @NotNull(message="Bitte ein Spendenziel angeben.") // @DecimalMin(value="10.00", message="Das Spendenziel für die Aktion muss min. 10 Euro sein.") // private Double spendenZiel; // @NotNull(message="Bitte einen Spendenbetrag angeben.") // @DecimalMin(value="1.00", message="Der Spendenbetrag muss min. 1 Euro sein.") // private Double spendenBetrag; // @Transient // private Double bisherGespendet; // // @AttributeOverrides({ @AttributeOverride(name = "name", column = @Column(name = "kontoName")) }) // @Embedded // private Konto konto; // // @OneToMany(mappedBy = "aktion", cascade = CascadeType.REMOVE) // private List<Spende> spenden; // @ManyToOne // private Organisator organisator; // // @GeneratedValue // @Id // private Long id; // // public Aktion() { // konto = new Konto(); // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Double getSpendenZiel() { // return spendenZiel; // } // // public void setSpendenZiel(Double spendenZiel) { // this.spendenZiel = spendenZiel; // } // // public Double getSpendenBetrag() { // return spendenBetrag; // } // // public void setSpendenBetrag(Double spendenBetrag) { // this.spendenBetrag = spendenBetrag; // } // // public Double getBisherGespendet() { // return bisherGespendet; // } // // public void setBisherGespendet(Double bisherGespendet) { // this.bisherGespendet = bisherGespendet; // } // // public Konto getKonto() { // return konto; // } // // public void setKonto(Konto konto) { // this.konto = konto; // } // // public List<Spende> getSpenden() { // return spenden; // } // // public void setSpenden(List<Spende> spenden) { // this.spenden = spenden; // } // // public Organisator getOrganisator() { // return organisator; // } // // public void setOrganisator(Organisator organisator) { // this.organisator = organisator; // } // // // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/model/Spende.java // public enum Status { // UEBERWIESEN, IN_BEARBEITUNG; // } // // Path: my-aktion/src/main/java/de/dpunkt/myaktion/services/SpendeService.java // public interface SpendeService { // List<Spende> getSpendeListPublic(Long aktionId) throws ObjectNotFoundException; // List<Spende> getSpendeList(Long aktionId); // void addSpende(Long aktionId, Spende spende); // void transferSpende(); // } // Path: my-aktion/src/main/java/de/dpunkt/myaktion/controller/SpendeListController.java import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import de.dpunkt.myaktion.model.Aktion; import de.dpunkt.myaktion.model.Spende.Status; import de.dpunkt.myaktion.services.SpendeService; package de.dpunkt.myaktion.controller; @RequestScoped @Named public class SpendeListController { private Aktion aktion; @Inject private SpendeService spendeService; public Aktion getAktion() { return aktion; } public void setAktion(Aktion aktion) { aktion.setSpenden(spendeService.getSpendeList(aktion.getId())); this.aktion = aktion; } public String doOk() { return Pages.AKTION_LIST; }
public String convertStatus(Status status) {
jenkinsci/plugin-compat-tester
plugins-compat-tester/src/test/java/org/jenkins/tools/test/hook/JacocoHookTest.java
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/MavenCoordinates.java // public class MavenCoordinates implements Comparable<MavenCoordinates> { // public final String groupId; // public final String artifactId; // public final String version; // // No classifier/type for the moment... // // /** // * Constructor. // * // * @throws IllegalArgumentException one of the parameters is invalid. // */ // public MavenCoordinates(@Nonnull String groupId, @Nonnull String artifactId, @Nonnull String version){ // this.groupId = verifyInput( groupId, artifactId, version,"groupId", groupId); // this.artifactId = verifyInput( groupId, artifactId, version,"artifactId", artifactId); // this.version = verifyInput( groupId, artifactId, version,"version", version); // } // // private static String verifyInput(String groupId, String artifactId, String version, // String fieldName, String value) throws IllegalArgumentException { // if (value == null || StringUtils.isBlank(value)) { // throw new IllegalArgumentException( // String.format("Invalid parameter passed for %s:%s:%s: Field %s; %s", // groupId, artifactId, version, fieldName, value)); // } // return value.trim(); // } // // @Override // public boolean equals(Object o){ // if (!(o instanceof MavenCoordinates)) { // return false; // } // MavenCoordinates c2 = (MavenCoordinates)o; // return new EqualsBuilder().append(groupId, c2.groupId).append(artifactId, c2.artifactId).append(version, c2.version).isEquals(); // } // // @Override // public int hashCode(){ // return new HashCodeBuilder().append(groupId).append(artifactId).append(version).toHashCode(); // } // // @Override // public String toString(){ // return "MavenCoordinates[groupId="+groupId+", artifactId="+artifactId+", version="+version+"]"; // } // // public String toGAV(){ // return groupId+":"+artifactId+":"+version; // } // // public static MavenCoordinates fromGAV(String gav){ // String[] chunks = gav.split(":"); // return new MavenCoordinates(chunks[0], chunks[1], chunks[2]); // } // // @Override // public int compareTo(MavenCoordinates o) { // if((groupId+":"+artifactId).equals(o.groupId+":"+o.artifactId)){ // return compareVersionTo(o.version); // } else { // return (groupId+":"+artifactId).compareTo(o.groupId+":"+o.artifactId); // } // } // // public boolean matches(String groupId, String artifactId) { // return this.groupId.equals(groupId) && this.artifactId.equals(artifactId); // } // // public int compareVersionTo(String version) { // return new VersionComparator().compare(this.version, version); // } // } // // Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // }
import com.google.common.collect.Lists; import org.jenkins.tools.test.model.MavenCoordinates; import org.jenkins.tools.test.model.PomData; import org.junit.Test; import java.util.HashMap; import java.util.List; import java.util.Map; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue;
package org.jenkins.tools.test.hook; public class JacocoHookTest { @Test public void testCheckMethod() { final JacocoHook hook = new JacocoHook();
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/MavenCoordinates.java // public class MavenCoordinates implements Comparable<MavenCoordinates> { // public final String groupId; // public final String artifactId; // public final String version; // // No classifier/type for the moment... // // /** // * Constructor. // * // * @throws IllegalArgumentException one of the parameters is invalid. // */ // public MavenCoordinates(@Nonnull String groupId, @Nonnull String artifactId, @Nonnull String version){ // this.groupId = verifyInput( groupId, artifactId, version,"groupId", groupId); // this.artifactId = verifyInput( groupId, artifactId, version,"artifactId", artifactId); // this.version = verifyInput( groupId, artifactId, version,"version", version); // } // // private static String verifyInput(String groupId, String artifactId, String version, // String fieldName, String value) throws IllegalArgumentException { // if (value == null || StringUtils.isBlank(value)) { // throw new IllegalArgumentException( // String.format("Invalid parameter passed for %s:%s:%s: Field %s; %s", // groupId, artifactId, version, fieldName, value)); // } // return value.trim(); // } // // @Override // public boolean equals(Object o){ // if (!(o instanceof MavenCoordinates)) { // return false; // } // MavenCoordinates c2 = (MavenCoordinates)o; // return new EqualsBuilder().append(groupId, c2.groupId).append(artifactId, c2.artifactId).append(version, c2.version).isEquals(); // } // // @Override // public int hashCode(){ // return new HashCodeBuilder().append(groupId).append(artifactId).append(version).toHashCode(); // } // // @Override // public String toString(){ // return "MavenCoordinates[groupId="+groupId+", artifactId="+artifactId+", version="+version+"]"; // } // // public String toGAV(){ // return groupId+":"+artifactId+":"+version; // } // // public static MavenCoordinates fromGAV(String gav){ // String[] chunks = gav.split(":"); // return new MavenCoordinates(chunks[0], chunks[1], chunks[2]); // } // // @Override // public int compareTo(MavenCoordinates o) { // if((groupId+":"+artifactId).equals(o.groupId+":"+o.artifactId)){ // return compareVersionTo(o.version); // } else { // return (groupId+":"+artifactId).compareTo(o.groupId+":"+o.artifactId); // } // } // // public boolean matches(String groupId, String artifactId) { // return this.groupId.equals(groupId) && this.artifactId.equals(artifactId); // } // // public int compareVersionTo(String version) { // return new VersionComparator().compare(this.version, version); // } // } // // Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // } // Path: plugins-compat-tester/src/test/java/org/jenkins/tools/test/hook/JacocoHookTest.java import com.google.common.collect.Lists; import org.jenkins.tools.test.model.MavenCoordinates; import org.jenkins.tools.test.model.PomData; import org.junit.Test; import java.util.HashMap; import java.util.List; import java.util.Map; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; package org.jenkins.tools.test.hook; public class JacocoHookTest { @Test public void testCheckMethod() { final JacocoHook hook = new JacocoHook();
final MavenCoordinates parent = new MavenCoordinates("org.jenkins-ci.plugins", "plugin", "3.57");
jenkinsci/plugin-compat-tester
plugins-compat-tester/src/test/java/org/jenkins/tools/test/hook/JacocoHookTest.java
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/MavenCoordinates.java // public class MavenCoordinates implements Comparable<MavenCoordinates> { // public final String groupId; // public final String artifactId; // public final String version; // // No classifier/type for the moment... // // /** // * Constructor. // * // * @throws IllegalArgumentException one of the parameters is invalid. // */ // public MavenCoordinates(@Nonnull String groupId, @Nonnull String artifactId, @Nonnull String version){ // this.groupId = verifyInput( groupId, artifactId, version,"groupId", groupId); // this.artifactId = verifyInput( groupId, artifactId, version,"artifactId", artifactId); // this.version = verifyInput( groupId, artifactId, version,"version", version); // } // // private static String verifyInput(String groupId, String artifactId, String version, // String fieldName, String value) throws IllegalArgumentException { // if (value == null || StringUtils.isBlank(value)) { // throw new IllegalArgumentException( // String.format("Invalid parameter passed for %s:%s:%s: Field %s; %s", // groupId, artifactId, version, fieldName, value)); // } // return value.trim(); // } // // @Override // public boolean equals(Object o){ // if (!(o instanceof MavenCoordinates)) { // return false; // } // MavenCoordinates c2 = (MavenCoordinates)o; // return new EqualsBuilder().append(groupId, c2.groupId).append(artifactId, c2.artifactId).append(version, c2.version).isEquals(); // } // // @Override // public int hashCode(){ // return new HashCodeBuilder().append(groupId).append(artifactId).append(version).toHashCode(); // } // // @Override // public String toString(){ // return "MavenCoordinates[groupId="+groupId+", artifactId="+artifactId+", version="+version+"]"; // } // // public String toGAV(){ // return groupId+":"+artifactId+":"+version; // } // // public static MavenCoordinates fromGAV(String gav){ // String[] chunks = gav.split(":"); // return new MavenCoordinates(chunks[0], chunks[1], chunks[2]); // } // // @Override // public int compareTo(MavenCoordinates o) { // if((groupId+":"+artifactId).equals(o.groupId+":"+o.artifactId)){ // return compareVersionTo(o.version); // } else { // return (groupId+":"+artifactId).compareTo(o.groupId+":"+o.artifactId); // } // } // // public boolean matches(String groupId, String artifactId) { // return this.groupId.equals(groupId) && this.artifactId.equals(artifactId); // } // // public int compareVersionTo(String version) { // return new VersionComparator().compare(this.version, version); // } // } // // Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // }
import com.google.common.collect.Lists; import org.jenkins.tools.test.model.MavenCoordinates; import org.jenkins.tools.test.model.PomData; import org.junit.Test; import java.util.HashMap; import java.util.List; import java.util.Map; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue;
package org.jenkins.tools.test.hook; public class JacocoHookTest { @Test public void testCheckMethod() { final JacocoHook hook = new JacocoHook(); final MavenCoordinates parent = new MavenCoordinates("org.jenkins-ci.plugins", "plugin", "3.57");
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/MavenCoordinates.java // public class MavenCoordinates implements Comparable<MavenCoordinates> { // public final String groupId; // public final String artifactId; // public final String version; // // No classifier/type for the moment... // // /** // * Constructor. // * // * @throws IllegalArgumentException one of the parameters is invalid. // */ // public MavenCoordinates(@Nonnull String groupId, @Nonnull String artifactId, @Nonnull String version){ // this.groupId = verifyInput( groupId, artifactId, version,"groupId", groupId); // this.artifactId = verifyInput( groupId, artifactId, version,"artifactId", artifactId); // this.version = verifyInput( groupId, artifactId, version,"version", version); // } // // private static String verifyInput(String groupId, String artifactId, String version, // String fieldName, String value) throws IllegalArgumentException { // if (value == null || StringUtils.isBlank(value)) { // throw new IllegalArgumentException( // String.format("Invalid parameter passed for %s:%s:%s: Field %s; %s", // groupId, artifactId, version, fieldName, value)); // } // return value.trim(); // } // // @Override // public boolean equals(Object o){ // if (!(o instanceof MavenCoordinates)) { // return false; // } // MavenCoordinates c2 = (MavenCoordinates)o; // return new EqualsBuilder().append(groupId, c2.groupId).append(artifactId, c2.artifactId).append(version, c2.version).isEquals(); // } // // @Override // public int hashCode(){ // return new HashCodeBuilder().append(groupId).append(artifactId).append(version).toHashCode(); // } // // @Override // public String toString(){ // return "MavenCoordinates[groupId="+groupId+", artifactId="+artifactId+", version="+version+"]"; // } // // public String toGAV(){ // return groupId+":"+artifactId+":"+version; // } // // public static MavenCoordinates fromGAV(String gav){ // String[] chunks = gav.split(":"); // return new MavenCoordinates(chunks[0], chunks[1], chunks[2]); // } // // @Override // public int compareTo(MavenCoordinates o) { // if((groupId+":"+artifactId).equals(o.groupId+":"+o.artifactId)){ // return compareVersionTo(o.version); // } else { // return (groupId+":"+artifactId).compareTo(o.groupId+":"+o.artifactId); // } // } // // public boolean matches(String groupId, String artifactId) { // return this.groupId.equals(groupId) && this.artifactId.equals(artifactId); // } // // public int compareVersionTo(String version) { // return new VersionComparator().compare(this.version, version); // } // } // // Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // } // Path: plugins-compat-tester/src/test/java/org/jenkins/tools/test/hook/JacocoHookTest.java import com.google.common.collect.Lists; import org.jenkins.tools.test.model.MavenCoordinates; import org.jenkins.tools.test.model.PomData; import org.junit.Test; import java.util.HashMap; import java.util.List; import java.util.Map; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; package org.jenkins.tools.test.hook; public class JacocoHookTest { @Test public void testCheckMethod() { final JacocoHook hook = new JacocoHook(); final MavenCoordinates parent = new MavenCoordinates("org.jenkins-ci.plugins", "plugin", "3.57");
PomData pomData = new PomData("jacoco", "hpi", "it-does-not-matter", "whatever", parent, "org.jenkins-ci.plugins");
jenkinsci/plugin-compat-tester
plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/WarningsNGCheckoutHook.java
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // }
import hudson.model.UpdateSite; import org.jenkins.tools.test.model.PomData; import java.io.File; import java.util.Map;
package org.jenkins.tools.test.hook; public class WarningsNGCheckoutHook extends AbstractMultiParentHook { @Override protected String getParentFolder() { return "warnings-ng-plugin"; } @Override protected String getParentProjectName() { return "warnings-ng"; } @Override public boolean check(Map<String, Object> info) { return isWarningsNG(info); } @Override protected String getPluginFolderName(UpdateSite.Plugin currentPlugin) { return "plugin"; } private boolean isWarningsNG(Map<String, Object> moreInfo) {
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // } // Path: plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/WarningsNGCheckoutHook.java import hudson.model.UpdateSite; import org.jenkins.tools.test.model.PomData; import java.io.File; import java.util.Map; package org.jenkins.tools.test.hook; public class WarningsNGCheckoutHook extends AbstractMultiParentHook { @Override protected String getParentFolder() { return "warnings-ng-plugin"; } @Override protected String getParentProjectName() { return "warnings-ng"; } @Override public boolean check(Map<String, Object> info) { return isWarningsNG(info); } @Override protected String getPluginFolderName(UpdateSite.Plugin currentPlugin) { return "plugin"; } private boolean isWarningsNG(Map<String, Object> moreInfo) {
PomData data = (PomData) moreInfo.get("pomData");
jenkinsci/plugin-compat-tester
plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/AwsJavaSdkHook.java
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // }
import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import org.jenkins.tools.test.model.PomData;
package org.jenkins.tools.test.hook; public class AwsJavaSdkHook extends AbstractMultiParentHook { private static final Logger LOGGER = Logger.getLogger(AwsJavaSdkHook.class.getName()); @Override protected String getParentFolder() { return "aws-java-sdk"; } @Override protected String getParentProjectName() { return "aws-java-sdk-parent"; } @Override public boolean check(Map<String, Object> info) { return isAwsJavaSdkPlugin(info); } private boolean isAwsJavaSdkPlugin(Map<String, Object> moreInfo) {
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // } // Path: plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/AwsJavaSdkHook.java import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import org.jenkins.tools.test.model.PomData; package org.jenkins.tools.test.hook; public class AwsJavaSdkHook extends AbstractMultiParentHook { private static final Logger LOGGER = Logger.getLogger(AwsJavaSdkHook.class.getName()); @Override protected String getParentFolder() { return "aws-java-sdk"; } @Override protected String getParentProjectName() { return "aws-java-sdk-parent"; } @Override public boolean check(Map<String, Object> info) { return isAwsJavaSdkPlugin(info); } private boolean isAwsJavaSdkPlugin(Map<String, Object> moreInfo) {
PomData data = (PomData) moreInfo.get("pomData");
jenkinsci/plugin-compat-tester
plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/hook/PluginCompatTesterHookBeforeExecution.java
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // }
import java.util.Map; import org.jenkins.tools.test.model.PomData;
package org.jenkins.tools.test.model.hook; /** * An abstract class that marks a hook that runs before the execution stage of the Plugin * Compatibility Tester. * * <p>This exists simply for the ability to check when a subclass should be implemented. */ public abstract class PluginCompatTesterHookBeforeExecution implements PluginCompatTesterHook { /** * Check the value of {@code args} (the arguments with which to run {@code mvn test}) and {@code * pomData} (if the plugin should be checked out again). */ @Override public void validate(Map<String, Object> toCheck) { if((toCheck.get("args") != null && toCheck.get("args") instanceof String) && (toCheck.get("pomData") != null &&
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // } // Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/hook/PluginCompatTesterHookBeforeExecution.java import java.util.Map; import org.jenkins.tools.test.model.PomData; package org.jenkins.tools.test.model.hook; /** * An abstract class that marks a hook that runs before the execution stage of the Plugin * Compatibility Tester. * * <p>This exists simply for the ability to check when a subclass should be implemented. */ public abstract class PluginCompatTesterHookBeforeExecution implements PluginCompatTesterHook { /** * Check the value of {@code args} (the arguments with which to run {@code mvn test}) and {@code * pomData} (if the plugin should be checked out again). */ @Override public void validate(Map<String, Object> toCheck) { if((toCheck.get("args") != null && toCheck.get("args") instanceof String) && (toCheck.get("pomData") != null &&
toCheck.get("pomData") instanceof PomData) ) {
jenkinsci/plugin-compat-tester
plugins-compat-tester-cli/src/main/java/org/jenkins/tools/test/CliOptions.java
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PCTPlugin.java // public class PCTPlugin { // private String name; // private final String groupId; // private VersionNumber version; // // public PCTPlugin(String name, String groupId, VersionNumber version) { // this.name = name; // this.groupId = groupId; // this.version = version; // } // // public String getName() { // return name; // } // // @CheckForNull // public String getGroupId() { // return groupId; // } // // public VersionNumber getVersion() { // return version; // } // } // // Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/TestStatus.java // public enum TestStatus { // INTERNAL_ERROR(0.0), COMPILATION_ERROR(1.0), TEST_FAILURES(2.0), SUCCESS(3.0); // // private final double weight; // // TestStatus(double weight){ // this.weight = weight; // } // // public boolean isLowerThan(TestStatus s){ // return weight < s.weight; // } // }
import org.jenkins.tools.test.model.PCTPlugin; import org.jenkins.tools.test.model.TestStatus; import com.beust.jcommander.IParameterValidator; import com.beust.jcommander.IStringConverter; import com.beust.jcommander.Parameter; import com.beust.jcommander.ParameterException; import hudson.util.VersionNumber; import java.util.Collections; import java.io.File; import java.util.ArrayList; import java.util.List; import javax.annotation.CheckForNull;
"It is useful to use your own fork releases for an specific plugin if the " + "version is not found in the official repository.\n" + "If set, The PCT will try to use the fallback if a plugin tag is not found in the regular URL.") private String fallbackGitHubOrganization = null; @Parameter(names = "-m2SettingsFile", description = "Maven settings file used while executing maven") private File m2SettingsFile; @Parameter(names = "-mvn", description = "External Maven executable") @CheckForNull private File externalMaven; @Parameter(names = "-skipTestCache", description = "Allows to skip compatibility test cache (by default, to 100 days)\n" + "If set to true, every plugin will be tested, no matter the cache is.") private String skipTestCache = null; @Parameter(names = "-testCacheTimeout", description = "Allows to override the test cache timeout.\n" + "Test cache timeout allows to not perform compatibility test over\n" + "some plugins if compatibility test was performed recently.\n" + "Cache timeout is given in milliseconds") private Long testCacheTimeout = null; @Parameter(names = "-cacheThresholdStatus", description = "Allows to define a minimal cache threshold for test status.\n" + "That is to say, every results lower than this threshold won't be considered\n" + "as part of the cache")
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PCTPlugin.java // public class PCTPlugin { // private String name; // private final String groupId; // private VersionNumber version; // // public PCTPlugin(String name, String groupId, VersionNumber version) { // this.name = name; // this.groupId = groupId; // this.version = version; // } // // public String getName() { // return name; // } // // @CheckForNull // public String getGroupId() { // return groupId; // } // // public VersionNumber getVersion() { // return version; // } // } // // Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/TestStatus.java // public enum TestStatus { // INTERNAL_ERROR(0.0), COMPILATION_ERROR(1.0), TEST_FAILURES(2.0), SUCCESS(3.0); // // private final double weight; // // TestStatus(double weight){ // this.weight = weight; // } // // public boolean isLowerThan(TestStatus s){ // return weight < s.weight; // } // } // Path: plugins-compat-tester-cli/src/main/java/org/jenkins/tools/test/CliOptions.java import org.jenkins.tools.test.model.PCTPlugin; import org.jenkins.tools.test.model.TestStatus; import com.beust.jcommander.IParameterValidator; import com.beust.jcommander.IStringConverter; import com.beust.jcommander.Parameter; import com.beust.jcommander.ParameterException; import hudson.util.VersionNumber; import java.util.Collections; import java.io.File; import java.util.ArrayList; import java.util.List; import javax.annotation.CheckForNull; "It is useful to use your own fork releases for an specific plugin if the " + "version is not found in the official repository.\n" + "If set, The PCT will try to use the fallback if a plugin tag is not found in the regular URL.") private String fallbackGitHubOrganization = null; @Parameter(names = "-m2SettingsFile", description = "Maven settings file used while executing maven") private File m2SettingsFile; @Parameter(names = "-mvn", description = "External Maven executable") @CheckForNull private File externalMaven; @Parameter(names = "-skipTestCache", description = "Allows to skip compatibility test cache (by default, to 100 days)\n" + "If set to true, every plugin will be tested, no matter the cache is.") private String skipTestCache = null; @Parameter(names = "-testCacheTimeout", description = "Allows to override the test cache timeout.\n" + "Test cache timeout allows to not perform compatibility test over\n" + "some plugins if compatibility test was performed recently.\n" + "Cache timeout is given in milliseconds") private Long testCacheTimeout = null; @Parameter(names = "-cacheThresholdStatus", description = "Allows to define a minimal cache threshold for test status.\n" + "That is to say, every results lower than this threshold won't be considered\n" + "as part of the cache")
private String cacheThresholdStatus = TestStatus.COMPILATION_ERROR.toString();
jenkinsci/plugin-compat-tester
plugins-compat-tester-cli/src/main/java/org/jenkins/tools/test/CliOptions.java
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PCTPlugin.java // public class PCTPlugin { // private String name; // private final String groupId; // private VersionNumber version; // // public PCTPlugin(String name, String groupId, VersionNumber version) { // this.name = name; // this.groupId = groupId; // this.version = version; // } // // public String getName() { // return name; // } // // @CheckForNull // public String getGroupId() { // return groupId; // } // // public VersionNumber getVersion() { // return version; // } // } // // Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/TestStatus.java // public enum TestStatus { // INTERNAL_ERROR(0.0), COMPILATION_ERROR(1.0), TEST_FAILURES(2.0), SUCCESS(3.0); // // private final double weight; // // TestStatus(double weight){ // this.weight = weight; // } // // public boolean isLowerThan(TestStatus s){ // return weight < s.weight; // } // }
import org.jenkins.tools.test.model.PCTPlugin; import org.jenkins.tools.test.model.TestStatus; import com.beust.jcommander.IParameterValidator; import com.beust.jcommander.IStringConverter; import com.beust.jcommander.Parameter; import com.beust.jcommander.ParameterException; import hudson.util.VersionNumber; import java.util.Collections; import java.io.File; import java.util.ArrayList; import java.util.List; import javax.annotation.CheckForNull;
@Parameter(names = "-cacheThresholdStatus", description = "Allows to define a minimal cache threshold for test status.\n" + "That is to say, every results lower than this threshold won't be considered\n" + "as part of the cache") private String cacheThresholdStatus = TestStatus.COMPILATION_ERROR.toString(); @Parameter(names="-mavenProperties", description = "Define extra properties to be passed to the build." + "Format: 'KEY1=VALUE1:KEY2=VALUE2'. These options will be used a la -D.\n" + "If your property values contain ':' you must use the 'mavenPropertiesFile' option instead.") private String mavenProperties; @Parameter(names="-mavenPropertiesFile", description = "Allow loading some maven properties from a file using the standard java.util.Properties file format. " + "These options will be used a la -D") private String mavenPropertiesFile; @Parameter(names="-hookPrefixes", description = "Prefixes of the extra hooks' classes") private String hookPrefixes; @Parameter(names="-externalHooksJars", description = "Comma-separated list of external hooks jar file locations", listConverter = FileListConverter.class, validateWith = FileValidator.class) private List<File> externalHooksJars; @Parameter(names="-localCheckoutDir", description = "Folder containing either a local (possibly modified) clone of a plugin repository or a set of local clone of different plugins") private String localCheckoutDir; @Parameter(names="-help", description = "Print this help message", help = true) private boolean printHelp; @Parameter(names = "-overridenPlugins", description = "List of plugins to use to test a plugin in place of the normal dependencies." + "Format: '[GROUP_ID:]PLUGIN_NAME=PLUGIN_VERSION", converter = PluginConverter.class, validateWith = PluginValidator.class)
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PCTPlugin.java // public class PCTPlugin { // private String name; // private final String groupId; // private VersionNumber version; // // public PCTPlugin(String name, String groupId, VersionNumber version) { // this.name = name; // this.groupId = groupId; // this.version = version; // } // // public String getName() { // return name; // } // // @CheckForNull // public String getGroupId() { // return groupId; // } // // public VersionNumber getVersion() { // return version; // } // } // // Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/TestStatus.java // public enum TestStatus { // INTERNAL_ERROR(0.0), COMPILATION_ERROR(1.0), TEST_FAILURES(2.0), SUCCESS(3.0); // // private final double weight; // // TestStatus(double weight){ // this.weight = weight; // } // // public boolean isLowerThan(TestStatus s){ // return weight < s.weight; // } // } // Path: plugins-compat-tester-cli/src/main/java/org/jenkins/tools/test/CliOptions.java import org.jenkins.tools.test.model.PCTPlugin; import org.jenkins.tools.test.model.TestStatus; import com.beust.jcommander.IParameterValidator; import com.beust.jcommander.IStringConverter; import com.beust.jcommander.Parameter; import com.beust.jcommander.ParameterException; import hudson.util.VersionNumber; import java.util.Collections; import java.io.File; import java.util.ArrayList; import java.util.List; import javax.annotation.CheckForNull; @Parameter(names = "-cacheThresholdStatus", description = "Allows to define a minimal cache threshold for test status.\n" + "That is to say, every results lower than this threshold won't be considered\n" + "as part of the cache") private String cacheThresholdStatus = TestStatus.COMPILATION_ERROR.toString(); @Parameter(names="-mavenProperties", description = "Define extra properties to be passed to the build." + "Format: 'KEY1=VALUE1:KEY2=VALUE2'. These options will be used a la -D.\n" + "If your property values contain ':' you must use the 'mavenPropertiesFile' option instead.") private String mavenProperties; @Parameter(names="-mavenPropertiesFile", description = "Allow loading some maven properties from a file using the standard java.util.Properties file format. " + "These options will be used a la -D") private String mavenPropertiesFile; @Parameter(names="-hookPrefixes", description = "Prefixes of the extra hooks' classes") private String hookPrefixes; @Parameter(names="-externalHooksJars", description = "Comma-separated list of external hooks jar file locations", listConverter = FileListConverter.class, validateWith = FileValidator.class) private List<File> externalHooksJars; @Parameter(names="-localCheckoutDir", description = "Folder containing either a local (possibly modified) clone of a plugin repository or a set of local clone of different plugins") private String localCheckoutDir; @Parameter(names="-help", description = "Print this help message", help = true) private boolean printHelp; @Parameter(names = "-overridenPlugins", description = "List of plugins to use to test a plugin in place of the normal dependencies." + "Format: '[GROUP_ID:]PLUGIN_NAME=PLUGIN_VERSION", converter = PluginConverter.class, validateWith = PluginValidator.class)
private List<PCTPlugin> overridenPlugins;
jenkinsci/plugin-compat-tester
plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/SkipUIHelperPlugins.java
// Path: plugins-compat-tester/src/main/java/org/jenkins/tools/test/model/TestExecutionResult.java // public class TestExecutionResult { // // private final ExecutedTestNamesDetails testDetails; // // public final List<String> pomWarningMessages; // // public TestExecutionResult(List<String> pomWarningMessages){ // this(pomWarningMessages, new ExecutedTestNamesDetails()); // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "oh well") // public TestExecutionResult(List<String> pomWarningMessages, ExecutedTestNamesDetails testDetails){ // this.pomWarningMessages = Collections.unmodifiableList(pomWarningMessages); // this.testDetails = testDetails; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "oh well") // public ExecutedTestNamesDetails getTestDetails() { // return testDetails; // } // } // // Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/hook/PluginCompatTesterHookBeforeCheckout.java // public abstract class PluginCompatTesterHookBeforeCheckout implements PluginCompatTesterHook { // /** // * Check the value of {@code runCheckout} (if the plugin should be checked out again) and {@code // * pluginDir} (if set, the location of the plugin directory). // */ // @Override // public void validate(Map<String, Object> toCheck) { // if((toCheck.get("runCheckout") != null && // (toCheck.get("runCheckout").getClass().isPrimitive() || ClassUtils.wrapperToPrimitive(toCheck.get("runCheckout").getClass()) != null)) && // (toCheck.get("pluginDir") != null && // toCheck.get("pluginDir") instanceof String) ) { // throw new IllegalArgumentException("A hook modified a required parameter for plugin checkout."); // } // } // }
import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import org.jenkins.tools.test.model.TestExecutionResult; import org.jenkins.tools.test.model.hook.PluginCompatTesterHookBeforeCheckout;
package org.jenkins.tools.test.hook; /** * Short circuit running any UI plugins that function as a helper methods. These are installed as * "plugins" by various parts of the UI and can't be tested through Maven. * * <p>Currently UI features are handed through the acceptance test harness. Future work for testing * JavaScript? Up to the user. * * @see <a href="js-libs">https://github.com/jenkinsci/js-libs</a> */ public class SkipUIHelperPlugins extends PluginCompatTesterHookBeforeCheckout { private static List<String> allBundlePlugins = Arrays.asList( "ace-editor", "bootstrap", "handlebars", "jquery-detached", "js-module-base", "momentjs", "numeraljs"); public SkipUIHelperPlugins() {} @Override public List<String> transformedPlugins() { return Collections.unmodifiableList(allBundlePlugins); } /** * The plugin was identified as something that should be skipped. Create a {@link TestExecutionResult} * preventing forward movement. Also, indicates that we should skip the checkout completely. */ @Override public Map<String, Object> action(Map<String, Object> moreInfo) { moreInfo.put("executionResult",
// Path: plugins-compat-tester/src/main/java/org/jenkins/tools/test/model/TestExecutionResult.java // public class TestExecutionResult { // // private final ExecutedTestNamesDetails testDetails; // // public final List<String> pomWarningMessages; // // public TestExecutionResult(List<String> pomWarningMessages){ // this(pomWarningMessages, new ExecutedTestNamesDetails()); // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "oh well") // public TestExecutionResult(List<String> pomWarningMessages, ExecutedTestNamesDetails testDetails){ // this.pomWarningMessages = Collections.unmodifiableList(pomWarningMessages); // this.testDetails = testDetails; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "oh well") // public ExecutedTestNamesDetails getTestDetails() { // return testDetails; // } // } // // Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/hook/PluginCompatTesterHookBeforeCheckout.java // public abstract class PluginCompatTesterHookBeforeCheckout implements PluginCompatTesterHook { // /** // * Check the value of {@code runCheckout} (if the plugin should be checked out again) and {@code // * pluginDir} (if set, the location of the plugin directory). // */ // @Override // public void validate(Map<String, Object> toCheck) { // if((toCheck.get("runCheckout") != null && // (toCheck.get("runCheckout").getClass().isPrimitive() || ClassUtils.wrapperToPrimitive(toCheck.get("runCheckout").getClass()) != null)) && // (toCheck.get("pluginDir") != null && // toCheck.get("pluginDir") instanceof String) ) { // throw new IllegalArgumentException("A hook modified a required parameter for plugin checkout."); // } // } // } // Path: plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/SkipUIHelperPlugins.java import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import org.jenkins.tools.test.model.TestExecutionResult; import org.jenkins.tools.test.model.hook.PluginCompatTesterHookBeforeCheckout; package org.jenkins.tools.test.hook; /** * Short circuit running any UI plugins that function as a helper methods. These are installed as * "plugins" by various parts of the UI and can't be tested through Maven. * * <p>Currently UI features are handed through the acceptance test harness. Future work for testing * JavaScript? Up to the user. * * @see <a href="js-libs">https://github.com/jenkinsci/js-libs</a> */ public class SkipUIHelperPlugins extends PluginCompatTesterHookBeforeCheckout { private static List<String> allBundlePlugins = Arrays.asList( "ace-editor", "bootstrap", "handlebars", "jquery-detached", "js-module-base", "momentjs", "numeraljs"); public SkipUIHelperPlugins() {} @Override public List<String> transformedPlugins() { return Collections.unmodifiableList(allBundlePlugins); } /** * The plugin was identified as something that should be skipped. Create a {@link TestExecutionResult} * preventing forward movement. Also, indicates that we should skip the checkout completely. */ @Override public Map<String, Object> action(Map<String, Object> moreInfo) { moreInfo.put("executionResult",
new TestExecutionResult(Collections.singletonList("Plugin unsupported at this time, skipping")));
jenkinsci/plugin-compat-tester
plugins-compat-tester/src/main/java/org/jenkins/tools/test/model/MavenPom.java
// Path: plugins-compat-tester/src/main/java/org/jenkins/tools/test/exception/PomTransformationException.java // public class PomTransformationException extends Exception { // // public PomTransformationException(String message, Throwable cause){ // super(message, cause); // } // }
import hudson.util.VersionNumber; import java.io.File; import java.io.IOException; import java.io.Writer; import java.nio.charset.Charset; import java.nio.file.Files; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nonnull; import org.apache.commons.lang.StringUtils; import org.codehaus.plexus.util.FileUtils; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.OutputFormat; import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; import org.jenkins.tools.test.exception.PomTransformationException;
/* * The MIT License * * Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, * Erik Ramfelt, Koichi Fujikawa, Red Hat, Inc., Seiji Sogabe, * Stephen Connolly, Tom Huybrechts, Yahoo! Inc., Alan Harder, CloudBees, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package org.jenkins.tools.test.model; /** * Class encapsulating business around Maven POMs * * @author Frederic Camblor */ public class MavenPom { private static final Logger LOGGER = Logger.getLogger(MavenPom.class.getName()); private final static String GROUP_ID_ELEMENT = "groupId"; private final static String ARTIFACT_ID_ELEMENT = "artifactId"; private final static String VERSION_ELEMENT = "version"; private final static String CLASSIFIER_ELEMENT = "classifier"; private File rootDir; private String pomFileName; public MavenPom(File rootDir) { this(rootDir, "pom.xml"); } private MavenPom(File rootDir, String pomFileName) { this.rootDir = rootDir; this.pomFileName = pomFileName; }
// Path: plugins-compat-tester/src/main/java/org/jenkins/tools/test/exception/PomTransformationException.java // public class PomTransformationException extends Exception { // // public PomTransformationException(String message, Throwable cause){ // super(message, cause); // } // } // Path: plugins-compat-tester/src/main/java/org/jenkins/tools/test/model/MavenPom.java import hudson.util.VersionNumber; import java.io.File; import java.io.IOException; import java.io.Writer; import java.nio.charset.Charset; import java.nio.file.Files; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nonnull; import org.apache.commons.lang.StringUtils; import org.codehaus.plexus.util.FileUtils; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.OutputFormat; import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; import org.jenkins.tools.test.exception.PomTransformationException; /* * The MIT License * * Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, * Erik Ramfelt, Koichi Fujikawa, Red Hat, Inc., Seiji Sogabe, * Stephen Connolly, Tom Huybrechts, Yahoo! Inc., Alan Harder, CloudBees, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package org.jenkins.tools.test.model; /** * Class encapsulating business around Maven POMs * * @author Frederic Camblor */ public class MavenPom { private static final Logger LOGGER = Logger.getLogger(MavenPom.class.getName()); private final static String GROUP_ID_ELEMENT = "groupId"; private final static String ARTIFACT_ID_ELEMENT = "artifactId"; private final static String VERSION_ELEMENT = "version"; private final static String CLASSIFIER_ELEMENT = "classifier"; private File rootDir; private String pomFileName; public MavenPom(File rootDir) { this(rootDir, "pom.xml"); } private MavenPom(File rootDir, String pomFileName) { this.rootDir = rootDir; this.pomFileName = pomFileName; }
public void transformPom(MavenCoordinates coreCoordinates) throws PomTransformationException {
jenkinsci/plugin-compat-tester
plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/PipelineStageViewHook.java
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // }
import hudson.model.UpdateSite; import java.util.Map; import org.jenkins.tools.test.model.PomData;
package org.jenkins.tools.test.hook; public class PipelineStageViewHook extends AbstractMultiParentHook { @Override protected String getParentFolder() { return "pipeline-stage-view"; } @Override protected String getParentProjectName() { return "pipeline-stage-view"; } @Override protected String getPluginFolderName(UpdateSite.Plugin currentPlugin){ return (currentPlugin.getDisplayName().equals("pipeline-rest-api")) ? "rest-api" : "ui"; } @Override public boolean check(Map<String, Object> info) { return isPipelineStageViewPlugin(info); } private boolean isPipelineStageViewPlugin(Map<String, Object> moreInfo) {
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // } // Path: plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/PipelineStageViewHook.java import hudson.model.UpdateSite; import java.util.Map; import org.jenkins.tools.test.model.PomData; package org.jenkins.tools.test.hook; public class PipelineStageViewHook extends AbstractMultiParentHook { @Override protected String getParentFolder() { return "pipeline-stage-view"; } @Override protected String getParentProjectName() { return "pipeline-stage-view"; } @Override protected String getPluginFolderName(UpdateSite.Plugin currentPlugin){ return (currentPlugin.getDisplayName().equals("pipeline-rest-api")) ? "rest-api" : "ui"; } @Override public boolean check(Map<String, Object> info) { return isPipelineStageViewPlugin(info); } private boolean isPipelineStageViewPlugin(Map<String, Object> moreInfo) {
PomData data = (PomData) moreInfo.get("pomData");
jenkinsci/plugin-compat-tester
plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/DeclarativePipelineMigrationHook.java
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // }
import org.jenkins.tools.test.model.PomData; import hudson.model.UpdateSite; import java.util.Map;
package org.jenkins.tools.test.hook; /** * Workaround for the Declarative Pipeline Migration Assistant plugins since they are * stored in a central repository. */ public class DeclarativePipelineMigrationHook extends AbstractMultiParentHook { @Override protected String getParentFolder() { return "declarative-pipeline-migration-assistant"; } @Override protected String getParentProjectName() { return "declarative-pipeline-migration-assistant"; } @Override protected String getPluginFolderName(UpdateSite.Plugin currentPlugin){ return currentPlugin.getDisplayName(); } @Override public boolean check(Map<String, Object> info) { return isPlugin(info); } private boolean isPlugin(Map<String, Object> moreInfo) {
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // } // Path: plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/DeclarativePipelineMigrationHook.java import org.jenkins.tools.test.model.PomData; import hudson.model.UpdateSite; import java.util.Map; package org.jenkins.tools.test.hook; /** * Workaround for the Declarative Pipeline Migration Assistant plugins since they are * stored in a central repository. */ public class DeclarativePipelineMigrationHook extends AbstractMultiParentHook { @Override protected String getParentFolder() { return "declarative-pipeline-migration-assistant"; } @Override protected String getParentProjectName() { return "declarative-pipeline-migration-assistant"; } @Override protected String getPluginFolderName(UpdateSite.Plugin currentPlugin){ return currentPlugin.getDisplayName(); } @Override public boolean check(Map<String, Object> info) { return isPlugin(info); } private boolean isPlugin(Map<String, Object> moreInfo) {
PomData data = (PomData) moreInfo.get("pomData");
jenkinsci/plugin-compat-tester
plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/StructsHook.java
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // }
import hudson.model.UpdateSite; import hudson.util.VersionNumber; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import org.jenkins.tools.test.model.PomData;
package org.jenkins.tools.test.hook; public class StructsHook extends AbstractMultiParentHook { private static final Logger LOGGER = Logger.getLogger(StructsHook.class.getName()); @Override protected String getParentFolder() { return "structs-plugin"; } @Override protected String getParentProjectName() { return "structs-parent"; } @Override public boolean check(Map<String, Object> info) { return isStructsPlugin(info); } @Override protected String getPluginFolderName(UpdateSite.Plugin currentPlugin) { return "plugin"; } private boolean isStructsPlugin(Map<String, Object> moreInfo) {
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // } // Path: plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/StructsHook.java import hudson.model.UpdateSite; import hudson.util.VersionNumber; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import org.jenkins.tools.test.model.PomData; package org.jenkins.tools.test.hook; public class StructsHook extends AbstractMultiParentHook { private static final Logger LOGGER = Logger.getLogger(StructsHook.class.getName()); @Override protected String getParentFolder() { return "structs-plugin"; } @Override protected String getParentProjectName() { return "structs-parent"; } @Override public boolean check(Map<String, Object> info) { return isStructsPlugin(info); } @Override protected String getPluginFolderName(UpdateSite.Plugin currentPlugin) { return "plugin"; } private boolean isStructsPlugin(Map<String, Object> moreInfo) {
PomData data = (PomData) moreInfo.get("pomData");
jenkinsci/plugin-compat-tester
plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/SwarmHook.java
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // }
import hudson.model.UpdateSite; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import org.jenkins.tools.test.model.PomData;
package org.jenkins.tools.test.hook; public class SwarmHook extends AbstractMultiParentHook { private static final Logger LOGGER = Logger.getLogger(SwarmHook.class.getName()); @Override protected String getParentFolder() { return "swarm"; } @Override protected String getParentProjectName() { return "swarm-plugin"; } @Override protected String getPluginFolderName(UpdateSite.Plugin currentPlugin) { return "plugin"; } @Override public boolean check(Map<String, Object> info) { return isSwarmPlugin(info); } private boolean isSwarmPlugin(Map<String, Object> moreInfo) {
// Path: plugins-compat-tester-model/src/main/java/org/jenkins/tools/test/model/PomData.java // public class PomData { // public final String artifactId; // public final String groupId; // // @Nonnull // private final String packaging; // // @CheckForNull // public final MavenCoordinates parent; // private String connectionUrl; // private String scmTag; // private List<String> warningMessages = new ArrayList<>(); // // public PomData(String artifactId, @CheckForNull String packaging, String connectionUrl, String scmTag, @CheckForNull MavenCoordinates parent, String groupId){ // this.artifactId = artifactId; // this.groupId = groupId; // this.packaging = packaging != null ? packaging : "jar"; // this.setConnectionUrl(connectionUrl); // this.scmTag = scmTag; // this.parent = parent; // } // // public String getConnectionUrl() { // return connectionUrl; // } // // public void setConnectionUrl(String connectionUrl) { // this.connectionUrl = connectionUrl; // } // // @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Deliberately mutable") // public List<String> getWarningMessages() { // return warningMessages; // } // // @Nonnull // public String getPackaging() { // return packaging; // } // // public String getScmTag() { // return scmTag; // } // // public boolean isPluginPOM() { // if (parent != null) { // return parent.matches("org.jenkins-ci.plugins", "plugin"); // } else { // Interpolate by packaging // return "hpi".equalsIgnoreCase(packaging); // } // } // } // Path: plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/SwarmHook.java import hudson.model.UpdateSite; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import org.jenkins.tools.test.model.PomData; package org.jenkins.tools.test.hook; public class SwarmHook extends AbstractMultiParentHook { private static final Logger LOGGER = Logger.getLogger(SwarmHook.class.getName()); @Override protected String getParentFolder() { return "swarm"; } @Override protected String getParentProjectName() { return "swarm-plugin"; } @Override protected String getPluginFolderName(UpdateSite.Plugin currentPlugin) { return "plugin"; } @Override public boolean check(Map<String, Object> info) { return isSwarmPlugin(info); } private boolean isSwarmPlugin(Map<String, Object> moreInfo) {
PomData data = (PomData) moreInfo.get("pomData");